Commit Graph
243 Commits
Author SHA1 Message Date
Thiago Macieira ae64a3d9da Use 32-bit x86 for MSVC 2015, for completeness
We had no 32-bit build.

Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
v0.5.1
2018-03-31 09:46:39 -07:00
Thiago Macieira 73d0a9ce77 Fix json2cbor (cJSON) build
Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2018-03-31 09:40:28 -07:00
Konstantin Yegupov 8606611e53 Update gcc flags to build json2cbor with gcc 4.4.7 (used in CentOS 6)
Signed-off-by: Konstantin Yegupov <kyegupov4@gmail.com>
2018-03-31 09:39:10 -07:00
Andreas Zisowsky 70aba6ba51 Fix compile error on Windows x86.
Visual Studio expects the __fastcall attribute
between return type and function name.

Signed-off-by: Andreas Zisowsky <zisowsky@lynxtechnology.com>
2018-03-19 08:17:53 -07:00
Mårten Nordheim c1ae521511 Fix typo in documentation
Signed-off-by: Mårten Nordheim <Morten242@gmail.com>
2018-02-07 10:43:40 -08:00
Thiago Macieira c11324ec91 Disable timestamping in Doxygen
So the output is reproducible.

Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2018-02-07 10:40:52 -08:00
Thiago Macieira d8f8e8c57b Docs: Simplify the Doxyfile
Following Edward Welbourne's recommendation, first we remove the comments:
  $ doxygen -s -u

Then we compare to the stock Doxyfile without comments (doxygen -s -g)
and save only what's to our file:
  $ doxygen -s -g - | comm -13 Doxyfile > Doxyfile.new
  $ mv Doxyfile.new Doxyfile

Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2018-02-07 10:40:52 -08:00
Thiago Macieira f5a172b976 Docs and comments updates
Many thanks to Edward Welbourne for pointing them all out.

Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2018-02-05 18:02:52 -08:00
Thiago Macieira cd4430ece7 json2cbor: Minor update for clarity
Avoids a magic constant in the code.

Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2018-02-05 18:02:52 -08:00
Thiago Macieira 7a09e63fa0 json2cbor: don't crash if realloc() returns false
perror() doesn't exist. It's not like Perl's die().

Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2018-02-05 15:07:12 -08:00
Thiago Macieira 17aec2aa68 CborToJson: fix memory leak in case fprintf fails
Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2018-02-05 15:06:47 -08:00
Thiago Macieira 1f84b8361a Tests: fix the checking if the current test failed
The `compareFailed` variable was never initialised or set to anything.

Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2018-02-05 15:06:30 -08:00
Thiago Macieira 8c940d264a Pretty: fix typo in enum name
Will keep the misspelt name for a few releases and remove later.

Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2018-02-04 15:50:07 -08:00
Thiago Macieira 94a4edbbc7 Fix minor typo
Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2018-02-04 08:59:11 -08:00
Thiago Macieira 0170ebdcdc Fix the docs script when operating with a tag, in Travis
Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2018-01-30 15:01:23 -08:00
Thiago Macieira 803c048a8a Update version numbers for 0.5.1 release
Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2018-01-30 14:21:35 -08:00
Thiago Macieira 3cdb9c890b Add a script to make docs in Travis
This also stores the current library sizes (in -Os / -Oz build modes)
for each branch,

Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
v0.5.0
2018-01-30 14:21:35 -08:00
Thiago Macieira 301e263afb Update the ELF soname not to say "libtinycbor.so.0"
Since we're not (yet) guaranteeing binary compatibility, let's use 0.5
as the "soversion".

This changes the version number stored in the VERSION file so that the
actual library file is "libtinycbor.so.0.5.0". As an indirect
consequence, the release will be tagged "v0.5.0", which sorts after
"v0.5-beta1".

Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2018-01-30 14:01:23 -08:00
Thiago Macieira f2b75b8721 Make it easier to build only the freestanding code
Freestanding C, as opposed to hosted C (see the macro), is restricted to
a few C headers and usually lacks a libc. In our case, that means we
cannot assume <stdio.h> and FILE* is present, but we do require
<string.h> (memcpy, memcmp).

