summaryrefslogtreecommitdiff
path: root/lib/json.c
Commit message (Collapse)AuthorAgeFilesLines
* Move lib/dynamic-string.h to include/openvswitch directoryBen Warren2016-03-191-1/+1
| | | | | Signed-off-by: Ben Warren <ben@skyportsystems.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* Merge "master" into "ovn".Ben Pfaff2015-06-131-0/+1
|\ | | | | | | | | | | | | | | | | This allows OVN to take advantage of the client scalability changes that have been committed to ovsdb-server on master recently. Conflicts: Makefile.am lib/learn.c
| * json: Fix error message for corner case in json_string_unescape().Ben Pfaff2015-05-291-1/+2
| | | | | | | | | | | | | | | | | | | | The error message should not include bytes already copied from the input string. Found by inspection. Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Alex Wang <alexw@nicira.com>
* | json: New function json_string_escape().Ben Pfaff2015-04-201-1/+11
|/ | | | | | | | This saves some cut-and-paste duplicated code elsewhere and will have additional users in upcoming commits. Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Russell Bryant <rbryant@redhat.com>
* lib: Move compiler.h to <openvswitch/compiler.h>Thomas Graf2014-12-151-1/+1
| | | | | | | | | | The following macros are renamed to avoid conflicts with other headers: * WARN_UNUSED_RESULT to OVS_WARN_UNUSED_RESULT * PRINTF_FORMAT to OVS_PRINTF_FORMAT * NO_RETURN to OVS_NO_RETURN Signed-off-by: Thomas Graf <tgraf@noironetworks.com> Acked-by: Ben Pfaff <blp@nicira.com>
* util: Make hexits_value() support 64-bit integers too.Ben Pfaff2014-10-081-2/+3
| | | | | Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
* json: Fix leaked nodes in json_hash_object()Thomas Graf2014-08-261-0/+1
| | | | | | | nodes is allocated through shash_sort() but never freed. Signed-off-by: Thomas Graf <tgraf@noironetworks.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
* json: Fix parsing of strings that end with a backslash.Ben Pfaff2014-06-251-5/+9
| | | | | | | | | | json_string_unescape() flagged a backslash at the end of a string as an error, but of course "\\" is a valid string. This fixes the problem. VMware-BZ: #1275208 Reported-by: Michael Hu <mhu@nicira.com> Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Alex Wang <alexw@nicira.com>
* Revert "json: New function json_serialized_length()."Ben Pfaff2014-04-031-114/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 1600fa6853872e16130366351a2c14f6fa8b547c. Connections that queue up too much data, because they are monitoring a table that is changing quickly and failing to keep up with the updates, cause problems with buffer management. Since commit 60533a405b2e (jsonrpc-server: Disconnect connections that queue too much data.), ovsdb-server has dealt with them by disconnecting the connection and letting them start up again with a fresh copy of the database. However, this is not ideal because of situations where disconnection happens repeatedly. For example: - A manager toggles a column back and forth between two or more values quickly (in which case the data transmitted over the monitoring connections always increases quickly, without bound). - A manager repeatedly extends the contents of some column in some row (in which case the data transmitted over the monitoring connection grows with O(n**2) in the length of the string). A better way to deal with this problem is to combine updates when they are sent to the monitoring connection, if that connection is not keeping up. In both the above cases, this reduces the data that must be sent to a manageable amount. An upcoming patch implements this new way. This commit reverts part of the previous solution that disconnects backlogged connections, since it is no longer useful. Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Andy Zhou <azhou@nicira.com>
* Rename NOT_REACHED to OVS_NOT_REACHEDHarold Lim2013-12-171-8/+8
| | | | | | | | This allows other libraries to use util.h that has already defined NOT_REACHED. Signed-off-by: Harold Lim <haroldl@vmware.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
* Replace all uses of strerror() by ovs_strerror(), for thread safety.Ben Pfaff2013-06-281-2/+3
| | | | Signed-off-by: Ben Pfaff <blp@nicira.com>
* some ctype related casts to suppress gcc warnings on NetBSDYAMAMOTO Takashi2013-04-221-7/+7
| | | | | | | | where it can't be EOF, cast a value to unsigned char before passing it to ctype functions to avoid unintended sign extension. Signed-off-by: YAMAMOTO Takashi <yamt@mwd.biglobe.ne.jp> Signed-off-by: Ben Pfaff <blp@nicira.com>
* json: New function json_serialized_length().Ben Pfaff2013-04-011-1/+114
| | | | | | This will be used for the first time in an upcoming commit. Signed-off-by: Ben Pfaff <blp@nicira.com>
* Replace most uses of assert by ovs_assert.Ben Pfaff2013-01-161-9/+8
| | | | | | | | This is a straight search-and-replace, except that I also removed #include <assert.h> from each file where there were no assert calls left. Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Ethan Jackson <ethan@nicira.com>
* util: New macro CONST_CAST.Ben Pfaff2012-08-031-3/+3
| | | | | | | | | | | | | | Casts are sometimes necessary. One common reason that they are necessary is for discarding a "const" qualifier. However, this can impede maintenance: if the type of the expression being cast changes, then the presence of the cast can hide a necessary change in the code that does the cast. Using CONST_CAST, instead of a bare cast, makes these changes visible. Inspired by my own work elsewhere: http://git.savannah.gnu.org/cgit/pspp.git/tree/src/libpspp/cast.h#n80 Signed-off-by: Ben Pfaff <blp@nicira.com>
* Global replace of Nicira Networks.Raju Subramanian2012-05-021-1/+1
| | | | | | | | Replaced all instances of Nicira Networks(, Inc) to Nicira, Inc. Feature #10593 Signed-off-by: Raju Subramanian <rsubramanian@nicira.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
* json: Correct position tracking in JSON parser implementations.Ben Pfaff2012-04-261-8/+7
| | | | | | | | | | | When json_lex_input() returns false, the parser does not consume the byte passed in. That byte will get processed again in the next iteration of the json_parser_feed() loop. Therefore, until now, this code has double-counted bytes that cause a false return from json_lex_input(). This fixes the problem. Every input byte is now counted only once. Signed-off-by: Ben Pfaff <blp@nicira.com>
* Remove unnecessary #include directives.Ben Pfaff2011-05-161-2/+1
|
* util: Add function hexits_value() for parsing multiple hex digits.Ben Pfaff2010-11-151-8/+4
| | | | Suggested-by: Justin Pettit <jpettit@nicira.com>
* Avoid shadowing local variable names.Ben Pfaff2010-09-201-1/+0
| | | | | | | | | | | All of these changes avoid using the same name for two local variables within a same function. None of them are actual bugs as far as I can tell, but any of them could be confusing to the casual reader. The one in lib/ovsdb-idl.c is particularly brilliant: inner and outer loops both using (different) variables named 'i'. Found with GCC -Wshadow.
* json: Remove unused return value from json_parser_push().Ben Pfaff2010-08-251-3/+1
| | | | No point in returning a value that no caller uses.
* json: Remove write-only variable from json_lex_number().Ben Pfaff2010-08-251-6/+0
|
* json: Better handle JSON objects with duplicate names.Ben Pfaff2010-06-301-1/+1
| | | | | | | | | | | | | RFC 4627 (which defines JSON) says: The names within an object SHOULD be unique. In my view, this means that the treatment of duplicate names within a JSON object is more or less up to the implementation. Until now, the OVS JSON parser has dealt with duplicates fairly badly: they all get shoved into the hash table and you get one or the other value semi-randomly (typically the one added later). This commit makes the behavior predictable: old values are deleted and replaced by newer values.
* json: Fix typo in error message.Ben Pfaff2010-03-031-1/+1
|
* json: Fix memory leak when nesting depth is exceeded.Ben Pfaff2010-02-021-0/+1
| | | | | | | This is probably not an important memory leak, since it is only on a rare error path, but it is best to fix it anyway. Found with valgrind.
* json: New function json_to_ds().Ben Pfaff2010-01-261-30/+41
| | | | | | | | | | | Some upcoming code wants to serialize JSON into a "struct ds" dynamic string buffer, so expose an interface to do this. This commit doesn't change much, but it renames some functions internal to json.c to make the naming more consistent. Also, make jsonrpc_log_msg() use this new function, since it is a more straightforward way to do what it wants.
* json: Export function to parse an individual JSON string.Ben Pfaff2010-01-261-49/+88
| | | | | | | | | The JSON syntax for strings is very reasonable. An upcoming commit will have a need for a string parser, so make the JSON string parser available for that. Also, this change improves the error message for strings that end in the middle of a \u sequence, so update the tests to match.
* test-json: Avoid use of /dev/stdin to fix builds in limited chroots.Ben Pfaff2009-12-171-6/+20
| | | | | | The chroots in which we often build Open vSwitch don't have /proc and thus cannot support /dev/stdin, because on Linux that is a symlink to /proc/self/fd/0. So avoid using /dev/stdin in the testsuite.
* json: Accurately parse very large real numbers.Ben Pfaff2009-12-161-13/+10
| | | | | | The test for whether a real number was outside the valid range was imprecise and failed at the edge of the real range. This commit changes the code to use the C library's strtod(), which presumably does better.
* json: New convenience function json_array_create_1().Ben Pfaff2009-12-071-0/+8
|
* json: Improve error reporting.Ben Pfaff2009-12-031-2/+19
|
* json: Make json_equal() compare objects correctly.Ben Pfaff2009-11-061-3/+4
| | | | | | The previous code checked only that JSON objects have members with the same names. This commit makes json_equal() also check that like-named members have the same values.
* Implement JSON parsing and serialization.Ben Pfaff2009-11-041-0/+1569
This will be used by the upcoming Open vSwitch configuration database.