tests: set C11, enable pedantic warnings, fix GCC and Clang warnings
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -150,10 +150,12 @@ verify: | ../sysroot $(EXPECT_BINS)
|
||||
done
|
||||
|
||||
CFLAGS=\
|
||||
-std=c11 \
|
||||
-fno-builtin \
|
||||
-fno-stack-protector \
|
||||
-static \
|
||||
-Wall \
|
||||
-pedantic \
|
||||
-g \
|
||||
-nostdinc \
|
||||
-nostdlib \
|
||||
|
||||
+4
-4
@@ -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");
|
||||
|
||||
+4
-4
@@ -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");
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
clock_gettime: Success
|
||||
time: Success
|
||||
clock: Success
|
||||
|
||||
+1
-1
@@ -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);
|
||||
|
||||
|
||||
@@ -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]);
|
||||
|
||||
@@ -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("_");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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("_");
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -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;
|
||||
|
||||
+18
-5
@@ -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;
|
||||
}
|
||||
|
||||
+1
-1
@@ -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 {
|
||||
|
||||
@@ -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("]");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,4 +18,4 @@ int main(void)
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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("]");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user