Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.openwrt.org/project/libubox.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2023-04-16blobmsg: Don't do at run-time what can be done at compile-timePhilip Prindeville
Repeatedly calling a run-time function like strlen() on an invariant value is inefficient, especially if that value can be computed once (at initialization) or better yet, computed at compile-time. Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
2020-01-20blobmsg_json: prefer snprintf usagePetr Štetiar
Better safe than sorry and while at it prefer use of PRId16 and PRId32 formatting constants as well. Reviewed-by: Jo-Philipp Wich <jo@mein.io> Signed-off-by: Petr Štetiar <ynezz@true.cz>
2020-01-20blobmsg: blobmsg_add_json_element() 64-bit valuesDainis Jonitis
libjson-c json_type_int values are stored as int64_t. Use json_object_get_int64() instead of json_object_get_int() to avoid clamping to INT32_MAX. Reviewed-by: Jo-Philipp Wich <jo@mein.io> Signed-off-by: Dainis Jonitis <dainis.jonitis@ubnt.com> [fixed author to match SoB, added unit test results] Signed-off-by: Petr Štetiar <ynezz@true.cz>
2020-01-20blobmsg_json: fix int16 serializationPetr Štetiar
int16 blobmsg type is currently being serialized as uint16_t due to missing cast during JSON output. Following blobmsg content: bar-min: -32768 (i16) bar-max: 32767 (i16) Produces following JSON: { "bar-min":32768,"bar-max":32767 } Whereas one would expect: { "bar-min":-32768,"bar-max":32767 } Reviewed-by: Jo-Philipp Wich <jo@mein.io> Signed-off-by: Petr Štetiar <ynezz@true.cz>
2019-11-24blobmsg_json: fix possible uninitialized struct memberPetr Štetiar
clang-10 analyzer reports following: blobmsg_json.c:285:2: warning: The expression is an uninitialized value. The computed value will also be garbage s->indent_level++; ^~~~~~~~~~~~~~~~~ Signed-off-by: Petr Štetiar <ynezz@true.cz>
2019-11-20iron out all extra compiler warningsPetr Štetiar
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>
2019-02-27blobmsg_json: blobmsg_format_string: do not escape '/'Yousong Zhou
Resolves FS#2147 Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
2017-01-04blobmsg: add support for doubleAndré Gaul
This adds support for double floating point type to make it more JSON compatible. For type checking it also adds a stub BLOB_ATTR_DOUBLE type. If necessary, the accessor functions for blob can be added later Signed-off-by: André Gaul <andre@gaul.io> Signed-off-by: Felix Fietkau <nbd@nbd.name>
2016-07-02blobmsg_json: add new functions blobmsg_format_json_value*Matthias Schiffer
The current blobmsg_format_json* functions will return invalid JSON when the "list" argument is given as false (blobmsg_format_element() will output the name of the blob_attr as if the value is printed as part of a JSON object). To avoid breaking software relying on this behaviour, introduce new functions which will never print the blob_attr name and thus always produce valid JSON. Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net> Acked-by: Jo-Philipp Wich <jo@mein.io> Signed-off-by: Felix Fietkau <nbd@nbd.name> [cosmetic style fix]
2016-06-26Fix various memory management issuesMatthias Schiffer
Consistently handle allocation failures. Some functions are changed to return bool or int instead of void to allow returning an error. Also fix a buffer size miscalculation in lua/uloop and use _exit() instead of exit() on errors after forking. Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
2016-04-06blobmsg_json: simplify add_separator and fix thread-safetyMatthias Schiffer
The hard-coded length limits are replaced with strlen to make the code more robust. Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
2016-02-10blobmsg_json: support json_type_null in blobmsg_add_json_element()Jo-Philipp Wich
We already serialize BLOBMSG_TYPE_UNSPEC as "null" so represent JSON null values as blob attribute type unspec with payload size zero. Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
2014-09-23blobmsg_json: include json.h inside blobmsg_json.c instead of the public ↵Felix Fietkau
header file Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-09-23avoid using the deprecated is_error() function from json-cFelix Fietkau
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-05-31blobmsg_json: use cross-platform macro for fprintf on 64-bit valuesFelix Fietkau
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-04-26blobmsg_json: let blobmsg_format_json_with_cb with list == true also format ↵Felix Fietkau
arrays Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-04-12blobmsg_json: fix a memleak on errorFelix Fietkau
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-03-12blobmsg_json: unconditionally use blobmsg data/len accessor functionsFelix Fietkau
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-11-27blobmsg_json: do not emit any whitespace when formatting without indentationJo-Philipp Wich
2013-10-04blobmsg_json: allow signed output of integersFelix Fietkau
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-06-21blobmsg_json: do not corrupt UTF-8 stringsFelix Fietkau
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-06-21blobmsg_json: fix \u escaping for control charactersFelix Fietkau
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-05-29blobmsg_json: add blobmsg_add_json_from_fileFelix Fietkau
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-01-30blobmsg_json: fix buffer growing on blobmsg json formattingFelix Fietkau
2013-01-13blobmsg: allow BLOBMSG_TYPE_UNSPEC attributes, treat them as null for JSON ↵Felix Fietkau
conversion Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-01-06blobmsg_json: export blobmsg_add_objectFelix Fietkau
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2012-05-26switch blobmsg_json over to permissive licenseFelix Fietkau
2011-11-17blobmsg: add missing endian conversionsFelix Fietkau
2011-11-17blobmsg_json: print int16 elements in blobmsg_format_element (patch by Luka ↵Felix Fietkau
Perkov)
2011-07-29add BLOBMSG_TYPE_BOOL as an alias for BLOBMSG_TYPE_INT8Felix Fietkau
2011-07-18blobmsg_json: support indenting of output dataFelix Fietkau
2011-03-27remove int16, use int8 as bool instead of integerFelix Fietkau
2011-02-07add a cast to fix 64 bit issuesFelix Fietkau
2011-02-07validate blobmsg attributes before converting them to jsonFelix Fietkau
2011-02-07properly null-terminate formatted json stringsFelix Fietkau
2011-02-06move json formatting to the blobmsg_json libraryFelix Fietkau
2011-02-06add missing copyright headersFelix Fietkau
2011-02-06add a json to blobmsg parsing libraryFelix Fietkau