Commit Graph
274 Commits
Author SHA1 Message Date
Thiago Macieira 587ff539ba Update Travis CI to Ubuntu Xenial
This updates to Qt 5.12, since Stephan has a build for that in his
PPA. But we need to turn off RDRNAD support for the Valgrind build, as
it doesn't understand that instruction.

This also downgrades GCC to 5.4, which is what comes by default with
Travis CI.

Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2019-03-05 15:13:00 -08:00
Pedro Oliveira d75f2ebf65 Fixed minor error in the example code.
Signed-off-by: pelco <pelco89@gmail.com>
2019-01-11 12:11:33 -08:00
phirsov 7b08a99b9e Make AppVeyor test suit run silent as in Travis
Signed-off-by: phirsov <41143811+phirsov@users.noreply.github.com>
2018-12-06 14:44:17 -08:00
phirsov 3c910cf144 Run check silently in Travis
Run unittest in Travis in the silent mode to avoid Travis log cluttering

Signed-off-by: phirsov <41143811+phirsov@users.noreply.github.com>
2018-12-06 12:24:22 -08:00
phirsov e9c6ebe9d6 eliminating misleading messages in case .config file not yet created
Signed-off-by: phirsov <41143811+phirsov@users.noreply.github.com>
2018-12-04 15:15:32 -08:00
Svyatoslav Phirsov 1db99f95f2 typo in dumprecursive return type
should be CborErrorr rather than bool
2018-10-23 10:47:40 -07:00
Svyatoslav Phirsov 2b267847ef Typo fixed in stdlib fread(...) usage
fread(...) function returns the number of items read so far, not number of bytes, ergo, reading one st.st_size sized item produces 1 on success and 0 on failure.
Possibly fixing issue #77

Signed-off-by: phirsov <41143811+phirsov@users.noreply.github.com>
2018-10-13 16:26:48 -07:00
phirsov 37d4ba453a Protect macro argument expansion using parentheses
Fixes #141

Signed-off-by: phirsov <41143811+phirsov@users.noreply.github.com>
2018-10-13 09:51:43 -07:00
phirsov 3f0a830fad Fix off-by-one causing buffer overflow in open_memstream
Fixes #140

Signed-off-by: phirsov <41143811+phirsov@users.noreply.github.com>
2018-10-13 09:51:43 -07:00
Fabrice Fontaine d072f461e9 fix undefined encode_half in json2cbor
encode_half has been moved from compilersupport_p.h to cborinternal_p.h
in commit bfc40dcf90 so include this file
in json2cbor to avoid the following build failure:

/home/buildroot/autobuild/run/instance-0/output/host/bin/microblazeel-linux-gcc -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -I./src -std=gnu99 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64  -Os    -c -o tools/json2cbor/json2cbor.o tools/json2cbor/json2cbor.c
tools/json2cbor/json2cbor.c: In function 'decode_json_with_metadata':
tools/json2cbor/json2cbor.c:295:50: warning: implicit declaration of function 'encode_half' [-Wimplicit-function-declaration]
                                          (half = encode_half(v), cbor_encode_half_float(encoder, &half));
                                                  ^~~~~~~~~~~
/home/buildroot/autobuild/run/instance-0/output/host/bin/microblazeel-linux-gcc -o bin/json2cbor  tools/json2cbor/json2cbor.o lib/libtinycbor.so -lcjson -lm
tools/json2cbor/json2cbor.o: In function `decode_json_with_metadata':
(.text+0xe54): undefined reference to `encode_half'
collect2: error: ld returned 1 exit status
Makefile:151: recipe for target 'bin/json2cbor' failed

Fixes:
 - http://autobuild.buildroot.net/results/afd8d24f2a4e501264abff618cf421d4bd088ebf

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
2018-09-21 09:43:08 -07:00
Thiago Macieira 2421690d44 Fix #137: off-by-one error in UTF-8 decoding
I ported this from code I had written for Qt, where the subtraction was
correct. Qt's code is roughly:

    uchar b = *src++;
    ...
    int bytesAvailable = Traits::availableBytes(src, end);
    if (Q_UNLIKELY(bytesAvailable < charsNeeded - 1)) {

Which means src was advanced by the time we call Traits::availableBytes,
meaning that call returns the number of continuation bytes only. Our
code was:

    ptrdiff_t n = end - *buffer;
    ...
    uc = *(*buffer)++;
    ...
    if (n < charsNeeded - 1)

Which means our n is the total number of bytes, including the first
byte.

Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2018-09-21 09:41:57 -07:00
Thiago Macieira 27d913e0d5 Update version number for a possible but unlikely 0.5.3 release
Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2018-09-09 09:24:40 -07:00
Thiago Macieira d94ca09aa9 Install the tinycbor-version.h header.
Fixes #136.

Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
v0.5.2
2018-09-08 22:33:57 -07:00
Thiago Macieira bfc40dcf90 Move the floating point code to cborinternal_p.h
... and put it behind #ifndef CBOR_NO_FLOATING_POINT.

The functions were not really compiler support, but are internal
functionality of TinyCBOR. This commit also puts both the <math.H> and
<float.h> headers behind an #if, so constrained systems without floating
point support won't enable it.

Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2018-08-13 21:03:31 -07:00
Thiago Macieira 88943666c4 Properly link the shared libtinycbor.so to -lm
The hosted version makes use of math functions (usually, we don't test
that CBOR_NO_FLOATING_POINT is defined).

Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2018-08-13 21:03:31 -07:00
Thiago Macieira 4d15639645 Don't compile bin/cbordump in freestanding builds
Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2018-08-13 21:03:31 -07:00
Thiago Macieira f29859da33 Update our Qt 5.9 installation to 5.9.6
Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2018-07-08 11:48:31 -07:00
Thiago Macieira cf222ff986 Make the c90 test pass on Mac and on Windows
On the Mac, the Clang compiler complains about our (required) use of
uint64_t, which is typedef'ed to long long. That type didn't exist in
C90.

On Windows, I forgot the CONFIG += console, resulting in

 error LNK2019: unresolved external symbol _WinMain@16 referenced in function "int __cdecl invoke_main(void)" (?invoke_main@@YAHXZ)

Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2018-07-08 11:48:31 -07:00
Thiago Macieira 5356c1de23 Oops, enable the test too..
Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2018-07-08 11:16:12 -07:00
Thiago Macieira 85e1c18f41 Add a set of tests to ensure that the cbor.h remains C90-compatible
Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2018-07-08 11:10:14 -07:00
Thiago Macieira d2603496b3 Fix *some* C89/C90 issues in the code
This fixes the issues in all the headers (even in the private headers),
but not all of them in the .c files. I only fixed those that didn't make
the code look much uglier or those for which GCC complains with
-std=c90. The compiler only warns about mixed mixed variable
declarations and code, unless you use -pedantic-errors.

Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2018-07-08 10:57:22 -07:00
Thiago Macieira 9e226103da Improve our detection of floating-point that are integers
Turns out that we were relying on undefined behaviour when doing

    (uint64_t)fabs(val) == fabs(val)

This problem was noted when running our test data on an AArch64 build.

Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2018-05-31 19:22:32 -05:00
Koen Zandberg 412e40fcb3 pretty: Add ifdefs for float support
Adds ifdefs around the float handling to return an CborErrorUnknownType
if compiled without floating point support

Signed-off-by: Koen Zandberg <koen@bergzand.net>
2018-05-28 13:35:28 -03:00
Koen Zandberg f1b3258276 validation: fix undef var with half float disabled
Signed-off-by: Koen Zandberg <koen@bergzand.net>
2018-05-28 13:33:15 -03:00
Thiago Macieira df564822b1 Add more byte order detection code
Suggested in https://sourceforge.net/p/predef/wiki/Endianness/ and also
found by looking into glibc's <endian.h>. Plus some recommendation from
other people.

This fixed the build on INTEGRITY.

Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2018-05-27 23:02:33 -03:00
Koen Zandberg fac1e5761e validation: Fix tag array for 8 bit architectures
Compilation for 8 bit architectures fails due to a bit shift larger than
8 for a uint8_t data type. This commit changes the data type to uint32_t
for the tag array.

Signed-off-by: Koen Zandberg <koen@bergzand.net>
2018-05-25 11:44:07 -03:00
Koen Zandberg 81fbe2ee1c Change flag type to uint32_t for parser flags
The argument for the parser flags should have uint32_t as type to
prevent overflow on platforms where an int is not 32 bit wide.
2018-05-24 13:53:26 -03:00
Koen Zandberg 66f0e785fd validation: Fix brace mismatch with float disabled 2018-05-24 13:48:21 -03:00
Thiago Macieira 222845369c Attempt at detecting a few more endiannesses
On INTEGRITY, the __BYTE_ORDER__ macro isn't defined. So fall back to
the processor macros.

Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2018-05-09 08:45:44 -07:00
Thiago Macieira c9059d9e33 Print the diff of the library sizes in Travis
So we can tell from the output if the library is increasing or not.

This also fixes a silly bug in testing non-tags, introduced by
0170ebdcdc.

Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2018-03-31 10:50:24 -07:00
Thiago Macieira 3642f49d62 Update versions for TinyCBOR 0.5.2
Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2018-03-31 10:03:28 -07:00
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