Get rid of extra spaces, minor documentation improvements, readme additions
diff --git a/Makefile b/Makefile
index cba2c40..f88db0a 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
# Copyright (c) 2018, Laurence Lundblade.
# All rights reserved.
-#
+#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
@@ -13,7 +13,7 @@
# * The name "Laurence Lundblade" may not be used to
# endorse or promote products derived from this software without
# specific prior written permission.
-#
+#
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
@@ -24,14 +24,14 @@
# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
-# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
CFLAGS=-I inc -I test -Os -Wall -Werror -pedantic-errors -Wextra -Wshadow -Wparentheses -xc -std=c99
-QCBOR_OBJ=src/UsefulBuf.o src/qcbor_encode.o src/qcbor_decode.o src/ieee754.o
+QCBOR_OBJ=src/UsefulBuf.o src/qcbor_encode.o src/qcbor_decode.o src/ieee754.o
TEST_OBJ=test/UsefulBuf_Tests.o test/qcbor_encode_tests.o test/qcbor_decode_tests.o test/run_tests.o \
- test/float_tests.o test/half_to_double_from_rfc7049.o
+ test/float_tests.o test/half_to_double_from_rfc7049.o
qcbortest: libqcbor.a $(TEST_OBJ) cmd_line_main.o
cc -o $@ $^ libqcbor.a
@@ -45,10 +45,10 @@
src/UsefulBuf.o: inc/UsefulBuf.h
src/qcbor_decode.o: inc/UsefulBuf.h inc/qcbor.h src/ieee754.h
src/qcbor_encode.o: inc/UsefulBuf.h inc/qcbor.h src/ieee754.h
-src/iee754.o: src/ieee754.h
+src/iee754.o: src/ieee754.h
test/run_tests.o: test/UsefulBuf_Tests.h test/float_tests.h test/run_tests.h test/qcbor_encode_tests.h\
- test/qcbor_decode_tests.h
+ test/qcbor_decode_tests.h
test/UsefulBuf_Tests.o: test/UsefulBuf_Tests.h inc/qcbor.h inc/UsefulBuf.h
test/qcbor_encode_tests.o: test/qcbor_encode_tests.h inc/qcbor.h inc/UsefulBuf.h
test/qcbor_decode_tests.o: test/qcbor_decode_tests.h inc/qcbor.h inc/UsefulBuf.h
diff --git a/Makefile.gcc8 b/Makefile.gcc8
index 799ff3b..ef72372 100644
--- a/Makefile.gcc8
+++ b/Makefile.gcc8
@@ -1,6 +1,6 @@
# Copyright (c) 2018, Laurence Lundblade.
# All rights reserved.
-#
+#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
@@ -13,7 +13,7 @@
# * The name "Laurence Lundblade" may not be used to
# endorse or promote products derived from this software without
# specific prior written permission.
-#
+#
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
@@ -24,15 +24,15 @@
# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
-# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
CFLAGS=-I inc -I test -Os -Wall -Werror -pedantic-errors -Wextra -Wshadow -Wparentheses -xc -std=c99 -Werror=maybe-uninitialized
CC=/usr/local/bin/gcc-8
-QCBOR_OBJ=src/UsefulBuf.o src/qcbor_encode.o src/qcbor_decode.o src/ieee754.o
+QCBOR_OBJ=src/UsefulBuf.o src/qcbor_encode.o src/qcbor_decode.o src/ieee754.o
TEST_OBJ=test/UsefulBuf_Tests.o test/qcbor_encode_tests.o test/qcbor_decode_tests.o test/run_tests.o \
- test/float_tests.o test/half_to_double_from_rfc7049.o
+ test/float_tests.o test/half_to_double_from_rfc7049.o
qcbortest: libqcbor.a $(TEST_OBJ) cmd_line_main.o
$(CC) -o $@ $^ libqcbor.a
@@ -46,10 +46,10 @@
src/UsefulBuf.o: inc/UsefulBuf.h
src/qcbor_decode.o: inc/UsefulBuf.h inc/qcbor.h src/ieee754.h
src/qcbor_encode.o: inc/UsefulBuf.h inc/qcbor.h src/ieee754.h
-src/iee754.o: src/ieee754.h
+src/iee754.o: src/ieee754.h
test/run_tests.o: test/UsefulBuf_Tests.h test/float_tests.h test/run_tests.h test/qcbor_encode_tests.h\
- test/qcbor_decode_tests.h
+ test/qcbor_decode_tests.h
test/UsefulBuf_Tests.o: test/UsefulBuf_Tests.h inc/qcbor.h inc/UsefulBuf.h
test/qcbor_encode_tests.o: test/qcbor_encode_tests.h inc/qcbor.h inc/UsefulBuf.h
test/qcbor_decode_tests.o: test/qcbor_decode_tests.h inc/qcbor.h inc/UsefulBuf.h
diff --git a/README.md b/README.md
index 325d9a3..bb49970 100644
--- a/README.md
+++ b/README.md
@@ -23,7 +23,7 @@
**Supports nearly all of RFC 7049** – Only minor, corner-case parts of
RFC 7049 are not directly supported (canonicalization, decimal
- fractions, big floats). Decoding indefinite length strings is supported,
+ fractions, big floats). Decoding indefinite length strings is supported,
but requires a string allocator (see documentation). Encoding indefinite
length strings is not supported, but is also not necessary or
preferred.
@@ -119,3 +119,53 @@
the interface simpler and saving some code
* QCBOREncode_AddRawSimple_2 is removed (the macros that referenced
still exist and work the same)
+
+## Credits
+* Ganesh Kanike for porting to QSEE
+* Mark Bapst for sponsorship and release as open source by Qualcomm
+* Sachin Sharma for release through CAF
+* Tamas Ban for porting to TF-M and 32-bit ARM
+
+## Copyright and License
+
+QCBOR is available under what is essentially the 3-Clause BSD License.
+
+Files created inside Qualcomm and open-sourced through CAF (The Code
+Aurora Forum) have a slightly modified 3-Clause BSD License. The
+modification additional disclaims NON-INFRINGEMENT.
+
+Files created after release to CAF use the standard 3-Clause BSD
+License with no modification. These files have the SPDX license
+identifier, "SPDX-License-Identifier: BSD-3-Clause" in them.
+
+### BSD-3-Clause license
+
+* Redistributions of source code must retain the above copyright
+notice, this list of conditions and the following disclaimer.
+
+* Redistributions in binary form must reproduce the above copyright
+notice, this list of conditions and the following disclaimer in the
+documentation and/or other materials provided with the distribution.
+
+* Neither the name of the copyright holder nor the names of its
+contributors may be used to endorse or promote products derived from
+this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+### Copyright for this README
+
+Copyright (c) 2018-2019, Laurence Lundblade. All rights reserved.
+
+
+
diff --git a/src/qcbor_decode.c b/src/qcbor_decode.c
index abd03e3..2286038 100644
--- a/src/qcbor_decode.c
+++ b/src/qcbor_decode.c
@@ -360,14 +360,14 @@
uint8_t *puAdditionalInfo)
{
QCBORError nReturn;
-
+
// Get the initial byte that every CBOR data item has
const uint8_t uInitialByte = UsefulInputBuf_GetByte(pUInBuf);
-
+
// Break down the initial byte
const uint8_t uTmpMajorType = uInitialByte >> 5;
const uint8_t uAdditionalInfo = uInitialByte & 0x1f;
-
+
// Where the number or argument accumulates
uint64_t uArgument;
@@ -391,18 +391,18 @@
// No more bytes to get
uArgument = uAdditionalInfo;
}
-
+
if(UsefulInputBuf_GetError(pUInBuf)) {
nReturn = QCBOR_ERR_HIT_END;
goto Done;
}
-
+
// All successful if we got here.
nReturn = QCBOR_SUCCESS;
*pnMajorType = uTmpMajorType;
*puArgument = uArgument;
*puAdditionalInfo = uAdditionalInfo;
-
+
Done:
return nReturn;
}
diff --git a/test/UsefulBuf_Tests.c b/test/UsefulBuf_Tests.c
index 2b9a28e..cfa1262 100644
--- a/test/UsefulBuf_Tests.c
+++ b/test/UsefulBuf_Tests.c
@@ -403,11 +403,11 @@
if(!UsefulBuf_IsNULLC(UsefulBuf_Tail(xxyy, 5))) {
return "tail should have failed";
}
-
+
if(!UsefulBuf_IsNULLC(UsefulBuf_Tail(NULLUsefulBufC, 0))) {
return "tail of NULLUsefulBufC is not NULLUsefulBufC";
}
-
+
const UsefulBufC TailResult = UsefulBuf_Tail((UsefulBufC){NULL, 100}, 99);
if(TailResult.ptr != NULL || TailResult.len != 1) {
return "tail of NULL and length incorrect";
diff --git a/test/qcbor_decode_tests.h b/test/qcbor_decode_tests.h
index a7ee0b5..2b09c55 100644
--- a/test/qcbor_decode_tests.h
+++ b/test/qcbor_decode_tests.h
@@ -141,9 +141,9 @@
Parses all possible inputs that are two bytes long. Main point
is that the test doesn't crash as it doesn't evaluate the
input for correctness in any way.
-
+
(Parsing all possible 3 byte strings takes too long on all but
- very fast machines).
+ very fast machines).
*/
int ComprehensiveInputTest(void);
diff --git a/test/qcbor_encode_tests.c b/test/qcbor_encode_tests.c
index 6153b24..2a22cf1 100644
--- a/test/qcbor_encode_tests.c
+++ b/test/qcbor_encode_tests.c
@@ -1405,7 +1405,7 @@
if(CheckResults(Encoded, spExpectedBstrWrap)) {
return -2;
}
-
+
/* Another test; see about handling length calculation */
QCBOREncode_Init(&EC, (UsefulBuf){NULL, INT32_MAX});
QCBOREncode_OpenArray(&EC);
@@ -1756,7 +1756,7 @@
if(QCBORDecode_Finish(&DC)) {
return -16;
}
-
+
return 0;
}
@@ -1870,12 +1870,12 @@
int EncodeErrorTests()
{
QCBOREncodeContext EC;
-
-
+
+
// ------ Test for QCBOR_ERR_BUFFER_TOO_LARGE ------
// Do all of these tests with NULL buffers so no actual large allocations are neccesary
UsefulBuf Buffer = (UsefulBuf){NULL, UINT32_MAX};
-
+
// First verify no error from a big buffer
QCBOREncode_Init(&EC, Buffer);
QCBOREncode_OpenArray(&EC);
@@ -1898,7 +1898,7 @@
if(QCBOREncode_FinishGetSize(&EC, &xx) != QCBOR_ERR_BUFFER_TOO_LARGE) {
return -2;
}
-
+
// Third, fit an array in exactly at max position allowed
QCBOREncode_Init(&EC, Buffer);
QCBOREncode_OpenArray(&EC);
@@ -1934,8 +1934,8 @@
// Now just 1 byte over, see that it fails
return -4;
}
-
-
+
+
// ----- QCBOR_ERR_ARRAY_NESTING_TOO_DEEP -------
QCBOREncode_Init(&EC, Large);
for(int i = QCBOR_MAX_ARRAY_NESTING; i > 0; i--) {
@@ -1960,8 +1960,8 @@
// One more level to cause error
return -6;
}
-
-
+
+
// ------ QCBOR_ERR_TOO_MANY_CLOSES --------
QCBOREncode_Init(&EC, Large);
for(int i = QCBOR_MAX_ARRAY_NESTING; i > 0; i--) {
@@ -1974,8 +1974,8 @@
// One more level to cause error
return -7;
}
-
-
+
+
// ------ QCBOR_ERR_CLOSE_MISMATCH --------
QCBOREncode_Init(&EC, Large);
QCBOREncode_OpenArray(&EC);
@@ -1998,7 +1998,7 @@
// One more level to cause error
return -9;
}
-
+
/* QCBOR_ERR_ARRAY_TOO_LONG is not tested here as
it would require a 64KB of RAM to test */
diff --git a/test/run_tests.c b/test/run_tests.c
index c2816ba..6c09b09 100644
--- a/test/run_tests.c
+++ b/test/run_tests.c
@@ -209,7 +209,7 @@
if(pfOutput) {
(*pfOutput)(" FAILED (returned ", poutCtx, 0);
(*pfOutput)(szTestResult, poutCtx, 0);
- (*pfOutput)(")\n", poutCtx, 1);
+ (*pfOutput)(")", poutCtx, 1);
}
nTestsFailed++;
} else {
diff --git a/test/run_tests.h b/test/run_tests.h
index 438d55e..153107c 100644
--- a/test/run_tests.h
+++ b/test/run_tests.h
@@ -33,8 +33,9 @@
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
==============================================================================*/
-
-
+/**
+ @file run_tests.h
+*/
/**
@brief Type for function to output a text string
@@ -44,9 +45,12 @@
@param[in] bNewline If non-zero, output a newline after the string
This is a prototype of a function to be passed to RunTests() to
- output text strings. This can be implemented with stdio (if
- available) using a straight call to fputs() where the FILE *
- is passed as the ctx.
+ output text strings.
+
+ This can be implemented with stdio (if available) using a straight
+ call to fputs() where the FILE * is passed as the pOutCtx as shown in
+ the example code below. This code is for Linux where the newline is
+ a \\n. Windows usually prefers \\r\\n.
@code
static void fputs_wrapper(const char *szString, void *pOutCtx, int bNewLine)