This commit simply makes it easier for me to test that TinyCBOR still
compiles in freestanding mode. Eventually I need to test with an actual
Zephyr build (issue #40).

Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2018-01-30 13:43:49 -08:00
Thiago Macieira 5515a99434 Parser: remove the cbor_value_get_xxxx_string_chunk() API
It's really good, but I need to redesign it in order to support the
chained buffers found in Zephyr[1][2] and Mynewt. I'll bring it back in
0.6 when I introduce support for parsing directly from chained buffers
too.

[1] http://docs.zephyrproject.org/api/networking.html#network-buffers
[2] https://github.com/zephyrproject-rtos/zephyr/blob/master/include/net/buf.h

Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2018-01-30 12:04:05 -08:00
Thiago Macieira 2a38a95ca5 Parser: merge the break-handling code in enter_container()
There was a section of code that was mostly the same, dealing with the
possibility of reading a Break (0xFF) as the next element in a map or
array. The only difference was that preparse_next_value() also
decremented the item count for the current list.

We could have used that, but that would have meant a +1 on the list,
which in turn lowers the number of possible elements from UINT32_MAX-1
to UINT32_MAX-2. Not a big deal, but we can avoid it by just splitting
to a new function and retaining tail-call optimisations.

Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2018-01-30 10:38:04 -08:00
Thiago Macieira 497066ee87 Encoder: Fix off-by-one error encoding negative numbers
The documentation said we encoded the negative value equivalent to the
passed absolute value. That means encode_number() requires the
subtraction.

This commit takes the opportunity to unit-test the rest of the integer
API in the parser.

Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
v0.5-beta1
2018-01-23 10:36:41 -08:00
Thiago Macieira 1b9a6401ea JSON: Change the first number of the JSON conversion errors
This gives us a little more room to add validation errors when we have
to keep binary compatibility.

Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2018-01-23 10:36:25 -08:00
Thiago Macieira e5843df411 Tests: change a few more QCOMPARE to print the error message.
Commit 36bdbfb854 did not catch all cases.

Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2018-01-13 08:41:07 -08:00
Thiago Macieira f8514e3d0e Test Clang and release GCC builds in Travis
Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2018-01-13 08:41:07 -08:00
Thiago Macieira cc2bfbb209 Encoder: Change the way we reckon the number of items added
Instead of counting forward the number of items added, which meant we
couldn't know in cbot_encoder_close_container() whether we had added
enough, let's count backwards. The number is offset by 1 so we should be
at 1 if we added exactly as many items as we had expected to. Zero means
we added too many. Any other number means we added too few.

Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2018-01-13 14:37:40 -02:00
Thiago Macieira d3c47d2296 Valiation: suppress warning about uninitialized variables
GCC7 complains, though it's wrong:

 src/cborvalidation.c:472:57: error: ‘previous’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
 src/cborvalidation.c:485:61: error: ‘previous_end’ may be used uninitialized in this function [-Werror=maybe-uninitialized]

Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2018-01-13 14:36:35 -02:00
Thiago Macieira f39dcb8b56 Pretty: move the two functions taking FILE* to a separate file
This now allows the cborpretty.c source to be compiled even in C
freestanding environments.

Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2018-01-02 17:05:44 -06:00
Thiago Macieira ee63f791be Pretty: add the ability to stream out to a generic thing
Instead of always requiring FILE *. This does mean a slight code size
increase, since we now have to pass an extra parameter down the function
stack, plus we're making indirect calls, but it's worth it.

Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2018-01-02 17:05:44 -06:00
Thiago Macieira 36bdbfb854 Tests: print the error message insead of just a number (or nothing)
Some QCOMPARE did convert to int() so we would see an error number, but
not all comparisons did. For those those that didn't, QCOMPARE would
just print that the values differed, but not show what.

So try to harmonize on printing the error message.

I may not have caught all uses...

Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2017-12-26 19:05:32 -06:00
Thiago Macieira 345ffce82a Add support for more half-float values
Since Qt 5.9 has qfloat16, it became easier to write values. There was
no point with just the stand-in type, since the encoder would write
exactly the bytes we gave it.

Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2017-12-26 19:01:58 -06:00
Thiago Macieira b087939748 Parser: set *len = 0 in the last string chunk
Probably a good idea anyway, plus solves a false positive warning:

 src/compilersupport_p.h:192:34: error: ‘chunkLen’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
     return __builtin_add_overflow(v1, v2, r);
            ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~
 src/cborparser.c:1163:16: note: ‘chunkLen’ was declared here
         size_t chunkLen = chunkLen;
                ^~~~~~~~

Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2017-12-26 19:01:29 -06:00
Thiago Macieira c3c7bf63ed Only #include <assert.h> if assert isn't yet defined
The C standard requires every the macro to be redefined every time that
<assert.h> is included. It does so you can change NDEBUG from one

But that also means a wrapper couldn't #define assert to their own
macro. So stop overriding.

Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2017-12-26 14:28:39 -06:00
Thiago Macieira e5662358cb Brown paper bag: forgot to change the PATH to Qt
Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2017-12-26 18:24:11 -02:00
Thiago Macieira 09e4f8e436 Update Qt to 5.9 on Travis/Linux testing
The Windows builds on Appveyor use 5.9; the macOS builds on Travis use
the latest from Homebrew, which is currently 5.10.

Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2017-12-26 18:10:29 -02:00
Thiago Macieira afa273cffe Add #include guards to the utf8_p.h internal header
Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2017-12-22 09:55:14 -08:00
Thiago Macieira c4fa09e196 Validation: make sure that it compiles in C++ mode too
Like the rest of our parser and encoder, it's useful to be #include'd in
C++ souces.

Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2017-12-21 14:01:32 -08:00
Thiago Macieira d1f9416db4 Pretty: limit the number of recursions, like the Parser
The pretty-dumper code did not have a limit, assuming that the input had
been validated beforehand, so if the nesting was too deep, one would
have got an error before getting to the dumper.

However, it's not inconceivable that someone adds a logger code to a
packet a bit too early. So let's be defensive and apply the limiter here
too.

Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2017-12-21 13:04:48 -08:00
Thiago Macieira 5433fc38ef Encoder: Fix the returning of OOM errors in closing containers
Conditional added by 3369dd1f01 was
inverted.

Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2017-12-19 11:09:37 -08:00
Thiago Macieira 4df836436c Invert the way we account for the recursion level
This allows advance_recursive to be called with different levels when
called directly.

Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2017-12-18 10:40:18 -08:00
Thiago Macieira ed68cdae5f Merge remote-tracking branch 'origin/dev' into HEAD 2017-12-17 23:48:22 -08:00
Thiago Macieira 78905c85da Add the -f flag to ln, to force symlink creation
Otherwise, remaking ends with:

 ln: failed to create symbolic link 'libtinycbor.so': File exists
 ln: failed to create symbolic link 'libtinycbor.so.0': File exists

Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2017-12-17 23:46:54 -08:00
Thiago Macieira 8dcde96b65 Fix warning about implicitly casting a double to float
Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2017-12-17 23:45:27 -08:00
Vipul Rahane 650c31f3be Fix compiler warnings for tst_cpp
- The defines(_BSD_SOURCE, _DEFAULT_SOURCE) were getting defined in multiple source files generating
  warnings
- Solution is to conditionally define the above
2017-12-16 20:39:48 -08:00
Fabrice Fontaine 19b26bd416 Add BUILD_STATIC option
- Enable BUILD_STATIC by default
 - If BUILD_STATIC and BUILD_SHARED are both different from 1, return an
error
 - If BUILD_STATIC is disabled, use shared library for binaries
 - If both are enabled, use the static library

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
2017-12-07 13:20:48 -08:00
Erich Keane a2dab2c9b2 Update documentation link in README 2017-12-06 18:25:51 -08:00
Thiago Macieira df440a0891 Make sure that -fPIC objects are removed in make clean
Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2017-11-13 22:28:07 -08:00
Thiago Macieira aa692b7863 Fix build on non-ELF systems (macOS): don't build the shared library
Detect if this is an ELF system by checking if /bin/sh is ELF. This can
be configured manually with:
   make BUILD_SHARED=0
or
   make BUILD_SHARED=1

Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2017-11-13 20:54:30 -08:00
Thiago Macieira 110d6bc02c Fix Travis builds on macOS
Travis and Homebrew have been at odds: the Ruby in PATH is not what
Homebrew wants, so it prints:

 /usr/local/Homebrew/Library/Homebrew/brew.rb:12:in `<main>': Homebrew must be run under Ruby 2.3! You're running 2.0.0. (RuntimeError)

Info in the Travis's own GitHub bug report indicates "brew update" fixes
this issue, even though it increases the build time.

Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2017-11-13 20:30:43 -08:00
Thiago Macieira 5a9dae7420 Merge tag 'v0.4.2' into dev
TinyCBOR release 0.4.2

This is a bugfix release. Important bugs fixed in this release:
 - Fixed builds against a static cJSON
 - Fixed MSVC builds
 - Fixed builds on freestanding C implementation (no FILE* API)
 - Fixed the return value of cbor_encoder_close_container when a previous OOM
   condition had been detected
 - Fixed the build in strict C89 mode (no C99 extensions)

Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2017-11-13 19:25:56 -08:00