On 2015-09-09 09:23, Bachtin, Dmitri wrote: > libjson's json_object_from_file takes a non-const char buffer as > its second parameter while libjson-c takes a const one. Use > strdup() to avoid using const data as non-const. > > Signed-off-by: Dmitri Bachtin <dbach...@init-ka.de> > --- > blobmsg_json.c | 5 ++++- > 1 files changed, 4 insertions(+), 1 deletions(-) > > diff --git a/blobmsg_json.c b/blobmsg_json.c > index ffde23d..de876cf 100644 > --- a/blobmsg_json.c > +++ b/blobmsg_json.c > @@ -97,7 +97,10 @@ out: > > bool blobmsg_add_json_from_file(struct blob_buf *b, const char *file) > { > - return __blobmsg_add_json(b, json_object_from_file(file)); > + char* __file = strdup(file); > + bool result = __blobmsg_add_json(b, json_object_from_file(__file)); > + free(__file); > + return result; I think the non-const parameter of json_object_from_file is a bug, and in that case, a cast is better than a completely unnecessary strdup().
- Felix _______________________________________________ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel