projects
/
project
/
ubus.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
iron out all extra compiler warnings
[project/ubus.git]
/
examples
/
server.c
diff --git
a/examples/server.c
b/examples/server.c
index e0cde0bf3a8660941d34d0dcc29253f7fa0ad91e..004eaf3a7ae183ac650b417b387df55c46359d41 100644
(file)
--- 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];
{
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));
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]);
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;
if (!hreq)
return UBUS_STATUS_UNKNOWN_ERROR;
- s
printf(hreq->data
, format, obj->name, msgstr);
+ s
nprintf(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);
ubus_defer_request(ctx, req, &hreq->req);
hreq->timeout.cb = test_hello_reply;
uloop_timeout_set(&hreq->timeout, 1000);