Felix Fietkau [Wed, 14 Jun 2017 10:08:42 +0000 (12:08 +0200)]
runqueue: fix use-after-free bug
Calling t->complete in runqueue_task_complete can free the memory
associated with t. Change the runqueue_start_next accordingly.
Fixes https://github.com/openwrt/openwrt/issues/493
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Ted Hess [Thu, 23 Feb 2017 20:57:02 +0000 (15:57 -0500)]
libubox: Change calloc_a() to return size_t aligned pointers
Un-aligned pointers were causing seg faults on some targets
Signed-off-by: Ted Hess <thess@kitschensync.net>
Felix Fietkau [Fri, 3 Feb 2017 15:52:17 +0000 (16:52 +0100)]
uloop: add uloop_cancelling function
Returns true if uloop_run is still running and uloop_cancelled is set
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Felix Fietkau [Fri, 20 Jan 2017 10:29:51 +0000 (11:29 +0100)]
utils: fix build on Mac OS X 10.12
clock_gettime and CLOCK_MONOTONIC are supported now
Signed-off-by: Felix Fietkau <nbd@nbd.name>
André Gaul [Sat, 19 Nov 2016 17:55:49 +0000 (18:55 +0100)]
blobmsg: add support for double
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>
Felix Fietkau [Wed, 14 Dec 2016 22:26:51 +0000 (23:26 +0100)]
utils: add helper functions useful for allocating a ring buffer
This creates a mapping with twice the size of the allocated memory. The
second half of that mapping points at the same memory as the first half.
This is useful for ring buffers, because any read starting in the first
half can overflow into the second half as long as the read size is
smaller than the size of the memory area.
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Rosen Penev [Thu, 22 Dec 2016 19:53:25 +0000 (11:53 -0800)]
libubox: replace strtok with _r version.
_r is re-entrant. Also happens to silence a cppcheck warning.
Signed-off by: Rosen Penev <rosenp@gmail.com>
Florian Eckert [Tue, 13 Dec 2016 11:34:31 +0000 (12:34 +0100)]
libubox: allow reading out the pid of uloop process in lua
Add Lua method to get the forked pid of a uloop process
Signed-off-by: Florian Eckert <Eckert.Florian@googlemail.com>
Felix Fietkau [Mon, 12 Dec 2016 11:24:13 +0000 (12:24 +0100)]
uloop: remove useless epoll data assignment
ev.data is a union, so setting ev.data.fd is lost after setting
ev.data.ptr
Reported-by: Song Yaofei <songyaofei@joyware.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Stijn Cleynhens [Mon, 5 Dec 2016 14:11:05 +0000 (15:11 +0100)]
libubox: allow reading out the remaining time of a uloop timer in Lua
Add Lua method to the uloop wrapper to allow reading out the remaining time of a uloop timer
Signed-off-by: Stijn Cleynhens <stijncleynhens@gmail.com>
Felix Fietkau [Tue, 29 Nov 2016 13:02:54 +0000 (14:02 +0100)]
blob/blobmsg: add explicit typecasts for attribute iterators
Fixes C++ compatibility.
Reported in https://forum.lede-project.org/t/blobmsg-for-each-attr-from-c/389
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Felix Fietkau [Mon, 24 Oct 2016 10:34:09 +0000 (12:34 +0200)]
kvlist: add static initializer macros
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Felix Fietkau [Fri, 29 Jul 2016 10:00:15 +0000 (12:00 +0200)]
libubox: add static initializer macro for runqueues
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Felix Fietkau [Fri, 29 Jul 2016 08:58:55 +0000 (10:58 +0200)]
avl: add blob comparator function
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Matthias Schiffer [Mon, 27 Jun 2016 06:50:29 +0000 (08:50 +0200)]
blobmsg_json: add new functions blobmsg_format_json_value*
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]
Eyal Birger [Mon, 20 Jun 2016 05:36:47 +0000 (08:36 +0300)]
uloop: handle waker pipe write() return value
Recent glibc warns if result of read() or write() is unused.
Added a retry in case of EINTR, all other faults are silently discarded.
Signed-off-by: Eyal Birger <eyal.birger@gmail.com>
-----
- I was not able to reproduce the EINTR case, but it seems to be the right
thing to do
- Retrying on EAGAIN in this case would be weird as there is no one to read
from the other end of the pipe. We could call waker_consume() directly but
since the size of the message is just one byte, I think this would be dead
code
Matthias Schiffer [Tue, 21 Jun 2016 15:19:11 +0000 (17:19 +0200)]
loop: make uloop_run() return the cancelling signal
When a process quits in response to a signal it handles, it should to so
be re-sending the signal to itself. This especially important for SIGINT,
as is explained in [1].
uloop currently hides the reason for quitting uloop_run(). Fix this by
returning the signal that caused the loop to quit (or 0 when uloop_end()
was used), so a program using loop an comply with [1].
[1] https://www.cons.org/cracauer/sigint.html
Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
Matthias Schiffer [Tue, 21 Jun 2016 15:19:10 +0000 (17:19 +0200)]
Fix various memory management issues
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>
Felix Fietkau [Wed, 15 Jun 2016 13:14:51 +0000 (15:14 +0200)]
uloop: add missing waker_pipe initialization
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Yousong Zhou [Thu, 9 Jun 2016 02:20:32 +0000 (10:20 +0800)]
uloop: use a waker for notifying sigchld and loop cancel events
Fix a race condition when do_sigchld, uloop_cancelled were set just
before epoll_wait(timeout=-1), resulting the loop stuck in the syscall
without noticing the events just happened
Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Felix Fietkau [Thu, 19 May 2016 08:59:46 +0000 (10:59 +0200)]
uloop: revert signalfd support for now
It hasn't fixed the reported race condition and it introduced some new
issues.
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Felix Fietkau [Tue, 17 May 2016 11:59:05 +0000 (13:59 +0200)]
uloop: add back support for overriding signal handlers when signalfd is in use
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Felix Fietkau [Tue, 17 May 2016 11:35:00 +0000 (13:35 +0200)]
uloop: fix signal unblocking
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Felix Fietkau [Tue, 17 May 2016 11:27:44 +0000 (13:27 +0200)]
uloop: retry waitpid on signal interrupt
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Felix Fietkau [Tue, 17 May 2016 11:23:28 +0000 (13:23 +0200)]
uloop: try to use signalfd for signal handling if available
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Felix Fietkau [Tue, 17 May 2016 10:25:19 +0000 (12:25 +0200)]
uloop: move epoll code into a separate file
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Felix Fietkau [Tue, 17 May 2016 10:24:04 +0000 (12:24 +0200)]
uloop: move kqueue code into a separate file
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Matthias Schiffer [Wed, 6 Apr 2016 15:40:22 +0000 (17:40 +0200)]
blobmsg_json: simplify add_separator and fix thread-safety
The hard-coded length limits are replaced with strlen to make the code more
robust.
Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
Felix Fietkau [Sat, 5 Mar 2016 17:51:31 +0000 (18:51 +0100)]
jshn: use an avl tree for env variables to speed up processing of bigger json files
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Yousong Zhou [Wed, 17 Feb 2016 07:45:06 +0000 (15:45 +0800)]
examples: add shunit2 tests for json_script
Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
Yousong Zhou [Wed, 17 Feb 2016 07:45:05 +0000 (15:45 +0800)]
json_script: add "isdir" support
Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
Jo-Philipp Wich [Tue, 9 Feb 2016 21:51:41 +0000 (22:51 +0100)]
blobmsg_json: support json_type_null in blobmsg_add_json_element()
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>
Felix Fietkau [Thu, 28 Jan 2016 10:56:46 +0000 (11:56 +0100)]
usock: implement usock_inet_timeout() with RFC6555 support
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Felix Fietkau [Fri, 15 Jan 2016 20:35:48 +0000 (21:35 +0100)]
ustream-fd: handle ENOTCONN for read/write on not-yet-connected sockets
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Felix Fietkau [Fri, 15 Jan 2016 20:25:48 +0000 (21:25 +0100)]
lua: add gc/delete support for processes
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Felix Fietkau [Fri, 15 Jan 2016 20:19:47 +0000 (21:19 +0100)]
lua: create a common function for userdata with gc
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Felix Fietkau [Fri, 15 Jan 2016 20:04:16 +0000 (21:04 +0100)]
usock: add usock_inet, which returns the remote address
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Karl Palsson [Thu, 24 Sep 2015 15:14:04 +0000 (15:14 +0000)]
libubox: lua: use pkg-config built in module to search for alternatives
Different distributions have different names for the lua 5.1 package.
Use cmake's built in pkg-config support to search for the first one,
rather than running it explicitly and searching for a single version.
Signed-off-by: Karl Palsson <karlp@remake.is>
Felix Fietkau [Sun, 8 Nov 2015 19:19:08 +0000 (20:19 +0100)]
json_script: allow non-string types in command arguments
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Felix Fietkau [Fri, 6 Nov 2015 21:58:15 +0000 (22:58 +0100)]
json_script: add support for aborting script processing
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Sergiy Kibrik [Tue, 18 Aug 2015 06:28:39 +0000 (09:28 +0300)]
ulog: avoid accidental /dev/kmsg creation
Race is possible in ulog_kmsg(): if no /dev/kmsg exists
(e.g. while /dev gets re-mounted) regular file created instead.
>From this point system goes without kernel logger:
special character file can't be created anymore, all clients keep
overwriting single message in regular file.
To avoid this we open file in "r+" mode which doesn't create
file if it's not found.
Signed-off-by: Sergiy Kibrik <sakib@meta.ua>
Cc: John Crispin <blogic@openwrt.org>
Bachtin, Dmitri [Wed, 9 Sep 2015 07:23:58 +0000 (09:23 +0200)]
b64_encode(): fixed input[] not initialized warn under gcc 4.4.5
Signed-off-by: Dmitri Bachtin <dbachtin@init-ka.de>
Bachtin, Dmitri [Wed, 9 Sep 2015 07:23:57 +0000 (09:23 +0200)]
Build static version of libblobmsg_json
Signed-off-by: Dmitri Bachtin <dbachtin@init-ka.de>
Philip Craig [Mon, 13 Jul 2015 02:12:28 +0000 (12:12 +1000)]
ustream-fd: handle uloop errors
The default uloop error handling is to delete the fd. Continue to do
that, but also set the write_error flag and notify the user.
Signed-off-by: Philip Craig <philipjcraig@gmail.com>
Felix Fietkau [Mon, 29 Jun 2015 14:13:08 +0000 (16:13 +0200)]
md5: include utils.h instead of endian.h to fix portability issues
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Steven Barth [Mon, 29 Jun 2015 14:01:04 +0000 (16:01 +0200)]
md5: include endian.h for musl, otherwise hashes are invalid for BE
Signed-off-by: Steven Barth <steven@midlink.org>
Yousong Zhou [Thu, 4 Jun 2015 13:41:38 +0000 (21:41 +0800)]
ulog: always use stderr for ulog_stdio().
stdout is for normal program output.
Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
Nikolay Dimitrov [Sat, 6 Jun 2015 15:04:19 +0000 (18:04 +0300)]
libubox: cmake: Add BUILD_EXAMPLES option
Add ability to skip building the examples. The default value is ON to follow
the original cmake behavior.
Signed-off-by: Nikolay Dimitrov <picmaster@mail.bg>
Yousong Zhou [Thu, 4 Jun 2015 13:41:42 +0000 (21:41 +0800)]
ustream-fd: stop trying to read when s->read_blocked is set.
User's s->notify_read is called in ustream_fill_read(). If
s->read_blocked is set there, then stop reading more.
Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
Yousong Zhou [Thu, 4 Jun 2015 13:41:41 +0000 (21:41 +0800)]
ustream-fd: readability change.
Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
Yousong Zhou [Thu, 4 Jun 2015 13:41:40 +0000 (21:41 +0800)]
ustream: tweak ustream_prepare_buf() a bit.
No functional change.
- Reuse existing NULL check on buf.
- Add some comments for ease of reading the code.
Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
Yegor Yefremov [Mon, 27 Apr 2015 20:13:42 +0000 (22:13 +0200)]
ubox: CMake: fix json-c detection
Use PKG_SEARCH_MODULE() to detect json-c library,
otherwise the search fails, if both json-c and json
are not present in pkg-config database.
Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
Felix Fietkau [Fri, 8 May 2015 12:28:51 +0000 (14:28 +0200)]
add a base64 implementation (based on FreeBSD code)
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
John Crispin [Sat, 21 Mar 2015 04:49:38 +0000 (05:49 +0100)]
allow process callback to call uloop_end()
Signed-off-by: John Crispin <blogic@openwrt.org>
Jo-Philipp Wich [Thu, 26 Feb 2015 12:35:50 +0000 (13:35 +0100)]
ulog: implement ulog_close()
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
Jo-Philipp Wich [Wed, 25 Feb 2015 19:42:03 +0000 (20:42 +0100)]
ulog: introduce new simple logging api
The ulog api is intended to be used by procd, fstools, ubox etc. to provide
a generic logging api for early boot messages and automatic switching between
syslog / kmsg / stdout depending on the way the process is executed.
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
Rafał Miłecki [Tue, 27 Jan 2015 07:19:31 +0000 (08:19 +0100)]
uloop: ignore SIGPIPE by default
Most app don't want to crash because of unhandled SIGPIPE. It could
happen is such trivial situations like writing to socket.
Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
Yousong Zhou [Wed, 21 Jan 2015 13:21:28 +0000 (21:21 +0800)]
utils: use clock_get_time() for clock_gettime() on Apple.
It turns out that mach_absolute_time() is not monotonic at all. While
at it, convert the CLOCK_REALTIME implementation to using
clock_get_time() as well.
Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
Yousong Zhou [Wed, 21 Jan 2015 13:21:27 +0000 (21:21 +0800)]
uloop: optimize uloop_timeout_set() implementaiton a bit.
Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
Yousong Zhou [Wed, 21 Jan 2015 13:21:26 +0000 (21:21 +0800)]
ustream-fd: fix logic invert of write polling.
ustream_write_pending() returns true if write buffer was flushed there.
Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
Yousong Zhou [Wed, 21 Jan 2015 13:21:25 +0000 (21:21 +0800)]
ustream: add function ustream_read().
It can be used to fill caller-specified buffer with data already in
ustream read buffer. Useful in the following use pattern.
int available = ustream_pending_data(s, false);
if (available >= sizeof(struct msghdr)) {
struct msghdr h;
ustream_read(s, &h, sizeof(h));
}
Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
Rafał Miłecki [Thu, 15 Jan 2015 11:42:52 +0000 (12:42 +0100)]
usock: set socket flags right after creating it
Otherwise some flags like USOCK_NONBLOCK wouldn't work as expected
(O_NONBLOCK affects connect behavior).
Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
Rafał Miłecki [Thu, 15 Jan 2015 11:59:18 +0000 (12:59 +0100)]
usock: add helper waiting for socket to be ready
Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
Yousong Zhou [Tue, 16 Dec 2014 21:15:37 +0000 (05:15 +0800)]
examples: add example code for json_script.
Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
Yousong Zhou [Tue, 16 Dec 2014 21:15:36 +0000 (05:15 +0800)]
json_script: fix logic invert of handle_expr_not().
Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
Yousong Zhou [Wed, 12 Nov 2014 13:59:23 +0000 (21:59 +0800)]
json_script: remove unneed argument check before calling __json_script_file_free().
NULL check is present at the begining of function body.
Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
Yousong Zhou [Wed, 12 Nov 2014 13:59:22 +0000 (21:59 +0800)]
json_script: fix eval_string().
- Fix handling of "%%".
- Fix length requirement when calling blobmsg_realloc_string_buffer().
Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
Yousong Zhou [Wed, 12 Nov 2014 13:59:20 +0000 (21:59 +0800)]
jshn: add error handling and fix memory leak in jshn_format().
Though currently jshn is more a one-shot data transformation tool and
won't leak much memory in its lifetime, people may use it as example
code, so do it right.
Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
Yousong Zhou [Wed, 12 Nov 2014 13:59:19 +0000 (21:59 +0800)]
blobmsg: remove unneeded assignment in blobmsg_alloc_string_buffer().
data_dest should already be assigned by blobmsg_new() if the return
value is not NULL.
Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
Yousong Zhou [Wed, 12 Nov 2014 13:59:16 +0000 (21:59 +0800)]
examples: fix build.
- runqueue-example.c: fix include path for in-tree build.
- blobmsg-example.c: add inttypes.h for using PRIu64.
- add examples/ subdirectory to main CMakeLists.txt
Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
Yousong Zhou [Wed, 12 Nov 2014 13:59:15 +0000 (21:59 +0800)]
lua: do not hardcode /opt/local/include for Apple.
Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
Yousong Zhou [Wed, 12 Nov 2014 13:59:14 +0000 (21:59 +0800)]
libubox: drop legacy json-c support
The cmake logic is wrong (E.G. PKG_CHECK_FOR_MODULES fails unless all
modules are found), and the legacy libjson.so name is also used by the other
libjson (http://sourceforge.net/projects/libjson/) which provides an
incompatible API, so just drop it.
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
Felix Fietkau [Sun, 23 Nov 2014 22:53:37 +0000 (23:53 +0100)]
Revert "jshn: only keep UP_* variables around while they are needed"
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Felix Fietkau [Sun, 23 Nov 2014 19:21:14 +0000 (20:21 +0100)]
jshn: shorten JSON_VAR to J_V
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Felix Fietkau [Sun, 23 Nov 2014 19:02:33 +0000 (20:02 +0100)]
jshn: shorten variable names to speed up processing
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Felix Fietkau [Sun, 23 Nov 2014 18:45:07 +0000 (19:45 +0100)]
jshn: remove TYPE_JSON_VAR
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Felix Fietkau [Sun, 23 Nov 2014 18:44:10 +0000 (19:44 +0100)]
jshn: do not export JSON_SEQ
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Felix Fietkau [Sun, 23 Nov 2014 18:43:56 +0000 (19:43 +0100)]
jshn: only keep UP_* variables around while they are needed
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Felix Fietkau [Sun, 23 Nov 2014 18:25:39 +0000 (19:25 +0100)]
jshn: improve performance by using let instead of $(( ))
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Felix Fietkau [Fri, 24 Oct 2014 11:40:10 +0000 (13:40 +0200)]
blobmsg_json: avoid redefinition of json_object
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Michel Stam [Mon, 13 Oct 2014 14:14:28 +0000 (16:14 +0200)]
uloop: Do not override signal handlers not installed by us
Signed-off-by: Michel Stam <m.stam@fugro.nl>
Michel Stam [Mon, 13 Oct 2014 14:14:27 +0000 (16:14 +0200)]
uloop: Remove uloop_cancelled variable, it is not used anywhere
Signed-off-by: Michel Stam <m.stam@fugro.nl>
Felix Fietkau [Wed, 1 Oct 2014 14:38:17 +0000 (16:38 +0200)]
md5: add a new implementation under permissive license
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Felix Fietkau [Tue, 23 Sep 2014 10:03:32 +0000 (12:03 +0200)]
blobmsg_json: include json.h inside blobmsg_json.c instead of the public header file
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Felix Fietkau [Tue, 23 Sep 2014 10:02:31 +0000 (12:02 +0200)]
avoid using the deprecated is_error() function from json-c
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Jo-Philipp Wich [Mon, 22 Sep 2014 16:15:58 +0000 (18:15 +0200)]
usock: add usock_port() for convenient use of numeric ports
Add a new helper function usock_port() which converts the given numeric port number
into a string using a private static buffer. This way a calling application can
conveniently use numeric port arguments without having to convert them before:
int fd = usock(USOCK_UDP, "example.org", usock_port(80));
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
John Crispin [Mon, 4 Aug 2014 17:26:18 +0000 (19:26 +0200)]
jshn: pretty print indented output with jshn -i -w
Signed-off-by: John Crispin <blogic@openwrt.org>
Felix Fietkau [Sun, 3 Aug 2014 13:00:54 +0000 (15:00 +0200)]
blobmsg: accept NULL attr in blobmsg_get_string()
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
xfguo@credosemi.com [Sun, 27 Jul 2014 09:21:35 +0000 (17:21 +0800)]
lua/uloop: 'end' is the keyword of Lua, use 'cancel' replace it.
Signed-off-by: Xiongfei Guo <xfguo@credosemi.com>
ewolfok [Tue, 8 Jul 2014 13:43:58 +0000 (21:43 +0800)]
blob: improve out-of-memory handling
Signed-off-by: Chen Bin <ewolfok@126.com>
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Felix Fietkau [Sun, 20 Jul 2014 23:24:01 +0000 (01:24 +0200)]
blobmsg: add a helper function to reset the name of a blobmsg attribute
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Jo-Philipp Wich [Tue, 15 Jul 2014 13:57:47 +0000 (15:57 +0200)]
jshn: do not collapse whitespace in json_load()
When running the test case below the $key variable holds "foo bar" instead
of the expected "foo bar".
-- 8< --
. /usr/share/libubox/jshn.sh
json_init
json_load '{ "key": "foo bar" }'
json_get_var key key
-- >8 --
Quote the output of the "jshn -r" backtick expression to prevent the shell
from erroneously collapsing whitespace.
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
Felix Fietkau [Tue, 15 Jul 2014 08:51:09 +0000 (10:51 +0200)]
blobmsg: add blobmsg_check_array, which returns the size of the array
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Felix Fietkau [Thu, 3 Jul 2014 11:50:49 +0000 (13:50 +0200)]
blobmsg-example: use blobmsg_get_string()
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Luka Perkov [Thu, 3 Jul 2014 11:46:24 +0000 (13:46 +0200)]
examples: fix build error
Patch fixes the following error:
error: format ‘%s’ expects argument of type ‘char *’, but argument 3 has type ‘void *’ [-Werror=format=]
indent_printf(indent, "%s\n", blobmsg_data(data));
Signed-off-by: Luka Perkov <luka@openwrt.org>
Felix Fietkau [Thu, 3 Jul 2014 10:56:40 +0000 (12:56 +0200)]
blobmsg_example: fix output
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Luka Perkov [Thu, 3 Jul 2014 10:28:24 +0000 (12:28 +0200)]
examples: use PRIu64 instead %lld when printing uint64_t values
Patch fixes build failure:
error: format ‘%lld’ expects argument of type ‘long long int’, but argument 3 has type ‘uint64_t’ [-Werror=format=]
indent_printf(indent, "%lld\n", *(uint64_t *)data);
Signed-off-by: Luka Perkov <luka@openwrt.org>
Luka Perkov [Thu, 3 Jul 2014 10:28:23 +0000 (12:28 +0200)]
examples: add missing include
Patch fixes following build error:
error: implicit declaration of function ‘close’ [-Werror=implicit-function-declaration]
close(cl->s.fd.fd);
Signed-off-by: Luka Perkov <luka@openwrt.org>
Luka Perkov [Thu, 3 Jul 2014 10:28:22 +0000 (12:28 +0200)]
examples: fix linking with json-c
Signed-off-by: Luka Perkov <luka@openwrt.org>
Luka Perkov [Thu, 3 Jul 2014 10:28:21 +0000 (12:28 +0200)]
examples: remove set but unused variable
Fixes build failure.
Signed-off-by: Luka Perkov <luka@openwrt.org>