mirror of https://gerrit.osmocom.org/libosmocore
utils: Fix -Wsign-compare warnings
Change-Id: I8b1118ca519b0a419a42eab8b7d4ba9e26a0bab5
This commit is contained in:
parent
c85aaed3fb
commit
7d6166a0e3
|
@ -40,7 +40,7 @@
|
||||||
|
|
||||||
/*! A mapping between human-readable string and numeric value */
|
/*! A mapping between human-readable string and numeric value */
|
||||||
struct value_string {
|
struct value_string {
|
||||||
int value; /*!< numeric value */
|
uint32_t value; /*!< numeric value */
|
||||||
const char *str; /*!< human-readable string */
|
const char *str; /*!< human-readable string */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ uint8_t osmo_char2bcd(char c);
|
||||||
int osmo_bcd2str(char *dst, size_t dst_size, const uint8_t *bcd, int start_nibble, int end_nibble, bool allow_hex);
|
int osmo_bcd2str(char *dst, size_t dst_size, const uint8_t *bcd, int start_nibble, int end_nibble, bool allow_hex);
|
||||||
int osmo_str2bcd(uint8_t *dst, size_t dst_size, const char *digits, int start_nibble, int end_nibble, bool allow_hex);
|
int osmo_str2bcd(uint8_t *dst, size_t dst_size, const char *digits, int start_nibble, int end_nibble, bool allow_hex);
|
||||||
|
|
||||||
int osmo_hexparse(const char *str, uint8_t *b, int max_len);
|
int osmo_hexparse(const char *str, uint8_t *b, unsigned int max_len);
|
||||||
|
|
||||||
char *osmo_ubit_dump_buf(char *buf, size_t buf_len, const uint8_t *bits, unsigned int len);
|
char *osmo_ubit_dump_buf(char *buf, size_t buf_len, const uint8_t *bits, unsigned int len);
|
||||||
char *osmo_ubit_dump(const uint8_t *bits, unsigned int len);
|
char *osmo_ubit_dump(const uint8_t *bits, unsigned int len);
|
||||||
|
@ -323,7 +323,7 @@ int osmo_str_to_int(int *result, const char *str, int base, int min_val, int max
|
||||||
_needed = FUNC_BUF(_str, _len, ## FUNC_BUF_ARGS); \
|
_needed = FUNC_BUF(_str, _len, ## FUNC_BUF_ARGS); \
|
||||||
if (_needed < 0) \
|
if (_needed < 0) \
|
||||||
goto OSMO_NAME_C_on_error; \
|
goto OSMO_NAME_C_on_error; \
|
||||||
if (_needed < _len) \
|
if ((unsigned int) _needed < _len) \
|
||||||
return _str; \
|
return _str; \
|
||||||
_len = _needed + 1; \
|
_len = _needed + 1; \
|
||||||
if (_str) \
|
if (_str) \
|
||||||
|
|
10
src/utils.c
10
src/utils.c
|
@ -202,7 +202,7 @@ int osmo_str2bcd(uint8_t *dst, size_t dst_size, const char *digits, int start_ni
|
||||||
if (end_nibble & 1)
|
if (end_nibble & 1)
|
||||||
end_nibble++;
|
end_nibble++;
|
||||||
}
|
}
|
||||||
if ((end_nibble / 2) > dst_size)
|
if ((unsigned int) (end_nibble / 2) > dst_size)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
for (nibble_i = start_nibble; nibble_i < end_nibble; nibble_i++) {
|
for (nibble_i = start_nibble; nibble_i < end_nibble; nibble_i++) {
|
||||||
|
@ -237,7 +237,7 @@ int osmo_str2bcd(uint8_t *dst, size_t dst_size, const char *digits, int start_ni
|
||||||
* \param[in] max_len maximum space in output buffer
|
* \param[in] max_len maximum space in output buffer
|
||||||
* \returns number of parsed octets, or -1 on error
|
* \returns number of parsed octets, or -1 on error
|
||||||
*/
|
*/
|
||||||
int osmo_hexparse(const char *str, uint8_t *b, int max_len)
|
int osmo_hexparse(const char *str, uint8_t *b, unsigned int max_len)
|
||||||
|
|
||||||
{
|
{
|
||||||
char c;
|
char c;
|
||||||
|
@ -312,7 +312,7 @@ const char *osmo_hexdump_buf(char *out_buf, size_t out_buf_size, const unsigned
|
||||||
for (i = 0; i < len; i++) {
|
for (i = 0; i < len; i++) {
|
||||||
const char *delimp = delim;
|
const char *delimp = delim;
|
||||||
int len_remain = out_buf_size - (cur - out_buf) - 1;
|
int len_remain = out_buf_size - (cur - out_buf) - 1;
|
||||||
if (len_remain < (2 + delim_len)
|
if (len_remain < (int) (2 + delim_len)
|
||||||
&& !(!delim_after_last && i == (len - 1) && len_remain >= 2))
|
&& !(!delim_after_last && i == (len - 1) && len_remain >= 2))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -340,7 +340,7 @@ const char *osmo_hexdump_buf(char *out_buf, size_t out_buf_size, const unsigned
|
||||||
*/
|
*/
|
||||||
char *osmo_ubit_dump_buf(char *buf, size_t buf_len, const uint8_t *bits, unsigned int len)
|
char *osmo_ubit_dump_buf(char *buf, size_t buf_len, const uint8_t *bits, unsigned int len)
|
||||||
{
|
{
|
||||||
int i;
|
unsigned int i;
|
||||||
|
|
||||||
if (len > buf_len-1)
|
if (len > buf_len-1)
|
||||||
len = buf_len-1;
|
len = buf_len-1;
|
||||||
|
@ -1222,7 +1222,7 @@ int osmo_float_str_to_int(int64_t *val, const char *str, unsigned int precision)
|
||||||
int64_t precision_factor;
|
int64_t precision_factor;
|
||||||
int64_t integer_max;
|
int64_t integer_max;
|
||||||
int64_t decimal_max;
|
int64_t decimal_max;
|
||||||
int i;
|
unsigned int i;
|
||||||
|
|
||||||
OSMO_ASSERT(val);
|
OSMO_ASSERT(val);
|
||||||
*val = 0;
|
*val = 0;
|
||||||
|
|
Loading…
Reference in New Issue