diff --git a/include/bits/sys/time.h b/include/bits/sys/time.h index 0b4f8f285c7edf59a09255afbca9648780757cf5..73b0683f5c2e76a9f6ab2d6bbe14cfc38902803c 100644 --- a/include/bits/sys/time.h +++ b/include/bits/sys/time.h @@ -14,10 +14,10 @@ (t)->tv_sec = 0, \ (t)->tv_usec = 0 \ ) -#define timerisset(t) (t)->tv_sec || (t)->tv_usec -#define timercmp(x,y,op) (x)->tv_sec == (y)->tv_sec ? \ +#define timerisset(t) ((t)->tv_sec || (t)->tv_usec) +#define timercmp(x,y,op) ((x)->tv_sec == (y)->tv_sec ? \ (x)->tv_usec op (y)->tv_usec \ : \ - (x)->tv_sec op (y)->tv_sec + (x)->tv_sec op (y)->tv_sec) #endif diff --git a/tests/Makefile b/tests/Makefile index d90078cfd11f083c49e6850580192035157a4265..30efeddaeca20c4250866f61a7d37ab6115f8b96 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -150,10 +150,12 @@ verify: | ../sysroot $(EXPECT_BINS) done CFLAGS=\ + -std=c11 \ -fno-builtin \ -fno-stack-protector \ -static \ -Wall \ + -pedantic \ -g \ -nostdinc \ -nostdlib \ diff --git a/tests/constructor.c b/tests/constructor.c index 4a5a4fa55e50065534e996fdeb1edda64d67955e..01f4f9ca33bdb2c50cfb23de7740148f28169f5b 100644 --- a/tests/constructor.c +++ b/tests/constructor.c @@ -11,10 +11,10 @@ void constructor_no_priority(void) { puts("constructor ("#__priority")"); \ } -TEST(101); -TEST(102); -TEST(103); -TEST(104); +TEST(101) +TEST(102) +TEST(103) +TEST(104) int main(int argc, char *argv[]) { puts("main"); diff --git a/tests/destructor.c b/tests/destructor.c index af3e1416bffdcda9efbaf672c782d79b55e5c80f..57b87ff11b39867aa7e2891dfb26b49e30baa34b 100644 --- a/tests/destructor.c +++ b/tests/destructor.c @@ -11,10 +11,10 @@ void destructor_no_priority(void) { puts("destructor ("#__priority")"); \ } -TEST(101); -TEST(102); -TEST(103); -TEST(104); +TEST(101) +TEST(102) +TEST(103) +TEST(104) int main(int argc, char *argv[]) { puts("main"); diff --git a/tests/expected/time/time.stderr b/tests/expected/time/time.stderr index b19be1d86ccea100aa1b039acf0316326c854b0c..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 --- a/tests/expected/time/time.stderr +++ b/tests/expected/time/time.stderr @@ -1,3 +0,0 @@ -clock_gettime: Success -time: Success -clock: Success diff --git a/tests/regex.c b/tests/regex.c index 432a8b546ed2fb0fa7f29473bb3ef077a998e28a..cd692f89b31660fc9000078a4d75bdb29f476f28 100644 --- a/tests/regex.c +++ b/tests/regex.c @@ -13,7 +13,7 @@ int main() { return -1; } - regmatch_t matches[3] = { 0 }; + regmatch_t matches[3] = {{0}}; error = regexec(®ex, "Hey, how are you? Hello? Hallo Wurld??", 3, matches, 0); diff --git a/tests/stdlib/bsearch.c b/tests/stdlib/bsearch.c index efe8d46521278021be48e6574e1e120e4d834cc7..c8e43c612bf4e00d1183be261b17e19666637f3b 100644 --- a/tests/stdlib/bsearch.c +++ b/tests/stdlib/bsearch.c @@ -22,8 +22,10 @@ int int_cmp(const void* a, const void* b) { int main(int argc, char* argv[]) { int x = 0; int y = 1024; - int empty[] = {}; - BSEARCH_TEST_INT(x, empty, 0, NULL); + + // TODO: Zero sized arrays are a non-standard GNU extension + //int empty[] = {}; + //BSEARCH_TEST_INT(x, empty, 0, NULL); int singleton[] = {42}; printf("%p\n%p\n", singleton, &singleton[1]); diff --git a/tests/string/strtok.c b/tests/string/strtok.c index 9809fdf054f4ca51c77a657e3d30e86af60d5ace..18436d9f7ea36cc55854d8a80b3734094f9414b7 100644 --- a/tests/string/strtok.c +++ b/tests/string/strtok.c @@ -8,7 +8,7 @@ int main(int argc, char* argv[]) { char* token = strtok(source, " "); while (token) { printf("%s", token); - if (token = strtok(NULL, " ")) { + if ((token = strtok(NULL, " "))) { printf("_"); } } diff --git a/tests/string/strtok_r.c b/tests/string/strtok_r.c index 36becfe2969093dcd80246a1dcef0b03a0892770..6b3f501422148aa0588e23704a01e06ee4bc5b1e 100644 --- a/tests/string/strtok_r.c +++ b/tests/string/strtok_r.c @@ -9,7 +9,7 @@ int main(int argc, char* argv[]) { char* token = strtok_r(source, " ", &sp); while (token) { printf("%s", token); - if (token = strtok_r(NULL, " ", &sp)) { + if ((token = strtok_r(NULL, " ", &sp))) { printf("_"); } } diff --git a/tests/time/mktime.c b/tests/time/mktime.c index 9b9d94069378aa4db623451b160b4cb60ee15f2c..c99102f673ce78d75b7aeb96b8ee5e77d2dc0df9 100644 --- a/tests/time/mktime.c +++ b/tests/time/mktime.c @@ -19,7 +19,7 @@ int check(time_t input) { return 0; } int main() { - struct tm t = {}; + struct tm t = { 0 }; t.tm_year = 71; t.tm_mday = 1; diff --git a/tests/time/time.c b/tests/time/time.c index bf827b1c00df4cf6f44a6924eed2de6a77007be5..3dc120b2703cd77557bdbb26f6ce8eae8329518e 100644 --- a/tests/time/time.c +++ b/tests/time/time.c @@ -3,11 +3,24 @@ int main(int argc, char** argv) { struct timespec tm = {0, 0}; - clock_gettime(CLOCK_REALTIME, &tm); - perror("clock_gettime"); - time(NULL); - perror("time"); + + int cgt = clock_gettime(CLOCK_REALTIME, &tm); + if (cgt == -1) { + perror("clock_gettime"); + return 1; + } + + time_t t = time(NULL); + if (t == (time_t)-1) { + perror("time"); + return 1; + } + clock_t c = clock(); - perror("clock"); + if (c == (clock_t)-1) { + perror("clock"); + return 1; + } + return 0; } diff --git a/tests/unistd/pipe.c b/tests/unistd/pipe.c index af5b2d89ae13156a7cae3e775d9d3176342a768e..8f0fc71e5c629ea32ecac86f51f1468593d17266 100644 --- a/tests/unistd/pipe.c +++ b/tests/unistd/pipe.c @@ -59,7 +59,7 @@ int main() } else if (bytes != strlen(outstring)) { fprintf(stderr, "pipe read: %d != %ld\n", bytes, strlen(outstring)); return 1; - } else if (memcmp(instring, outstring, sizeof(outstring)) != 0) { + } else if (memcmp(instring, outstring, strlen(outstring)) != 0) { fprintf(stderr, "pipe read does not match pipe write\n"); return 1; } else { diff --git a/tests/wchar/mbrtowc.c b/tests/wchar/mbrtowc.c index 4487d2273192ce2b38c98e2eac6ef054b34d1c82..293926d7ed5def7befe3dce8e04c8a3589a31f07 100644 --- a/tests/wchar/mbrtowc.c +++ b/tests/wchar/mbrtowc.c @@ -27,4 +27,4 @@ int main(void) printf("into %zu wchar_t units: [ ", out_sz); //Should be 5 wchars for(size_t x = 0; x < out_sz; ++x) printf("%#x ", out[x]); puts("]"); -} \ No newline at end of file +} diff --git a/tests/wchar/putwchar.c b/tests/wchar/putwchar.c index f9f7ea41236ce5bbbf85d1cbd1ed318b67a0ea71..067c0a4107565cc200a001b22f712e43ec2a39a2 100644 --- a/tests/wchar/putwchar.c +++ b/tests/wchar/putwchar.c @@ -18,4 +18,4 @@ int main(void) } return 0; -} \ No newline at end of file +} diff --git a/tests/wchar/wcrtomb.c b/tests/wchar/wcrtomb.c index 27b05cef6b3bbfb9b383867c11ec5f185cc65f02..4bf5dc35746aade08c69befaa6e7f9b68dd35a73 100644 --- a/tests/wchar/wcrtomb.c +++ b/tests/wchar/wcrtomb.c @@ -26,4 +26,4 @@ int main( void ) printf("into %zu UTF-8 code units: [ ", out_sz); for(size_t x = 0; x < out_sz; ++x) printf("%#x ", +(unsigned char)out[x]); puts("]"); -} \ No newline at end of file +}