Browse Source

iron out all extra compiler warnings

gcc-9 on x86/64 has reported following issues:

 base64.c:173:17: error: comparison of integer expressions of different signedness: ‘int’ and ‘size_t’ {aka ‘long unsigned int’} [-Werror=sign-compare]
 base64.c:230:18: error: comparison of integer expressions of different signedness: ‘int’ and ‘size_t’ {aka ‘long unsigned int’} [-Werror=sign-compare]
 base64.c:238:18: error: comparison of integer expressions of different signedness: ‘int’ and ‘size_t’ {aka ‘long unsigned int’} [-Werror=sign-compare]
 base64.c:242:22: error: comparison of integer expressions of different signedness: ‘int’ and ‘size_t’ {aka ‘long unsigned int’} [-Werror=sign-compare]
 base64.c:252:18: error: comparison of integer expressions of different signedness: ‘int’ and ‘size_t’ {aka ‘long unsigned int’} [-Werror=sign-compare]
 base64.c:256:22: error: comparison of integer expressions of different signedness: ‘int’ and ‘size_t’ {aka ‘long unsigned int’} [-Werror=sign-compare]
 base64.c:266:18: error: comparison of integer expressions of different signedness: ‘int’ and ‘size_t’ {aka ‘long unsigned int’} [-Werror=sign-compare]
 base64.c:315:27: error: comparison of integer expressions of different signedness: ‘int’ and ‘size_t’ {aka ‘long unsigned int’} [-Werror=sign-compare]
 base64.c:329:15: error: comparison of integer expressions of different signedness: ‘int’ and ‘size_t’ {aka ‘long unsigned int’} [-Werror=sign-compare]
 blob.c:207:11: error: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Werror=sign-compare]
 blob.c:210:11: error: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Werror=sign-compare]
 blob.c:243:31: error: comparison of integer expressions of different signedness: ‘int’ and ‘unsigned int’ [-Werror=sign-compare]
 blob.c:246:31: error: comparison of integer expressions of different signedness: ‘int’ and ‘unsigned int’ [-Werror=sign-compare]
 blob.h:245:37: error: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Werror=sign-compare]
 blob.h:253:37: error: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Werror=sign-compare]
 blobmsg.h:269:37: error: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Werror=sign-compare]
 blobmsg_json.c:155:10: error: comparison of integer expressions of different signedness: ‘int’ and ‘size_t’ {aka ‘long unsigned int’} [-Werror=sign-compare]
 examples/../blob.h:245:37: error: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Werror=sign-compare]
 examples/../blobmsg.h:269:37: error: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Werror=sign-compare]
 json_script.c:590:7: error: this statement may fall through [-Werror=implicit-fallthrough=]

Signed-off-by: Petr Štetiar <ynezz@true.cz>
master
Petr Štetiar 2 years ago
parent
commit
6228df9de9
8 changed files with 24 additions and 20 deletions
  1. +3
    -2
      base64.c
  2. +3
    -3
      blob.c
  3. +3
    -3
      blob.h
  4. +1
    -1
      blobmsg.c
  5. +2
    -2
      blobmsg_json.c
  6. +1
    -1
      examples/blobmsg-example.c
  7. +1
    -1
      examples/json_script-example.c
  8. +10
    -7
      json_script.c

+ 3
- 2
base64.c View File

@ -142,7 +142,7 @@ int b64_encode(const void *_src, size_t srclength,
size_t datalength = 0;
u_char input[3] = {0};
u_char output[4];
int i;
size_t i;
while (2 < srclength) {
input[0] = *src++;
@ -200,7 +200,8 @@ int b64_decode(const void *_src, void *dest, size_t targsize)
{
const char *src = _src;
unsigned char *target = dest;
int tarindex, state, ch;
int state, ch;
size_t tarindex;
u_char nextbyte;
char *pos;


+ 3
- 3
blob.c View File

@ -186,7 +186,7 @@ blob_nest_end(struct blob_buf *buf, void *cookie)
buf->head = attr;
}
static const int blob_type_minlen[BLOB_ATTR_LAST] = {
static const size_t blob_type_minlen[BLOB_ATTR_LAST] = {
[BLOB_ATTR_STRING] = 1,
[BLOB_ATTR_INT8] = sizeof(uint8_t),
[BLOB_ATTR_INT16] = sizeof(uint16_t),
@ -222,12 +222,12 @@ blob_parse(struct blob_attr *attr, struct blob_attr **data, const struct blob_at
{
struct blob_attr *pos;
int found = 0;
int rem;
size_t rem;
memset(data, 0, sizeof(struct blob_attr *) * max);
blob_for_each_attr(pos, attr, rem) {
int id = blob_id(pos);
int len = blob_len(pos);
size_t len = blob_len(pos);
if (id >= max)
continue;


+ 3
- 3
blob.h View File

@ -96,7 +96,7 @@ blob_is_extended(const struct blob_attr *attr)
/*
* blob_len: returns the length of the attribute's payload
*/
static inline unsigned int
static inline size_t
blob_len(const struct blob_attr *attr)
{
return (be32_to_cpu(attr->id_len) & BLOB_ATTR_LEN_MASK) - sizeof(struct blob_attr);
@ -105,7 +105,7 @@ blob_len(const struct blob_attr *attr)
/*
* blob_raw_len: returns the complete length of an attribute (including the header)
*/
static inline unsigned int
static inline size_t
blob_raw_len(const struct blob_attr *attr)
{
return blob_len(attr) + sizeof(struct blob_attr);
@ -114,7 +114,7 @@ blob_raw_len(const struct blob_attr *attr)
/*
* blob_pad_len: returns the padded length of an attribute (including the header)
*/
static inline unsigned int
static inline size_t
blob_pad_len(const struct blob_attr *attr)
{
unsigned int len = blob_raw_len(attr);


+ 1
- 1
blobmsg.c View File

@ -67,7 +67,7 @@ int blobmsg_check_array(const struct blob_attr *attr, int type)
{
struct blob_attr *cur;
bool name;
int rem;
size_t rem;
int size = 0;
switch (blobmsg_type(attr)) {


+ 2
- 2
blobmsg_json.c View File

@ -146,7 +146,7 @@ static bool blobmsg_puts(struct strbuf *s, const char *c, int len)
static void add_separator(struct strbuf *s)
{
const char *indent_chars = "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t";
int len;
size_t len;
if (!s->indent)
return;
@ -279,7 +279,7 @@ static void blobmsg_format_json_list(struct strbuf *s, struct blob_attr *attr, i
{
struct blob_attr *pos;
bool first = true;
int rem = len;
size_t rem = len;
blobmsg_puts(s, (array ? "[" : "{" ), 1);
s->indent_level++;


+ 1
- 1
examples/blobmsg-example.c View File

@ -15,7 +15,7 @@ static const char *indent_str = "\t\t\t\t\t\t\t\t\t\t\t\t\t";
static void dump_attr_data(struct blob_attr *data, int indent, int next_indent);
static void
dump_table(struct blob_attr *head, int len, int indent, bool array)
dump_table(struct blob_attr *head, size_t len, int indent, bool array)
{
struct blob_attr *attr;
struct blobmsg_hdr *hdr;


+ 1
- 1
examples/json_script-example.c View File

@ -14,7 +14,7 @@ static void handle_command(struct json_script_ctx *ctx, const char *name,
struct blob_attr *data, struct blob_attr *vars)
{
struct blob_attr *cur;
int rem;
size_t rem;
fprintf(stdout, "%s", name);
blobmsg_for_each_attr(cur, data, rem)


+ 10
- 7
json_script.c View File

@ -95,7 +95,7 @@ const char *json_script_find_var(struct json_script_ctx *ctx, struct blob_attr *
const char *name)
{
struct blob_attr *cur;
int rem;
size_t rem;
blobmsg_for_each_attr(cur, vars, rem) {
if (blobmsg_type(cur) != BLOBMSG_TYPE_STRING)
@ -164,7 +164,7 @@ static int handle_case(struct json_call *call, struct blob_attr *expr)
{
struct blob_attr *tb[3], *cur;
const char *var;
int rem;
size_t rem;
json_get_tuple(expr, tb, BLOBMSG_TYPE_STRING, BLOBMSG_TYPE_TABLE);
if (!tb[1] || !tb[2])
@ -233,7 +233,7 @@ static int expr_eq_regex(struct json_call *call, struct blob_attr *expr, bool re
struct json_script_ctx *ctx = call->ctx;
struct blob_attr *tb[3], *cur;
const char *var;
int rem;
size_t rem;
json_get_tuple(expr, tb, BLOBMSG_TYPE_STRING, 0);
if (!tb[1] || !tb[2])
@ -277,7 +277,7 @@ static int handle_expr_has(struct json_call *call, struct blob_attr *expr)
{
struct json_script_ctx *ctx = call->ctx;
struct blob_attr *tb[3], *cur;
int rem;
size_t rem;
json_get_tuple(expr, tb, 0, 0);
if (!tb[1])
@ -306,7 +306,8 @@ static int handle_expr_has(struct json_call *call, struct blob_attr *expr)
static int expr_and_or(struct json_call *call, struct blob_attr *expr, bool and)
{
struct blob_attr *cur;
int ret, rem;
int ret;
size_t rem;
int i = 0;
blobmsg_for_each_attr(cur, expr, rem) {
@ -515,7 +516,8 @@ static int cmd_process_strings(struct json_call *call, struct blob_attr *attr)
struct json_script_ctx *ctx = call->ctx;
struct blob_attr *cur;
int args = -1;
int rem, ret;
int ret;
size_t rem;
void *c;
blob_buf_init(&ctx->buf, 0);
@ -572,7 +574,7 @@ static int json_process_cmd(struct json_call *call, struct blob_attr *block)
{
struct json_script_ctx *ctx = call->ctx;
struct blob_attr *cur;
int rem;
size_t rem;
int ret;
int i = 0;
@ -589,6 +591,7 @@ static int json_process_cmd(struct json_call *call, struct blob_attr *block)
case BLOBMSG_TYPE_STRING:
if (!i)
return __json_process_cmd(call, block);
/* fall through */
default:
ret = json_process_cmd(call, cur);
if (ret < -1)


Loading…
Cancel
Save