From 02582cc1ab4d188d663bb9948de4a1e7bfb187d6 Mon Sep 17 00:00:00 2001 From: leitner Date: Tue, 26 Nov 2024 09:49:31 +0000 Subject: [PATCH] sprinkle compiler attributes over code base some arm fixes (char is unsigned on arm) --- CHANGES | 2 ++ compiler.h | 2 ++ str/str_len.c | 2 ++ textcode/scan_jsonescape.c | 2 +- 4 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index c65cf0a..5c3c690 100644 --- a/CHANGES +++ b/CHANGES @@ -1,5 +1,7 @@ 0.35: add clamp.h (for easy integer overflow prevention) + sprinkle compiler attributes over code base + some arm fixes (char is unsigned on arm) 0.34: be more C99 compliant (Florian Weimer) diff --git a/compiler.h b/compiler.h index 4361770..e98e383 100644 --- a/compiler.h +++ b/compiler.h @@ -158,6 +158,7 @@ #define __builtin_constant_p(x) 0 #endif +#ifndef __dietlibc__ #if defined(__GNUC__) #if __has_attribute(null_terminated_string_arg) // Function arguments. @@ -208,5 +209,6 @@ #endif #endif // !defined(__GNUC__) +#endif // !defined(__dietlibc__ #endif diff --git a/str/str_len.c b/str/str_len.c index 9621518..915282e 100644 --- a/str/str_len.c +++ b/str/str_len.c @@ -1,3 +1,5 @@ +#include +#include "compiler.h" #undef __dietlibc__ #include "str.h" diff --git a/textcode/scan_jsonescape.c b/textcode/scan_jsonescape.c index 3d30401..8c6b4c5 100644 --- a/textcode/scan_jsonescape.c +++ b/textcode/scan_jsonescape.c @@ -29,7 +29,7 @@ size_t scan_jsonescape(const char *src,char *dest,size_t *destlen) { size_t j; unsigned int cur; for (cur=j=0; j<4; ++j) { - char x=scan_fromhex(s[i+2+j]); + signed char x=scan_fromhex(s[i+2+j]); if (x<0) goto abort; // not hex -> invalid input cur=(cur<<4) | x; }