diff options
author | Petr Štetiar <ynezz@true.cz> | 2019-12-11 10:36:36 +0100 |
---|---|---|
committer | Petr Štetiar <ynezz@true.cz> | 2019-12-16 23:39:16 +0100 |
commit | d2e026a33df81f116ceb2567056346f38d139706 (patch) | |
tree | 8f4631fb72aed09dad0d2f5be15b61d8dbf64e99 /examples | |
parent | 5d7ca8309d0a1614d829df9ecd72553bcd6b5ec6 (diff) | |
download | ubus-d2e026a33df81f116ceb2567056346f38d139706.tar.gz |
iron out all extra compiler warnings
clang-9 on x86/64 has reported following warnings/errors:
libubus-acl.c:123:2: error: comparison of integers of different signs: 'size_t' (aka 'unsigned long') and 'int' [-Werror,-Wsign-compare]
libubus-io.c:108:18: error: comparison of integers of different signs: 'int' and 'size_t' (aka 'unsigned long') [-Werror,-Wsign-compare]
libubus-io.c:395:56: error: comparison of integers of different signs: 'ssize_t' (aka 'long') and 'size_t' (aka 'unsigned long') [-Werror,-Wsign-compare]
libubus-req.c:441:4: error: comparison of integers of different signs: 'size_t' (aka 'unsigned long') and 'int' [-Werror,-Wsign-compare]
ubusd_acl.c:119:18: error: comparison of integers of different signs: 'int' and 'unsigned long' [-Werror,-Wsign-compare]
ubusd_acl.c:152:5: error: comparison of integers of different signs: 'size_t' (aka 'unsigned long') and 'int' [-Werror,-Wsign-compare]
ubusd_acl.c:348:3: error: comparison of integers of different signs: 'size_t' (aka 'unsigned long') and 'int' [-Werror,-Wsign-compare]
ubusd_acl.c:352:3: error: comparison of integers of different signs: 'size_t' (aka 'unsigned long') and 'int' [-Werror,-Wsign-compare]
ubusd_acl.c:357:3: error: comparison of integers of different signs: 'size_t' (aka 'unsigned long') and 'int' [-Werror,-Wsign-compare]
ubusd_acl.c:362:3: error: comparison of integers of different signs: 'size_t' (aka 'unsigned long') and 'int' [-Werror,-Wsign-compare]
ubusd_acl.c:367:3: error: comparison of integers of different signs: 'size_t' (aka 'unsigned long') and 'int' [-Werror,-Wsign-compare]
ubusd_acl.c:447:16: error: comparison of integers of different signs: 'int' and '__size_t' (aka 'unsigned long') [-Werror,-Wsign-compare]
ubusd_acl.c:502:18: error: comparison of integers of different signs: 'int' and 'unsigned long' [-Werror,-Wsign-compare]
ubusd.c:123:13: error: comparison of integers of different signs: 'int' and 'unsigned long' [-Werror,-Wsign-compare]
ubusd.c:170:15: error: comparison of integers of different signs: 'int' and 'unsigned long' [-Werror,-Wsign-compare]
ubusd.c:262:43: error: comparison of integers of different signs: 'int' and 'unsigned long' [-Werror,-Wsign-compare]
ubusd.c:287:30: error: comparison of integers of different signs: 'int' and 'unsigned long' [-Werror,-Wsign-compare]
ubusd_event.c:170:18: error: comparison of integers of different signs: 'int' and 'unsigned long' [-Werror,-Wsign-compare]
ubusd_obj.c:71:2: error: comparison of integers of different signs: 'size_t' (aka 'unsigned long') and 'int' [-Werror,-Wsign-compare]
Signed-off-by: Petr Štetiar <ynezz@true.cz>
Diffstat (limited to 'examples')
-rw-r--r-- | examples/server.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/examples/server.c b/examples/server.c index e0cde0b..004eaf3 100644 --- a/examples/server.c +++ b/examples/server.c @@ -84,7 +84,7 @@ static int test_hello(struct ubus_context *ctx, struct ubus_object *obj, { struct hello_request *hreq; struct blob_attr *tb[__HELLO_MAX]; - const char *format = "%s received a message: %s"; + const char format[] = "%s received a message: %s"; const char *msgstr = "(unknown)"; blobmsg_parse(hello_policy, ARRAY_SIZE(hello_policy), tb, blob_data(msg), blob_len(msg)); @@ -92,11 +92,12 @@ static int test_hello(struct ubus_context *ctx, struct ubus_object *obj, if (tb[HELLO_MSG]) msgstr = blobmsg_data(tb[HELLO_MSG]); - hreq = calloc(1, sizeof(*hreq) + strlen(format) + strlen(obj->name) + strlen(msgstr) + 1); + size_t len = sizeof(*hreq) + sizeof(format) + strlen(obj->name) + strlen(msgstr) + 1; + hreq = calloc(1, len); if (!hreq) return UBUS_STATUS_UNKNOWN_ERROR; - sprintf(hreq->data, format, obj->name, msgstr); + snprintf(hreq->data, len, format, obj->name, msgstr); ubus_defer_request(ctx, req, &hreq->req); hreq->timeout.cb = test_hello_reply; uloop_timeout_set(&hreq->timeout, 1000); |