Skip to content

Commit 62c73f6

Browse files
Merge branch 'main' into dev
2 parents cc7774e + e27261e commit 62c73f6

File tree

8 files changed

+31
-11
lines changed

8 files changed

+31
-11
lines changed

Makefile

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ silentcheck: | $(BINLIBRARY)
134134
TESTARGS=-silent $(MAKE) -f $(MAKEFILE) -s check
135135
configure: .config
136136
.config: Makefile.configure
137-
$(MAKE) -f $(SRCDIR)Makefile.configure OUT='>&9' configure 9> $@
137+
$(MAKE) -f $(SRCDIR)Makefile.configure OUT='$@' configure
138138

139139
lib/libtinycbor-freestanding.a: $(TINYCBOR_FREESTANDING_SOURCES:.c=.o)
140140
@$(MKDIR) -p lib
@@ -236,10 +236,16 @@ tag: distcheck
236236
.SECONDARY:
237237

238238
cflags := $(CPPFLAGS) -I$(SRCDIR)src
239-
cflags += -std=gnu99 $(CFLAGS) \
239+
cflags += -std=gnu99 $(CFLAGS)
240+
241+
ifneq ($(DISABLE_WERROR),1)
242+
cflags += \
243+
-Werror=discarded-qualifiers \
240244
-Werror=incompatible-pointer-types \
241245
-Werror=implicit-function-declaration \
242246
-Werror=int-conversion
247+
endif
248+
243249
%.o: %.c
244250
@test -d $(@D) || $(MKDIR) $(@D)
245251
$(CC) $(cflags) $($(basename $(notdir $@))_CCFLAGS) -c -o $@ $<

Makefile.configure

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ sink:
2727
configure: $(foreach it,$(ALLTESTS),check-$(it))
2828

2929
check-%:
30-
@echo $(subst check-,,$@)-tested := 1 $(OUT)
30+
@echo $(subst check-,,$@)-tested := 1 >>$(OUT)
3131
$(if $(V),,@)if printf "$($(subst check-,PROGRAM-,$@))" | \
3232
$(CC) -xc $($(subst check-,CCFLAGS-,$@)) -o /dev/null - $(if $(V),,>/dev/null 2>&1); \
3333
then \
34-
echo $(subst check-,,$@)-pass := 1 $(OUT); \
34+
echo $(subst check-,,$@)-pass := 1 >>$(OUT); \
3535
fi

src/cborparser.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1211,7 +1211,7 @@ static CborError iterate_string_chunks(const CborValue *value, char *buffer, siz
12111211
return CborErrorDataTooLarge;
12121212

12131213
if (*result && *buflen >= newTotal)
1214-
*result = !!func(buffer + total, (const uint8_t *)ptr, chunkLen);
1214+
*result = !!func(buffer == NULL ? buffer : buffer + total, (const uint8_t *)ptr, chunkLen);
12151215
else
12161216
*result = false;
12171217

@@ -1221,7 +1221,7 @@ static CborError iterate_string_chunks(const CborValue *value, char *buffer, siz
12211221
/* is there enough room for the ending NUL byte? */
12221222
if (*result && *buflen > total) {
12231223
uint8_t nul[] = { 0 };
1224-
*result = !!func(buffer + total, nul, 1);
1224+
*result = !!func(buffer == NULL ? buffer : buffer + total, nul, 1);
12251225
}
12261226
*buflen = total;
12271227
return _cbor_value_finish_string_iteration(next);

src/cbortojson.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
#define _BSD_SOURCE 1
2626
#define _DEFAULT_SOURCE 1
2727
#define _GNU_SOURCE 1
28-
#define _POSIX_C_SOURCE 200809L
2928
#ifndef __STDC_LIMIT_MACROS
3029
# define __STDC_LIMIT_MACROS 1
3130
#endif

src/cborvalidation.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,7 @@ CborError cbor_value_validate(const CborValue *it, uint32_t flags)
647647
CborError err = validate_value(&value, flags, CBOR_PARSER_MAX_RECURSIONS);
648648
if (err)
649649
return err;
650-
if (flags & CborValidateCompleteData && can_read_bytes(it, 1))
650+
if (flags & CborValidateCompleteData && can_read_bytes(&value, 1))
651651
return CborErrorGarbageAtEnd;
652652
return CborNoError;
653653
}

src/compilersupport_p.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@
156156
(defined(BYTE_ORDER) && defined(LITTLE_ENDIAN) && BYTE_ORDER == LITTLE_ENDIAN) || \
157157
defined(_LITTLE_ENDIAN) || defined(__LITTLE_ENDIAN__) || defined(__ARMEL__) || defined(__MIPSEL__) || \
158158
defined(__i386) || defined(__i386__) || defined(__x86_64) || defined(__x86_64__) || defined(__amd64)
159-
# define ntohll(x) ((ntohl((uint32_t)(x)) * UINT64_C(0x100000000)) + (ntohl((x) >> 32)))
159+
# define ntohll(x) ((cbor_ntohl((uint32_t)(x)) * UINT64_C(0x100000000)) + (cbor_ntohl((x) >> 32)))
160160
# define htonll ntohll
161161
# else
162162
# error "Unable to determine byte order!"
@@ -202,4 +202,3 @@ static inline bool add_check_overflow(size_t v1, size_t v2, size_t *r)
202202
}
203203

204204
#endif /* COMPILERSUPPORT_H */
205-

tests/parser/tst_parser.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ private slots:
106106
// validation & errors
107107
void checkedIntegers_data();
108108
void checkedIntegers();
109+
void validationValid_data() { arrays_data(); }
110+
void validationValid();
109111
void validation_data();
110112
void validation();
111113
void strictValidation_data();
@@ -1337,6 +1339,21 @@ void tst_Parser::checkedIntegers()
13371339
}
13381340
}
13391341

1342+
void tst_Parser::validationValid()
1343+
{
1344+
// verify that all valid data validate properly
1345+
QFETCH(QByteArray, data);
1346+
1347+
QString decoded;
1348+
ParserWrapper w;
1349+
CborError err = w.init(data);
1350+
QVERIFY2(!err, QByteArray("Got error \"") + cbor_error_string(err) + "\"");
1351+
1352+
QCOMPARE(cbor_value_validate_basic(&w.first), CborNoError);
1353+
QCOMPARE(cbor_value_validate(&w.first, CborValidateBasic), CborNoError);
1354+
QCOMPARE(cbor_value_validate(&w.first, CborValidateCompleteData), CborNoError);
1355+
}
1356+
13401357
void tst_Parser::validation_data()
13411358
{
13421359
addValidationColumns();

tools/json2cbor/json2cbor.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
**
2323
****************************************************************************/
2424

25-
#define _POSIX_C_SOURCE 200809L
2625
#define _GNU_SOURCE
2726
#include "cbor.h"
2827
#include "cborinternal_p.h"

0 commit comments

Comments
 (0)