From d38a1d0da3c2a1c078edf56d5983e4c2cad89ae6 Mon Sep 17 00:00:00 2001 From: Tibor Nagy Date: Wed, 20 Feb 2019 10:29:20 +0100 Subject: [PATCH 1/6] ctype: Implement _tolower, _toupper --- include/bits/ctype.h | 7 +++++++ src/header/ctype/cbindgen.toml | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 include/bits/ctype.h diff --git a/include/bits/ctype.h b/include/bits/ctype.h new file mode 100644 index 0000000000..e5dedf5d30 --- /dev/null +++ b/include/bits/ctype.h @@ -0,0 +1,7 @@ +#ifndef _BITS_CTYPE_H +#define _BITS_CTYPE_H + +#define _tolower(c) tolower(c) +#define _toupper(c) toupper(c) + +#endif /* _BITS_CTYPE_H */ diff --git a/src/header/ctype/cbindgen.toml b/src/header/ctype/cbindgen.toml index 4fadb84477..eb9b10d151 100644 --- a/src/header/ctype/cbindgen.toml +++ b/src/header/ctype/cbindgen.toml @@ -1,4 +1,4 @@ -sys_includes = [] +sys_includes = ["bits/ctype.h"] include_guard = "_CTYPE_H" language = "C" style = "Tag" From 7ee59d2fdbe6f1129b9d19fd376cb1ec2f9aa0d7 Mon Sep 17 00:00:00 2001 From: Tibor Nagy Date: Wed, 20 Feb 2019 15:04:47 +0100 Subject: [PATCH 2/6] tests: set C11, enable pedantic warnings, fix GCC and Clang warnings --- include/bits/sys/time.h | 6 +++--- tests/Makefile | 2 ++ tests/constructor.c | 8 ++++---- tests/destructor.c | 8 ++++---- tests/expected/time/time.stderr | 3 --- tests/regex.c | 2 +- tests/stdlib/bsearch.c | 6 ++++-- tests/string/strtok.c | 2 +- tests/string/strtok_r.c | 2 +- tests/time/mktime.c | 2 +- tests/time/time.c | 23 ++++++++++++++++++----- tests/unistd/pipe.c | 2 +- tests/wchar/mbrtowc.c | 2 +- tests/wchar/putwchar.c | 2 +- tests/wchar/wcrtomb.c | 2 +- 15 files changed, 43 insertions(+), 29 deletions(-) diff --git a/include/bits/sys/time.h b/include/bits/sys/time.h index 0b4f8f285c..73b0683f5c 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 d90078cfd1..30efeddaec 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 4a5a4fa55e..01f4f9ca33 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 af3e1416bf..57b87ff11b 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 b19be1d86c..e69de29bb2 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 432a8b546e..cd692f89b3 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 efe8d46521..c8e43c612b 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 9809fdf054..18436d9f7e 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 36becfe296..6b3f501422 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 9b9d940693..c99102f673 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 bf827b1c00..3dc120b270 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 af5b2d89ae..8f0fc71e5c 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 4487d22731..293926d7ed 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 f9f7ea4123..067c0a4107 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 27b05cef6b..4bf5dc3574 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 +} From ff874c87d7479b1d7c853af369778d99e82c13ba Mon Sep 17 00:00:00 2001 From: Tibor Nagy Date: Wed, 20 Feb 2019 19:27:18 +0100 Subject: [PATCH 3/6] tests: Fix function signatures --- CONTRIBUTING.md | 16 ++++++++-------- tests/alloca.c | 2 +- tests/args.c | 2 +- tests/arpainet.c | 2 +- tests/assert.c | 2 +- tests/constructor.c | 2 +- tests/ctype.c | 2 +- tests/destructor.c | 2 +- tests/dirent/main.c | 2 +- tests/dirent/scandir.c | 2 +- tests/error.c | 2 +- tests/fcntl/create.c | 2 +- tests/fcntl/fcntl.c | 2 +- tests/fnmatch.c | 2 +- tests/libgen.c | 6 +++--- tests/locale.c | 2 +- tests/math.c | 2 +- tests/netdb/netdb.c | 2 +- tests/pwd.c | 2 +- tests/regex.c | 2 +- tests/resource/getrusage.c | 2 +- tests/select.c | 2 +- tests/setjmp.c | 2 +- tests/signal.c | 2 +- tests/stdio/all.c | 2 +- tests/stdio/buffer.c | 2 +- tests/stdio/fgets.c | 2 +- tests/stdio/fputs.c | 2 +- tests/stdio/fread.c | 2 +- tests/stdio/freopen.c | 2 +- tests/stdio/fseek.c | 2 +- tests/stdio/fwrite.c | 2 +- tests/stdio/getc_unget.c | 2 +- tests/stdio/mutex.c | 2 +- tests/stdio/popen.c | 2 +- tests/stdio/printf.c | 2 +- tests/stdio/rename.c | 2 +- tests/stdio/scanf.c | 2 +- tests/stdio/setvbuf.c | 2 +- tests/stdio/sprintf.c | 2 +- tests/stdlib/a64l.c | 2 +- tests/stdlib/alloc.c | 2 +- tests/stdlib/atof.c | 2 +- tests/stdlib/atoi.c | 2 +- tests/stdlib/bsearch.c | 2 +- tests/stdlib/div.c | 7 +++---- tests/stdlib/env.c | 2 +- tests/stdlib/mkostemps.c | 2 +- tests/stdlib/mktemp.c | 2 +- tests/stdlib/rand.c | 2 +- tests/stdlib/realpath.c | 2 +- tests/stdlib/strtod.c | 2 +- tests/stdlib/strtol.c | 2 +- tests/stdlib/strtoul.c | 2 +- tests/stdlib/system.c | 2 +- tests/string/mem.c | 2 +- tests/string/strcat.c | 2 +- tests/string/strchr.c | 2 +- tests/string/strcpy.c | 2 +- tests/string/strcspn.c | 2 +- tests/string/strncmp.c | 2 +- tests/string/strpbrk.c | 2 +- tests/string/strrchr.c | 3 +-- tests/string/strspn.c | 2 +- tests/string/strstr.c | 2 +- tests/string/strtok.c | 2 +- tests/string/strtok_r.c | 2 +- tests/strings.c | 2 +- tests/sys_utsname/uname.c | 2 +- tests/time/asctime.c | 2 +- tests/time/gettimeofday.c | 2 +- tests/time/gmtime.c | 2 +- tests/time/localtime.c | 2 +- tests/time/macros.c | 2 +- tests/time/mktime.c | 3 ++- tests/time/strftime.c | 3 ++- tests/time/time.c | 2 +- tests/time/times.c | 2 +- tests/unistd/access.c | 2 +- tests/unistd/brk.c | 2 +- tests/unistd/chdir.c | 2 +- tests/unistd/dup.c | 2 +- tests/unistd/exec.c | 2 +- tests/unistd/fchdir.c | 2 +- tests/unistd/fsync.c | 2 +- tests/unistd/ftruncate.c | 2 +- tests/unistd/getcwd.c | 2 +- tests/unistd/gethostname.c | 2 +- tests/unistd/getid.c | 2 +- tests/unistd/isatty.c | 2 +- tests/unistd/link.c | 2 +- tests/unistd/pathconf.c | 2 +- tests/unistd/pipe.c | 4 +--- tests/unistd/rmdir.c | 2 +- tests/unistd/setid.c | 5 ++--- tests/unistd/sleep.c | 2 +- tests/unistd/stat.c | 2 +- tests/unistd/sysconf.c | 2 +- tests/unistd/write.c | 2 +- tests/waitpid.c | 2 +- tests/wchar/mbrtowc.c | 3 +-- tests/wchar/mbsrtowcs.c | 3 +-- tests/wchar/putwchar.c | 3 +-- tests/wchar/wcrtomb.c | 5 ++--- 104 files changed, 119 insertions(+), 126 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ddeac8444c..e1d1a28dca 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -88,14 +88,14 @@ just in case, it'd be a good idea to map inputs to variables. #include "string.h" #include "stdio.h" -int main() { - // Don't do this - printf("%d\n", strcspn("Hello", "Hi")); +int main(void) { + // Don't do this + printf("%d\n", strcspn("Hello", "Hi")); - // Do this - char *first = "Hello"; - char *second = "Hi"; - printf("%d\n", strcspn(first, second)); + // Do this + char *first = "Hello"; + char *second = "Hi"; + printf("%d\n", strcspn(first, second)); } ``` @@ -120,4 +120,4 @@ You can test against verified correct output with `make verify` in the tests directory. You will need to manually create the correct output and put it in the tests/expected directory. Running any `make` commands in the tests directory will ***not*** rebuild relibc, so you'll need to go back to the root directory -if you need to rebuild relibc. \ No newline at end of file +if you need to rebuild relibc. diff --git a/tests/alloca.c b/tests/alloca.c index 990bd49b35..3d774c5fcc 100644 --- a/tests/alloca.c +++ b/tests/alloca.c @@ -2,7 +2,7 @@ #include #include -int main(int argc, char ** argv) { +int main(void) { char *str = (char *) alloca(17); memset(str, 'A', 16); diff --git a/tests/args.c b/tests/args.c index fd9c779701..e05509c405 100644 --- a/tests/args.c +++ b/tests/args.c @@ -1,7 +1,7 @@ #include #include -int main(int argc, char ** argv) { +int main(int argc, char *argv[]) { int i; for(i = 0; i < argc; i++) { write(STDOUT_FILENO, argv[i], strlen(argv[i])); diff --git a/tests/arpainet.c b/tests/arpainet.c index c93f3933c2..cae9921b54 100644 --- a/tests/arpainet.c +++ b/tests/arpainet.c @@ -3,7 +3,7 @@ #include #include -int main(int argc, char** argv) { +int main(void) { uint32_t hl = 0xBADFACED; uint32_t nl = htonl(hl); assert(nl == 0xEDACDFBA); diff --git a/tests/assert.c b/tests/assert.c index 7f98bbe9c5..0ab46cafa2 100644 --- a/tests/assert.c +++ b/tests/assert.c @@ -2,7 +2,7 @@ #include #include -int main() { +int main(void) { assert(1 == 1); assert(1 + 1 == 2); puts("yay!"); diff --git a/tests/constructor.c b/tests/constructor.c index 01f4f9ca33..38fc58cbaf 100644 --- a/tests/constructor.c +++ b/tests/constructor.c @@ -16,6 +16,6 @@ TEST(102) TEST(103) TEST(104) -int main(int argc, char *argv[]) { +int main(void) { puts("main"); } diff --git a/tests/ctype.c b/tests/ctype.c index 46682640b5..40ba65ae47 100644 --- a/tests/ctype.c +++ b/tests/ctype.c @@ -293,7 +293,7 @@ size_t num_test_cases = sizeof(test_cases) / sizeof(struct test_case); printf("Unexpected result: " #fn "('%c') != %d // Char value: %d\n", tc.c, tc.fn, tc.c); \ } -int main(int argc, char* argv[]) { +int main(void) { int retval = 0; for(int i = 0; i < num_test_cases; ++i) { diff --git a/tests/destructor.c b/tests/destructor.c index 57b87ff11b..40840ccde6 100644 --- a/tests/destructor.c +++ b/tests/destructor.c @@ -16,6 +16,6 @@ TEST(102) TEST(103) TEST(104) -int main(int argc, char *argv[]) { +int main(void) { puts("main"); } diff --git a/tests/dirent/main.c b/tests/dirent/main.c index 08cea69296..430626af70 100644 --- a/tests/dirent/main.c +++ b/tests/dirent/main.c @@ -2,7 +2,7 @@ #include #include -int main() { +int main(void) { printf("%lu\n", sizeof(struct dirent)); DIR* dir = opendir("example_dir/"); diff --git a/tests/dirent/scandir.c b/tests/dirent/scandir.c index 383a6ca0b1..2b2ea03c2b 100644 --- a/tests/dirent/scandir.c +++ b/tests/dirent/scandir.c @@ -7,7 +7,7 @@ int filter(const struct dirent* dirent) { return strstr(dirent->d_name, "3") == NULL; } -int main() { +int main(void) { struct dirent** array; int len = scandir("example_dir/", &array, filter, alphasort); if (len < 0) { diff --git a/tests/error.c b/tests/error.c index 0b539992d4..ac84c343b8 100644 --- a/tests/error.c +++ b/tests/error.c @@ -3,7 +3,7 @@ #include #include -int main(int argc, char** argv) { +int main(void) { chdir("nonexistent"); printf("errno: %d = %s\n", errno, strerror(errno)); perror("perror"); diff --git a/tests/fcntl/create.c b/tests/fcntl/create.c index 864496830b..8e70cb6c60 100644 --- a/tests/fcntl/create.c +++ b/tests/fcntl/create.c @@ -1,7 +1,7 @@ #include #include -int main(int argc, char ** argv) { +int main(void) { int fd = creat("create.out", 0755); if (fd >= 0) { write(fd, "Hello World!\n", 13); diff --git a/tests/fcntl/fcntl.c b/tests/fcntl/fcntl.c index 4ce261d188..474e163f56 100644 --- a/tests/fcntl/fcntl.c +++ b/tests/fcntl/fcntl.c @@ -2,7 +2,7 @@ #include #include -int main() { +int main(void) { //Lose our fd and pull it again creat("fcntl.out", 0777); int newfd = open("fcntl.out", 0); diff --git a/tests/fnmatch.c b/tests/fnmatch.c index 4d10a642ef..9fa673f539 100644 --- a/tests/fnmatch.c +++ b/tests/fnmatch.c @@ -9,7 +9,7 @@ void test(char* pattern, char* input, int flags) { } } -int main() { +int main(void) { puts("Should succeed:"); test("*World", "Hello World", 0); test("*World", "World", 0); diff --git a/tests/libgen.c b/tests/libgen.c index f38f70f0f0..fd79f5b9d6 100644 --- a/tests/libgen.c +++ b/tests/libgen.c @@ -18,7 +18,7 @@ char * get_mutable_string(char *str) { return copy; } -void test_basename() { +void test_basename(void) { test_case test_cases[] = { {"/usr/lib", "lib"}, {"//usr//lib//", "lib"}, @@ -44,7 +44,7 @@ void test_basename() { return; } -void test_dirname() { +void test_dirname(void) { test_case test_cases[] = { {"/usr/lib", "/usr"}, {"//usr//lib//", "//usr"}, @@ -73,7 +73,7 @@ void test_dirname() { return; } -int main() { +int main(void) { printf("Testing libgen.h\n"); test_basename(); test_dirname(); diff --git a/tests/locale.c b/tests/locale.c index 9358bc5554..dde3364da4 100644 --- a/tests/locale.c +++ b/tests/locale.c @@ -2,7 +2,7 @@ #include #include -int main() { +int main(void) { // TODO: Implement locale properly and test it here char* val = setlocale(LC_ALL, NULL); if (strcmp(val, "C") == 0) { diff --git a/tests/math.c b/tests/math.c index fb53fa2438..014529f468 100644 --- a/tests/math.c +++ b/tests/math.c @@ -1,7 +1,7 @@ #include #include -int main(int argc, char ** argv) { +int main(void) { double pi = 3.14; float c = cos(pi); printf("cos(%f) = %f\n", pi, c); diff --git a/tests/netdb/netdb.c b/tests/netdb/netdb.c index 9bbbf3e283..d81f08d632 100644 --- a/tests/netdb/netdb.c +++ b/tests/netdb/netdb.c @@ -225,6 +225,6 @@ do_test (void) return (error_count != 0); } -int main() { +int main(void) { do_test(); } diff --git a/tests/pwd.c b/tests/pwd.c index 52b3511675..77087425ef 100644 --- a/tests/pwd.c +++ b/tests/pwd.c @@ -13,7 +13,7 @@ void print(struct passwd *pwd) { printf("pw_shell: %s\n", pwd->pw_shell); } -int main() { +int main(void) { puts("--- Checking getpwuid ---"); errno = 0; struct passwd *pwd = getpwuid(0); diff --git a/tests/regex.c b/tests/regex.c index cd692f89b3..b74a0f2ce6 100644 --- a/tests/regex.c +++ b/tests/regex.c @@ -1,7 +1,7 @@ #include #include -int main() { +int main(void) { regex_t regex; char error_buf[256]; diff --git a/tests/resource/getrusage.c b/tests/resource/getrusage.c index a844335032..e04a623910 100644 --- a/tests/resource/getrusage.c +++ b/tests/resource/getrusage.c @@ -6,7 +6,7 @@ void ptimeval(struct timeval* val) { printf("{ tv_sec: %ld, tv_usec: %ld }\n", val->tv_sec, val->tv_usec); } -int main() { +int main(void) { struct rusage r_usage; if (getrusage(RUSAGE_SELF, &r_usage) < 0) { perror("getrusage"); diff --git a/tests/select.c b/tests/select.c index ba053a1e09..596a589a83 100644 --- a/tests/select.c +++ b/tests/select.c @@ -3,7 +3,7 @@ #include #include -int main() { +int main(void) { int fd = open("select.c", 0, 0); fd_set read; diff --git a/tests/setjmp.c b/tests/setjmp.c index c45390bf4a..fe117e4dec 100644 --- a/tests/setjmp.c +++ b/tests/setjmp.c @@ -1,7 +1,7 @@ #include #include -int main() { +int main(void) { jmp_buf buf; if (setjmp(buf)) { puts("hi from jump"); diff --git a/tests/signal.c b/tests/signal.c index 7f41785613..aa9a563e01 100644 --- a/tests/signal.c +++ b/tests/signal.c @@ -7,7 +7,7 @@ void handler(int sig) { puts("Signal handler called!"); } -int main() { +int main(void) { if (signal(SIGUSR1, &handler) == SIG_ERR) { puts("Signal error!"); printf("%d\n", errno); diff --git a/tests/stdio/all.c b/tests/stdio/all.c index 118f46541c..c049e3eb0e 100644 --- a/tests/stdio/all.c +++ b/tests/stdio/all.c @@ -1,7 +1,7 @@ #include #include -int main(int argc, char ** argv) { +int main(void) { FILE *f = fopen("stdio/stdio.in", "r"); printf("%c\n", fgetc(f)); ungetc('H', f); diff --git a/tests/stdio/buffer.c b/tests/stdio/buffer.c index c5d55944bf..50b236f148 100644 --- a/tests/stdio/buffer.c +++ b/tests/stdio/buffer.c @@ -1,6 +1,6 @@ #include -int main() { +int main(void) { // Tests what used to be a bug with buffering fwrite("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", 1, 999, stdout); fwrite("Test\n", 1, 5, stdout); diff --git a/tests/stdio/fgets.c b/tests/stdio/fgets.c index c89e491ae0..404002a8b2 100644 --- a/tests/stdio/fgets.c +++ b/tests/stdio/fgets.c @@ -1,6 +1,6 @@ #include -int main() { +int main(void) { //FILE *f = fopen("/etc/ssl/certs/ca-certificates.crt", "r"); FILE *f = fopen("stdio/stdio.in", "r"); char line[256]; diff --git a/tests/stdio/fputs.c b/tests/stdio/fputs.c index 34ac5f361a..2ce599203c 100644 --- a/tests/stdio/fputs.c +++ b/tests/stdio/fputs.c @@ -2,7 +2,7 @@ #include #include -int main(int argc, char ** argv) { +int main(void) { FILE *f = fopen("stdio/fputs.out", "w"); char *in = "Hello World!"; fputs(in, f); // calls fwrite, helpers::fwritex, internal::to_write and internal::stdio_write diff --git a/tests/stdio/fread.c b/tests/stdio/fread.c index 40b6f69e57..f87e9172b1 100644 --- a/tests/stdio/fread.c +++ b/tests/stdio/fread.c @@ -1,7 +1,7 @@ #include #include -int main(int argc, char *argv[]) { +int main(void) { FILE *fp = fopen("stdio/fread.in", "rb"); char buf[33] = { 0 }; diff --git a/tests/stdio/freopen.c b/tests/stdio/freopen.c index 7bf3b64f20..3189b7e64d 100644 --- a/tests/stdio/freopen.c +++ b/tests/stdio/freopen.c @@ -1,6 +1,6 @@ #include -int main(int argc, char ** argv) { +int main(void) { freopen("stdio/stdio.in", "r", stdin); char in[6]; fgets(in, 6, stdin); diff --git a/tests/stdio/fseek.c b/tests/stdio/fseek.c index 84f544d2a2..eed59eca0c 100644 --- a/tests/stdio/fseek.c +++ b/tests/stdio/fseek.c @@ -1,6 +1,6 @@ #include -int main() { +int main(void) { FILE *f = fopen("stdio/stdio.in", "r"); if (fseek(f, 14, SEEK_CUR) < 0) { puts("fseek error"); diff --git a/tests/stdio/fwrite.c b/tests/stdio/fwrite.c index 85da119054..37df8a75c9 100644 --- a/tests/stdio/fwrite.c +++ b/tests/stdio/fwrite.c @@ -2,7 +2,7 @@ #include #include -int main(int argc, char ** argv) { +int main(void) { FILE *f = fopen("stdio/fwrite.out", "w"); const char ptr[] = "Hello World!"; diff --git a/tests/stdio/getc_unget.c b/tests/stdio/getc_unget.c index f8008534fb..257170a04b 100644 --- a/tests/stdio/getc_unget.c +++ b/tests/stdio/getc_unget.c @@ -1,6 +1,6 @@ #include -int main(int argc, char ** argv) { +int main(void) { ungetc('h', stdin); char c; if ((c = getchar()) == 'h') { diff --git a/tests/stdio/mutex.c b/tests/stdio/mutex.c index 032ced27e9..04f7b386c9 100644 --- a/tests/stdio/mutex.c +++ b/tests/stdio/mutex.c @@ -1,6 +1,6 @@ #include -int main() { +int main(void) { FILE* f = fopen("stdio/stdio.in", "r"); flockfile(f); diff --git a/tests/stdio/popen.c b/tests/stdio/popen.c index 9550b0ef24..364b3753b5 100644 --- a/tests/stdio/popen.c +++ b/tests/stdio/popen.c @@ -1,6 +1,6 @@ #include -int main(int argc, char **argv) { +int main(void) { FILE *fp; int status; char path[256]; diff --git a/tests/stdio/printf.c b/tests/stdio/printf.c index 3ef0c9b224..833b39c84c 100644 --- a/tests/stdio/printf.c +++ b/tests/stdio/printf.c @@ -1,6 +1,6 @@ #include -int main(int argc, char ** argv) { +int main(void) { int sofar = 0; int len = printf( "percent: %%\nstring: %s\nchar: %c\nchar: %c\nint: %d\n%nuint: %u\nhex: %x\nHEX: %X\nstring: %s\n", diff --git a/tests/stdio/rename.c b/tests/stdio/rename.c index 189ba22771..537b2dc6a4 100644 --- a/tests/stdio/rename.c +++ b/tests/stdio/rename.c @@ -8,7 +8,7 @@ static char newpath[] = "new-name.out"; static char str[] = "Hello, World!"; int str_len = 13; -int main() { +int main(void) { char buf[14]; buf[13] = 0x00; int fd = creat(oldpath, 0777); diff --git a/tests/stdio/scanf.c b/tests/stdio/scanf.c index 3f6a236631..a19daaf3bb 100644 --- a/tests/stdio/scanf.c +++ b/tests/stdio/scanf.c @@ -25,7 +25,7 @@ void test(char* fmt_in, char* input, struct params *p, ...) { ); } -int main(int argc, char ** argv) { +int main(void) { struct params p = { .c = 'a' }; test("%hhd %d", "12 345", &p, &p.sa, &p.ia); diff --git a/tests/stdio/setvbuf.c b/tests/stdio/setvbuf.c index 62a13aeeb5..46191f53cd 100644 --- a/tests/stdio/setvbuf.c +++ b/tests/stdio/setvbuf.c @@ -1,7 +1,7 @@ #include #include -int main(int argc, char ** argv) { +int main(void) { setvbuf(stdout, 0, _IONBF, 0); FILE *f = fopen("stdio/stdio.in", "r"); setvbuf(f, 0, _IONBF, 0); diff --git a/tests/stdio/sprintf.c b/tests/stdio/sprintf.c index 7e42245bc2..3205473e3b 100644 --- a/tests/stdio/sprintf.c +++ b/tests/stdio/sprintf.c @@ -1,7 +1,7 @@ #include #include -int main(int argc, char ** argv) { +int main(void) { char buffer[72]; int ret = sprintf( diff --git a/tests/stdlib/a64l.c b/tests/stdlib/a64l.c index 8036d9e3fb..14d44a9f83 100644 --- a/tests/stdlib/a64l.c +++ b/tests/stdlib/a64l.c @@ -1,7 +1,7 @@ #include #include -int main(int argc, char* argv[]) { +int main(void) { char * s = "azAZ9."; // test boundaries long l = a64l(s); if (l != 194301926) { diff --git a/tests/stdlib/alloc.c b/tests/stdlib/alloc.c index bfb8673400..85d6c9c076 100644 --- a/tests/stdlib/alloc.c +++ b/tests/stdlib/alloc.c @@ -2,7 +2,7 @@ #include #include -int main(int argc, char ** argv) { +int main(void) { char * ptr = (char *)malloc(256); printf("malloc %p\n", ptr); int i; diff --git a/tests/stdlib/atof.c b/tests/stdlib/atof.c index 1bfb9d0e22..37f8d11299 100644 --- a/tests/stdlib/atof.c +++ b/tests/stdlib/atof.c @@ -1,7 +1,7 @@ #include #include -int main(int argc, char* argv[]) { +int main(void) { double d = atof("-3.14"); printf("%f\n", d); return 0; diff --git a/tests/stdlib/atoi.c b/tests/stdlib/atoi.c index e9af8da95e..8ce33962f0 100644 --- a/tests/stdlib/atoi.c +++ b/tests/stdlib/atoi.c @@ -1,7 +1,7 @@ #include #include -int main(int argc, char* argv[]) { +int main(void) { printf("%d\n", atoi(" -42")); printf("%d\n", atoi(" +555")); printf("%d\n", atoi(" 1234567890 ")); diff --git a/tests/stdlib/bsearch.c b/tests/stdlib/bsearch.c index c8e43c612b..9ccd1a7d47 100644 --- a/tests/stdlib/bsearch.c +++ b/tests/stdlib/bsearch.c @@ -19,7 +19,7 @@ int int_cmp(const void* a, const void* b) { -int main(int argc, char* argv[]) { +int main(void) { int x = 0; int y = 1024; diff --git a/tests/stdlib/div.c b/tests/stdlib/div.c index 22acb9176a..7752fb5d17 100644 --- a/tests/stdlib/div.c +++ b/tests/stdlib/div.c @@ -3,10 +3,9 @@ volatile long double ld; volatile unsigned long long ll; lldiv_t mydivt; -int -main () -{ -char* tmp; + +int main(void) { + char* tmp; f = strtof("gnu", &tmp); ld = strtold("gnu", &tmp); ll = strtoll("gnu", &tmp, 10); diff --git a/tests/stdlib/env.c b/tests/stdlib/env.c index e0a821c839..684e78bedf 100644 --- a/tests/stdlib/env.c +++ b/tests/stdlib/env.c @@ -2,7 +2,7 @@ #include #include -int main() { +int main(void) { //puts(getenv("SHELL")); //puts(getenv("CC")); diff --git a/tests/stdlib/mkostemps.c b/tests/stdlib/mkostemps.c index 2ada5d1f48..c3547f49c2 100644 --- a/tests/stdlib/mkostemps.c +++ b/tests/stdlib/mkostemps.c @@ -2,7 +2,7 @@ #include #include -int main(int argc, char** argv) { +int main(void) { char* file_name = (char*) calloc(18, sizeof(char)); strcpy(file_name, "tempXXXXXX.suffix"); int fd = mkostemps(file_name, 7, 0); diff --git a/tests/stdlib/mktemp.c b/tests/stdlib/mktemp.c index eaafe83480..e2394f6360 100644 --- a/tests/stdlib/mktemp.c +++ b/tests/stdlib/mktemp.c @@ -2,7 +2,7 @@ #include #include -int main(int argc, char** argv) { +int main(void) { char* string = (char*) calloc(20, sizeof(char)); strcpy(string, "tempXXXXXX"); mktemp(string); diff --git a/tests/stdlib/rand.c b/tests/stdlib/rand.c index 484b09906b..f3883c3fdb 100644 --- a/tests/stdlib/rand.c +++ b/tests/stdlib/rand.c @@ -1,7 +1,7 @@ #include #include -int main(int argc, char** argv) { +int main(void) { printf("%d\n", rand()); srand(259); printf("%d\n", rand()); diff --git a/tests/stdlib/realpath.c b/tests/stdlib/realpath.c index c6a679a4d5..918874ee23 100644 --- a/tests/stdlib/realpath.c +++ b/tests/stdlib/realpath.c @@ -4,7 +4,7 @@ #include #include -int main() { +int main(void) { char* path = realpath("stdlib/realpath.c", NULL); if (!path) { perror("realpath"); diff --git a/tests/stdlib/strtod.c b/tests/stdlib/strtod.c index 21a728050d..ae88af4db2 100644 --- a/tests/stdlib/strtod.c +++ b/tests/stdlib/strtod.c @@ -1,7 +1,7 @@ #include #include -int main() { +int main(void) { char* endptr = 0; double d; diff --git a/tests/stdlib/strtol.c b/tests/stdlib/strtol.c index c088e144b9..e98964ad59 100644 --- a/tests/stdlib/strtol.c +++ b/tests/stdlib/strtol.c @@ -2,7 +2,7 @@ #include #include -int main(int argc, char* argv[]) { +int main(void) { printf("%ld\n", strtol(" -42", NULL, 0)); printf("%ld\n", strtol(" +555", NULL, 0)); printf("%ld\n", strtol(" 1234567890 ", NULL, 0)); diff --git a/tests/stdlib/strtoul.c b/tests/stdlib/strtoul.c index 4431a720d2..2e7f368673 100644 --- a/tests/stdlib/strtoul.c +++ b/tests/stdlib/strtoul.c @@ -2,7 +2,7 @@ #include #include -int main(int argc, char* argv[]) { +int main(void) { printf("%ld\n", strtoul(" -42", NULL, 0)); printf("%ld\n", strtoul(" +555", NULL, 0)); printf("%ld\n", strtoul(" 1234567890 ", NULL, 0)); diff --git a/tests/stdlib/system.c b/tests/stdlib/system.c index 8c4cda187c..9acc8d6b33 100644 --- a/tests/stdlib/system.c +++ b/tests/stdlib/system.c @@ -1,6 +1,6 @@ #include -int main(int argc, char ** argv) { +int main(void) { system("echo test of system"); return 0; } diff --git a/tests/string/mem.c b/tests/string/mem.c index 121a8f5f3b..43424b8165 100644 --- a/tests/string/mem.c +++ b/tests/string/mem.c @@ -2,7 +2,7 @@ #include #include -int main(int argc, char ** argv) { +int main(void) { puts("# mem #"); char arr[100]; memset(arr, 0, 100); // Compiler builtin, should work diff --git a/tests/string/strcat.c b/tests/string/strcat.c index 6913c55757..2ccc932729 100644 --- a/tests/string/strcat.c +++ b/tests/string/strcat.c @@ -1,7 +1,7 @@ #include #include -int main(int argc, char* argv[]) { +int main(void) { char dest1[12] = "hello"; printf("%s\n", strcat(dest1, " world")); // should be hello world diff --git a/tests/string/strchr.c b/tests/string/strchr.c index 202737faac..7ef4452eef 100644 --- a/tests/string/strchr.c +++ b/tests/string/strchr.c @@ -1,7 +1,7 @@ #include #include -int main(int argc, char* argv[]) { +int main(void) { printf("%s\n", strchr("hello", 'e')); // should be ello printf("%s\n", strchr("world", 'l')); // should be ld printf("%i\n", strchr("world", 0) == NULL); // should be 1 diff --git a/tests/string/strcpy.c b/tests/string/strcpy.c index f0c7d79259..69159d738e 100644 --- a/tests/string/strcpy.c +++ b/tests/string/strcpy.c @@ -1,7 +1,7 @@ #include #include -int main() { +int main(void) { char dst[20]; strcpy(dst, "strcpy works!"); diff --git a/tests/string/strcspn.c b/tests/string/strcspn.c index 859d880435..b9a81c8b28 100644 --- a/tests/string/strcspn.c +++ b/tests/string/strcspn.c @@ -1,7 +1,7 @@ #include #include -int main(int argc, char* argv[]) { +int main(void) { char *world = "world"; printf("%ld\n", strcspn("hello", world)); // should be 2 printf("%ld\n", strcspn("banana", world)); // should be 6 diff --git a/tests/string/strncmp.c b/tests/string/strncmp.c index efb2bea978..122a1ca647 100644 --- a/tests/string/strncmp.c +++ b/tests/string/strncmp.c @@ -1,7 +1,7 @@ #include #include -int main(int argc, char* argv[]) { +int main(void) { printf("%d\n", strncmp("a", "aa", 2)); printf("%d\n", strncmp("a", "aä", 2)); printf("%d\n", strncmp("\xFF", "\xFE", 2)); diff --git a/tests/string/strpbrk.c b/tests/string/strpbrk.c index dc0ebf7c53..248ade9393 100644 --- a/tests/string/strpbrk.c +++ b/tests/string/strpbrk.c @@ -1,7 +1,7 @@ #include #include -int main(int argc, char* argv[]) { +int main(void) { char* source = "The quick drawn fix jumps over the lazy bug"; // should be "The quick drawn fix jumps over the lazy bug" diff --git a/tests/string/strrchr.c b/tests/string/strrchr.c index 7edc98040b..d999cacc42 100644 --- a/tests/string/strrchr.c +++ b/tests/string/strrchr.c @@ -1,8 +1,7 @@ #include #include - -int main(int argc, char* argv[]) { +int main(void) { char s0[] = "hello, world"; char* ptr = strrchr(s0, 'l'); if (ptr != &s0[10]) { diff --git a/tests/string/strspn.c b/tests/string/strspn.c index 52431a70ff..30caaaaf97 100644 --- a/tests/string/strspn.c +++ b/tests/string/strspn.c @@ -1,7 +1,7 @@ #include #include -int main(int argc, char* argv[]) { +int main(void) { char *hello = "hello"; char *world = "world"; char *banana = "banana"; diff --git a/tests/string/strstr.c b/tests/string/strstr.c index cc23f070fd..90c8f34975 100644 --- a/tests/string/strstr.c +++ b/tests/string/strstr.c @@ -1,7 +1,7 @@ #include #include -int main(int argc, char* argv[]) { +int main(void) { printf("%s\n", strstr("In relibc we trust", "rust")); printf("%s\n", strstr("In relibc we trust", "libc")); printf("%s\n", strstr("In relibc we trust", "bugs")); diff --git a/tests/string/strtok.c b/tests/string/strtok.c index 18436d9f7e..6333f5c3b8 100644 --- a/tests/string/strtok.c +++ b/tests/string/strtok.c @@ -1,7 +1,7 @@ #include #include -int main(int argc, char* argv[]) { +int main(void) { char source[] = "I'd just like to interject for a moment. What you're referring to as Linux, " "is in fact, GNU/Linux, or as I've recently taken to calling it, GNU plus Linux.\n"; diff --git a/tests/string/strtok_r.c b/tests/string/strtok_r.c index 6b3f501422..9238f0a185 100644 --- a/tests/string/strtok_r.c +++ b/tests/string/strtok_r.c @@ -1,7 +1,7 @@ #include #include -int main(int argc, char* argv[]) { +int main(void) { char source[] = "I'd just like to interject for a moment. What you're referring to as Linux, " "is in fact, GNU/Linux, or as I've recently taken to calling it, GNU plus Linux.\n"; char* sp; diff --git a/tests/strings.c b/tests/strings.c index fefb631a68..11cdb48feb 100644 --- a/tests/strings.c +++ b/tests/strings.c @@ -3,7 +3,7 @@ #include #include -int main() { +int main(void) { assert(!bcmp("hello", "hehe", 2)); assert(bcmp("hello", "haha", 2)); diff --git a/tests/sys_utsname/uname.c b/tests/sys_utsname/uname.c index 05ad034019..8e094df416 100644 --- a/tests/sys_utsname/uname.c +++ b/tests/sys_utsname/uname.c @@ -1,7 +1,7 @@ #include #include -int main() { +int main(void) { struct utsname system_info; int result = uname(&system_info); diff --git a/tests/time/asctime.c b/tests/time/asctime.c index a2a3db03ff..a76b032b23 100644 --- a/tests/time/asctime.c +++ b/tests/time/asctime.c @@ -3,7 +3,7 @@ #include #include -int main(int argc, char** argv) { +int main(void) { time_t a = 0; struct tm *time_info = gmtime(&a); diff --git a/tests/time/gettimeofday.c b/tests/time/gettimeofday.c index 7cd71d9aee..a17e2aedf5 100644 --- a/tests/time/gettimeofday.c +++ b/tests/time/gettimeofday.c @@ -1,7 +1,7 @@ #include #include -int main() { +int main(void) { struct timeval tv; gettimeofday(&tv, NULL); printf("%ld: %ld\n", tv.tv_sec, tv.tv_usec); diff --git a/tests/time/gmtime.c b/tests/time/gmtime.c index 836822db35..f8be76adce 100644 --- a/tests/time/gmtime.c +++ b/tests/time/gmtime.c @@ -3,7 +3,7 @@ #include #include -int main(int argc, char** argv) { +int main(void) { time_t a = 0; struct tm expected = { .tm_sec = 0, .tm_min = 0, .tm_hour = 0, .tm_mday = 1, .tm_year = 70, .tm_wday = 4, .tm_yday = 0, .tm_isdst = 0, .tm_gmtoff = 0, .tm_zone = "UTC" }; diff --git a/tests/time/localtime.c b/tests/time/localtime.c index 3792531b95..5f96b3ea23 100644 --- a/tests/time/localtime.c +++ b/tests/time/localtime.c @@ -1,7 +1,7 @@ #include #include -int main() { +int main(void) { int day = 60 * 60 * 24; time_t inputs[] = { -(day * 33), -day, -1, -500, 0, 1, 1531454950 }; for (int i = 0; i < (sizeof(inputs) / sizeof(time_t)); i += 1) { diff --git a/tests/time/macros.c b/tests/time/macros.c index b33f78b750..737dab831f 100644 --- a/tests/time/macros.c +++ b/tests/time/macros.c @@ -1,7 +1,7 @@ #include #include -int main() { +int main(void) { struct timeval x = { .tv_usec = 15 }; struct timeval y = { 0 }; struct timeval z = { 0 }; diff --git a/tests/time/mktime.c b/tests/time/mktime.c index c99102f673..94b96eb8c2 100644 --- a/tests/time/mktime.c +++ b/tests/time/mktime.c @@ -18,7 +18,8 @@ int check(time_t input) { } return 0; } -int main() { + +int main(void) { struct tm t = { 0 }; t.tm_year = 71; diff --git a/tests/time/strftime.c b/tests/time/strftime.c index 56ecc6f9e2..99da578bfd 100644 --- a/tests/time/strftime.c +++ b/tests/time/strftime.c @@ -8,7 +8,8 @@ void print(time_t timestamp, char* fmt) { printf("%zu: %s\n", n, out); free(out); } -int main() { + +int main(void) { print(1531808742, "%a %A %b %B"); print(1531808742, "The %Cst century"); print(1531808742, "%I:%M:%S %p"); diff --git a/tests/time/time.c b/tests/time/time.c index 3dc120b270..3fe2fc2322 100644 --- a/tests/time/time.c +++ b/tests/time/time.c @@ -1,7 +1,7 @@ #include #include -int main(int argc, char** argv) { +int main(void) { struct timespec tm = {0, 0}; int cgt = clock_gettime(CLOCK_REALTIME, &tm); diff --git a/tests/time/times.c b/tests/time/times.c index 975aae2dd0..91829b4cad 100644 --- a/tests/time/times.c +++ b/tests/time/times.c @@ -2,7 +2,7 @@ #include #include -int main() { +int main(void) { struct tms tms; printf("return: %ld\n", times(&tms)); diff --git a/tests/unistd/access.c b/tests/unistd/access.c index 9491aa5f5d..2ba3d01849 100644 --- a/tests/unistd/access.c +++ b/tests/unistd/access.c @@ -1,7 +1,7 @@ #include #include -int main() { +int main(void) { if (access("example_dir/1-never-gonna-give-you-up", R_OK | W_OK)) { perror("access"); return 1; diff --git a/tests/unistd/brk.c b/tests/unistd/brk.c index 138b0080f3..60d3ad0d14 100644 --- a/tests/unistd/brk.c +++ b/tests/unistd/brk.c @@ -1,7 +1,7 @@ #include #include -int main(int argc, char** argv) { +int main(void) { int status = brk((void*)100); printf("brk exited with status code %d\n", status); return 0; diff --git a/tests/unistd/chdir.c b/tests/unistd/chdir.c index be0e29018f..f0cd849af0 100644 --- a/tests/unistd/chdir.c +++ b/tests/unistd/chdir.c @@ -2,7 +2,7 @@ #include #include -int main(int argc, char** argv) { +int main(void) { char* cwd1 = malloc(4096*sizeof(char));//(char*) calloc(4096 + 1, sizeof(char)); getcwd(cwd1, 4096); printf("initial cwd: %s\n", cwd1); diff --git a/tests/unistd/dup.c b/tests/unistd/dup.c index 54bbb159b0..10a56ea882 100644 --- a/tests/unistd/dup.c +++ b/tests/unistd/dup.c @@ -2,7 +2,7 @@ #include #include -int main(int argc, char** argv) { +int main(void) { creat("dup.out", 0777); int fd1 = open("dup.out", 0); int fd2 = dup(fd1); diff --git a/tests/unistd/exec.c b/tests/unistd/exec.c index 732ed00aec..fd603471ef 100644 --- a/tests/unistd/exec.c +++ b/tests/unistd/exec.c @@ -1,7 +1,7 @@ #include #include -int main(int argc, char** argv) { +int main(void) { char* args[] = {"sh", "-c", "echo 'exec works :D'", NULL}; execv("/bin/sh", args); perror("execv"); diff --git a/tests/unistd/fchdir.c b/tests/unistd/fchdir.c index e89c5ef593..07256cf28c 100644 --- a/tests/unistd/fchdir.c +++ b/tests/unistd/fchdir.c @@ -2,7 +2,7 @@ #include #include -int main (int argc, char** argv) { +int main(void) { int fd = open("..", 0, 0); int status; status = fchdir(fd); diff --git a/tests/unistd/fsync.c b/tests/unistd/fsync.c index d9f42bd239..b7d2f76d58 100644 --- a/tests/unistd/fsync.c +++ b/tests/unistd/fsync.c @@ -2,7 +2,7 @@ #include #include -int main (int argc, char** argv) { +int main(void) { int fd = open(".", 0, 0); int status; status = fsync(fd); diff --git a/tests/unistd/ftruncate.c b/tests/unistd/ftruncate.c index 67f39f4c45..05634015c1 100644 --- a/tests/unistd/ftruncate.c +++ b/tests/unistd/ftruncate.c @@ -2,7 +2,7 @@ #include #include -int main (int argc, char** argv) { +int main(void) { int fd = creat("ftruncate.out", 0777); int status; status = ftruncate(fd, 100); diff --git a/tests/unistd/getcwd.c b/tests/unistd/getcwd.c index 0d8e5f108d..fd5bd60cc5 100644 --- a/tests/unistd/getcwd.c +++ b/tests/unistd/getcwd.c @@ -4,7 +4,7 @@ #include #include -int main() { +int main(void) { char first[PATH_MAX]; getcwd(first, PATH_MAX); puts(first); diff --git a/tests/unistd/gethostname.c b/tests/unistd/gethostname.c index 02a0b7a7d4..85119c32f5 100644 --- a/tests/unistd/gethostname.c +++ b/tests/unistd/gethostname.c @@ -2,7 +2,7 @@ #include #include -int main() { +int main(void) { char* hostname = malloc(256); if (gethostname(hostname, 256) == 0) { printf("Hostname: %s\n", hostname); diff --git a/tests/unistd/getid.c b/tests/unistd/getid.c index 774ffea260..b6a8507dc2 100644 --- a/tests/unistd/getid.c +++ b/tests/unistd/getid.c @@ -1,7 +1,7 @@ #include #include -int main(int argc, char** argv) { +int main(void) { gid_t egid = getegid(); uid_t euid = geteuid(); gid_t gid = getgid(); diff --git a/tests/unistd/isatty.c b/tests/unistd/isatty.c index 9647282aa6..33855fbaf9 100644 --- a/tests/unistd/isatty.c +++ b/tests/unistd/isatty.c @@ -1,7 +1,7 @@ #include #include -int main() { +int main(void) { // 1 is stdout if (isatty(1)) { puts("'Tis a tty :D"); diff --git a/tests/unistd/link.c b/tests/unistd/link.c index a39286106f..264c2dda5f 100644 --- a/tests/unistd/link.c +++ b/tests/unistd/link.c @@ -3,7 +3,7 @@ #include #include -int main(int argc, char** argv) { +int main(void) { printf("%ld\n", sizeof(struct stat)); struct stat buf; diff --git a/tests/unistd/pathconf.c b/tests/unistd/pathconf.c index f943ec56ef..77cb7d5466 100644 --- a/tests/unistd/pathconf.c +++ b/tests/unistd/pathconf.c @@ -7,7 +7,7 @@ printf("%s (%d): %ld (%d)\n", #N, _PC_ ## N, fpathconf(0, _PC_ ## N), errno); \ } -int main(){ +int main(void) { PC(LINK_MAX); PC(MAX_CANON); PC(MAX_INPUT); diff --git a/tests/unistd/pipe.c b/tests/unistd/pipe.c index 8f0fc71e5c..2e1edf2c9e 100644 --- a/tests/unistd/pipe.c +++ b/tests/unistd/pipe.c @@ -3,9 +3,7 @@ #include #include -int main() -{ - +int main(void) { int pid, pip[2]; char instring[20]; char * outstring = "Hello World!"; diff --git a/tests/unistd/rmdir.c b/tests/unistd/rmdir.c index 97aa50fe17..11a8bd646e 100644 --- a/tests/unistd/rmdir.c +++ b/tests/unistd/rmdir.c @@ -2,7 +2,7 @@ #include #include -int main(int argc, char** argv) { +int main(void) { mkdir("foo", 0); int status = rmdir("foo"); printf("rmdir exited with status code %d\n", status); diff --git a/tests/unistd/setid.c b/tests/unistd/setid.c index cf6abc6c67..78b01dda2e 100644 --- a/tests/unistd/setid.c +++ b/tests/unistd/setid.c @@ -6,8 +6,7 @@ #include #include -int main( void ) - { +int main(void) { if( setpgid( getpid(), 0 ) == -1 ) { perror( "setpgid" ); } @@ -24,4 +23,4 @@ int main( void ) } printf("%d has euid %d and uid %d\n", getpid(), geteuid(), getuid()); return 0; - } +} diff --git a/tests/unistd/sleep.c b/tests/unistd/sleep.c index cf395a7839..df69754dd2 100644 --- a/tests/unistd/sleep.c +++ b/tests/unistd/sleep.c @@ -2,7 +2,7 @@ #include #include -int main(int argc, char** argv) { +int main(void) { sleep(2); perror("sleep"); usleep(1000); diff --git a/tests/unistd/stat.c b/tests/unistd/stat.c index 5fd178530d..a0775bc535 100644 --- a/tests/unistd/stat.c +++ b/tests/unistd/stat.c @@ -3,7 +3,7 @@ #include #include -int main() { +int main(void) { printf("%ld\n", sizeof(struct stat)); struct stat buf; diff --git a/tests/unistd/sysconf.c b/tests/unistd/sysconf.c index aa4bf4882f..6e53ee3c40 100644 --- a/tests/unistd/sysconf.c +++ b/tests/unistd/sysconf.c @@ -7,7 +7,7 @@ printf("%s (%d): %ld (%d)\n", #N, _SC_ ## N, sysconf(_SC_ ## N), errno); \ } -int main(){ +int main(void) { SC(ARG_MAX); SC(CHILD_MAX); SC(CLK_TCK); diff --git a/tests/unistd/write.c b/tests/unistd/write.c index 5102aca427..bfc52a920b 100644 --- a/tests/unistd/write.c +++ b/tests/unistd/write.c @@ -1,6 +1,6 @@ #include -int main(int argc, char ** argv) { +int main(void) { write(STDOUT_FILENO, "Hello World!\n", 13); return 0; } diff --git a/tests/waitpid.c b/tests/waitpid.c index c350e33c6f..0a52eaa45a 100644 --- a/tests/waitpid.c +++ b/tests/waitpid.c @@ -2,7 +2,7 @@ #include #include -int main(int argc, char** argv) { +int main(void) { pid_t pid = fork(); if (pid == 0) { // child diff --git a/tests/wchar/mbrtowc.c b/tests/wchar/mbrtowc.c index 293926d7ed..f05f70313a 100644 --- a/tests/wchar/mbrtowc.c +++ b/tests/wchar/mbrtowc.c @@ -2,8 +2,7 @@ #include #include -int main(void) -{ +int main(void) { mbstate_t state; memset(&state, 0, sizeof state); char in[] = u8"z\u00df\u6c34\U0001F34C"; // or u8"zß水🍌" diff --git a/tests/wchar/mbsrtowcs.c b/tests/wchar/mbsrtowcs.c index 070cabc3cd..15dff0b7e8 100644 --- a/tests/wchar/mbsrtowcs.c +++ b/tests/wchar/mbsrtowcs.c @@ -17,8 +17,7 @@ void print_as_wide(const char* mbstr) //wprintf(L"The wide string: %ls \n", &wstr[0]); } -int main() -{ +int main(void) { const char* mbstr = u8"z\u00df\u6c34\U0001f34c"; // or u8"zß水🍌" print_as_wide(mbstr); } diff --git a/tests/wchar/putwchar.c b/tests/wchar/putwchar.c index 067c0a4107..a777854a53 100644 --- a/tests/wchar/putwchar.c +++ b/tests/wchar/putwchar.c @@ -3,8 +3,7 @@ #include #include -int main(void) -{ +int main(void) { wchar_t *wcs = L"zß水🍌"; int i; diff --git a/tests/wchar/wcrtomb.c b/tests/wchar/wcrtomb.c index 4bf5dc3574..233496ed37 100644 --- a/tests/wchar/wcrtomb.c +++ b/tests/wchar/wcrtomb.c @@ -2,9 +2,8 @@ #include #include #include - -int main( void ) -{ + +int main(void) { mbstate_t state; memset(&state, 0, sizeof state); wchar_t in[] = L"zß水🍌"; // or "z\u00df\u6c34\U0001F34C" From c19cc8b7310c868666f111759071fde1cbb08a0a Mon Sep 17 00:00:00 2001 From: Tibor Nagy Date: Wed, 20 Feb 2019 20:20:07 +0100 Subject: [PATCH 4/6] tests: Portability fixes, replaced 0/1/-1 return codes with macros --- tests/args.c | 3 ++- tests/dirent/main.c | 5 +++-- tests/dirent/scandir.c | 2 +- tests/error.c | 3 ++- tests/fcntl/create.c | 5 +++-- tests/fcntl/fcntl.c | 3 ++- tests/libgen.c | 2 +- tests/math.c | 3 ++- tests/netdb/getaddrinfo.c | 4 ++-- tests/pwd.c | 16 ++++++++-------- tests/regex.c | 5 +++-- tests/resource/getrusage.c | 2 +- tests/signal.c | 5 +++-- tests/stdio/all.c | 2 +- tests/stdio/fgets.c | 3 ++- tests/stdio/fputs.c | 2 +- tests/stdio/fread.c | 5 +++-- tests/stdio/freopen.c | 3 ++- tests/stdio/fseek.c | 3 ++- tests/stdio/fwrite.c | 8 ++++---- tests/stdio/getc_unget.c | 5 +++-- tests/stdio/mutex.c | 7 ++++--- tests/stdio/popen.c | 7 ++++--- tests/stdio/printf.c | 3 ++- tests/stdio/rename.c | 5 +++-- tests/stdio/setvbuf.c | 2 +- tests/stdio/sprintf.c | 5 +++-- tests/stdlib/a64l.c | 6 +++--- tests/stdlib/alloc.c | 2 +- tests/stdlib/atof.c | 2 +- tests/stdlib/atoi.c | 2 +- tests/stdlib/bsearch.c | 4 ++-- tests/stdlib/div.c | 2 +- tests/stdlib/env.c | 2 +- tests/stdlib/mkostemps.c | 2 +- tests/stdlib/mktemp.c | 2 +- tests/stdlib/realpath.c | 4 ++-- tests/stdlib/strtol.c | 2 +- tests/stdlib/strtoul.c | 2 +- tests/stdlib/system.c | 2 +- tests/string/mem.c | 14 +++++++------- tests/string/strcat.c | 3 ++- tests/string/strchr.c | 3 ++- tests/string/strcspn.c | 3 ++- tests/string/strncmp.c | 3 ++- tests/string/strpbrk.c | 3 ++- tests/string/strrchr.c | 7 ++++--- tests/string/strspn.c | 3 ++- tests/string/strstr.c | 3 ++- tests/string/strtok.c | 3 ++- tests/string/strtok_r.c | 3 ++- tests/time/asctime.c | 4 ++-- tests/time/gmtime.c | 6 +++--- tests/time/mktime.c | 6 +++--- tests/time/time.c | 9 +++++---- tests/unistd/access.c | 5 +++-- tests/unistd/brk.c | 3 ++- tests/unistd/chdir.c | 2 +- tests/unistd/dup.c | 3 ++- tests/unistd/exec.c | 3 ++- tests/unistd/fchdir.c | 3 ++- tests/unistd/fsync.c | 3 ++- tests/unistd/ftruncate.c | 3 ++- tests/unistd/getcwd.c | 2 +- tests/unistd/getid.c | 3 ++- tests/unistd/link.c | 9 +++++---- tests/unistd/pathconf.c | 3 ++- tests/unistd/pipe.c | 19 ++++++++++--------- tests/unistd/rmdir.c | 3 ++- tests/unistd/setid.c | 2 +- tests/unistd/sleep.c | 3 ++- tests/unistd/stat.c | 3 ++- tests/unistd/sysconf.c | 3 ++- tests/unistd/write.c | 3 ++- tests/waitpid.c | 4 ++-- tests/wchar/putwchar.c | 4 ++-- 76 files changed, 178 insertions(+), 133 deletions(-) diff --git a/tests/args.c b/tests/args.c index e05509c405..9f59c9012d 100644 --- a/tests/args.c +++ b/tests/args.c @@ -1,3 +1,4 @@ +#include #include #include @@ -8,5 +9,5 @@ int main(int argc, char *argv[]) { write(STDOUT_FILENO, " ", 1); } write(STDOUT_FILENO, "\n", 1); - return 0; + return EXIT_SUCCESS; } diff --git a/tests/dirent/main.c b/tests/dirent/main.c index 430626af70..aa574ba7d3 100644 --- a/tests/dirent/main.c +++ b/tests/dirent/main.c @@ -1,6 +1,7 @@ #include #include #include +#include int main(void) { printf("%lu\n", sizeof(struct dirent)); @@ -9,7 +10,7 @@ int main(void) { if (dir == NULL) { perror("opendir"); - return 1; + return EXIT_FAILURE; } struct dirent* entry; @@ -38,5 +39,5 @@ int main(void) { closedir(dir); - return 0; + return EXIT_SUCCESS; } diff --git a/tests/dirent/scandir.c b/tests/dirent/scandir.c index 2b2ea03c2b..8bbee0d13f 100644 --- a/tests/dirent/scandir.c +++ b/tests/dirent/scandir.c @@ -12,7 +12,7 @@ int main(void) { int len = scandir("example_dir/", &array, filter, alphasort); if (len < 0) { perror("scandir"); - return -1; + return EXIT_FAILURE; } for(int i = 0; i < len; i += 1) { diff --git a/tests/error.c b/tests/error.c index ac84c343b8..3bfd5217ff 100644 --- a/tests/error.c +++ b/tests/error.c @@ -1,5 +1,6 @@ #include #include +#include #include #include @@ -7,5 +8,5 @@ int main(void) { chdir("nonexistent"); printf("errno: %d = %s\n", errno, strerror(errno)); perror("perror"); - return 0; + return EXIT_SUCCESS; } diff --git a/tests/fcntl/create.c b/tests/fcntl/create.c index 8e70cb6c60..c881270c2f 100644 --- a/tests/fcntl/create.c +++ b/tests/fcntl/create.c @@ -1,4 +1,5 @@ #include +#include #include int main(void) { @@ -6,9 +7,9 @@ int main(void) { if (fd >= 0) { write(fd, "Hello World!\n", 13); close(fd); - return 0; + return EXIT_SUCCESS; } else { write(STDERR_FILENO, "creat failed\n", 13); - return 1; + return EXIT_FAILURE; } } diff --git a/tests/fcntl/fcntl.c b/tests/fcntl/fcntl.c index 474e163f56..d6f85a9a46 100644 --- a/tests/fcntl/fcntl.c +++ b/tests/fcntl/fcntl.c @@ -1,5 +1,6 @@ #include #include +#include #include int main(void) { @@ -10,5 +11,5 @@ int main(void) { printf("fd %d duped into fd %d\n", newfd, newfd2); close(newfd); close(newfd2); - return 0; + return EXIT_SUCCESS; } diff --git a/tests/libgen.c b/tests/libgen.c index fd79f5b9d6..4feee89bf0 100644 --- a/tests/libgen.c +++ b/tests/libgen.c @@ -77,5 +77,5 @@ int main(void) { printf("Testing libgen.h\n"); test_basename(); test_dirname(); - return 0; + return EXIT_SUCCESS; } diff --git a/tests/math.c b/tests/math.c index 014529f468..b061097755 100644 --- a/tests/math.c +++ b/tests/math.c @@ -1,9 +1,10 @@ #include #include +#include int main(void) { double pi = 3.14; float c = cos(pi); printf("cos(%f) = %f\n", pi, c); - return 0; + return EXIT_SUCCESS; } diff --git a/tests/netdb/getaddrinfo.c b/tests/netdb/getaddrinfo.c index 3864d0d990..efe4c5dfec 100644 --- a/tests/netdb/getaddrinfo.c +++ b/tests/netdb/getaddrinfo.c @@ -22,7 +22,7 @@ int main(void) { errcode = getaddrinfo("www.redox-os.org", NULL, &hints, &res); if (errcode != 0) { perror("getaddrinfo"); - return -1; + return EXIT_FAILURE; } while (res) { @@ -46,5 +46,5 @@ int main(void) { res = res->ai_next; } - return 0; + return EXIT_SUCCESS; } diff --git a/tests/pwd.c b/tests/pwd.c index 77087425ef..029972c7b7 100644 --- a/tests/pwd.c +++ b/tests/pwd.c @@ -19,7 +19,7 @@ int main(void) { struct passwd *pwd = getpwuid(0); if (errno != 0) { perror("getpwuid"); - return 1; + return EXIT_FAILURE; } if (pwd != NULL) { print(pwd); @@ -30,7 +30,7 @@ int main(void) { pwd = getpwnam("nobody"); if (errno != 0) { perror("getpwnam"); - return 1; + return EXIT_FAILURE; } if (pwd != NULL) { print(pwd); @@ -43,12 +43,12 @@ int main(void) { if (getpwuid_r(0, &pwd2, buf, 100, &result) < 0) { perror("getpwuid_r"); free(buf); - return 1; + return EXIT_FAILURE; } if (result != NULL) { if (result != &pwd2) { free(buf); - return 1; + return EXIT_FAILURE; } print(&pwd2); } @@ -57,12 +57,12 @@ int main(void) { if (getpwnam_r("nobody", &pwd2, buf, 100, &result) < 0) { perror("getpwuid_r"); free(buf); - return 1; + return EXIT_FAILURE; } if (result != NULL) { if (result != &pwd2) { free(buf); - return 1; + return EXIT_FAILURE; } print(&pwd2); } @@ -72,11 +72,11 @@ int main(void) { char buf2[1]; if (getpwuid_r(0, &pwd2, buf2, 1, &result) == 0) { puts("This shouldn't have succeeded, but did!"); - return 1; + return EXIT_FAILURE; } if (errno != ERANGE) { perror("getpwuid_r"); - return 1; + return EXIT_FAILURE; } puts("Returned ERANGE because the buffer was too small 👍"); } diff --git a/tests/regex.c b/tests/regex.c index b74a0f2ce6..e920b601d3 100644 --- a/tests/regex.c +++ b/tests/regex.c @@ -1,5 +1,6 @@ #include #include +#include int main(void) { regex_t regex; @@ -10,7 +11,7 @@ int main(void) { regerror(error, ®ex, error_buf, 255); error_buf[255] = 0; printf("regcomp error: %d = %s\n", error, error_buf); - return -1; + return EXIT_FAILURE; } regmatch_t matches[3] = {{0}}; @@ -22,7 +23,7 @@ int main(void) { if (error) { regerror(error, ®ex, error_buf, 255); printf("regexec error: %d = %s\n", error, error_buf); - return -1; + return EXIT_FAILURE; } for (int group = 0; group < 3; group += 1) { diff --git a/tests/resource/getrusage.c b/tests/resource/getrusage.c index e04a623910..1650dd6fc5 100644 --- a/tests/resource/getrusage.c +++ b/tests/resource/getrusage.c @@ -10,7 +10,7 @@ int main(void) { struct rusage r_usage; if (getrusage(RUSAGE_SELF, &r_usage) < 0) { perror("getrusage"); - return 1; + return EXIT_FAILURE; } printf("ru_utime:"); ptimeval(&r_usage.ru_utime); diff --git a/tests/signal.c b/tests/signal.c index aa9a563e01..1a48004507 100644 --- a/tests/signal.c +++ b/tests/signal.c @@ -1,5 +1,6 @@ #include #include +#include #include #include @@ -11,14 +12,14 @@ int main(void) { if (signal(SIGUSR1, &handler) == SIG_ERR) { puts("Signal error!"); printf("%d\n", errno); - return 1; + return EXIT_FAILURE; } puts("Raising..."); if (raise(SIGUSR1)) { puts("Raise error!"); printf("%d\n", errno); - return 1; + return EXIT_FAILURE; } puts("Raised."); } diff --git a/tests/stdio/all.c b/tests/stdio/all.c index c049e3eb0e..33a5f905b1 100644 --- a/tests/stdio/all.c +++ b/tests/stdio/all.c @@ -9,5 +9,5 @@ int main(void) { printf("%s\n", fgets(in, 30, f)); setvbuf(stdout, 0, _IONBF, 0); printf("Hello\n"); - return 0; + return EXIT_SUCCESS; } diff --git a/tests/stdio/fgets.c b/tests/stdio/fgets.c index 404002a8b2..e48247b98f 100644 --- a/tests/stdio/fgets.c +++ b/tests/stdio/fgets.c @@ -1,4 +1,5 @@ #include +#include int main(void) { //FILE *f = fopen("/etc/ssl/certs/ca-certificates.crt", "r"); @@ -12,7 +13,7 @@ int main(void) { puts("EOF"); if (!feof(f)) { puts("feof() not updated!"); - return -1; + return EXIT_FAILURE; } break; } diff --git a/tests/stdio/fputs.c b/tests/stdio/fputs.c index 2ce599203c..74424b20ee 100644 --- a/tests/stdio/fputs.c +++ b/tests/stdio/fputs.c @@ -7,5 +7,5 @@ int main(void) { char *in = "Hello World!"; fputs(in, f); // calls fwrite, helpers::fwritex, internal::to_write and internal::stdio_write fclose(f); - return 0; + return EXIT_SUCCESS; } diff --git a/tests/stdio/fread.c b/tests/stdio/fread.c index f87e9172b1..6e95bc7291 100644 --- a/tests/stdio/fread.c +++ b/tests/stdio/fread.c @@ -1,5 +1,6 @@ #include #include +#include int main(void) { FILE *fp = fopen("stdio/fread.in", "rb"); @@ -8,7 +9,7 @@ int main(void) { for (int i = 1; i <= 32; ++i) { if (fread(buf, 1, i, fp) < 0) { perror("fread"); - return 0; + return EXIT_FAILURE; } buf[i] = 0; @@ -17,5 +18,5 @@ int main(void) { fclose(fp); - return 0; + return EXIT_SUCCESS; } diff --git a/tests/stdio/freopen.c b/tests/stdio/freopen.c index 3189b7e64d..b68a858383 100644 --- a/tests/stdio/freopen.c +++ b/tests/stdio/freopen.c @@ -1,9 +1,10 @@ #include +#include int main(void) { freopen("stdio/stdio.in", "r", stdin); char in[6]; fgets(in, 6, stdin); printf("%s\n", in); // should print Hello - return 0; + return EXIT_SUCCESS; } diff --git a/tests/stdio/fseek.c b/tests/stdio/fseek.c index eed59eca0c..6f166928f3 100644 --- a/tests/stdio/fseek.c +++ b/tests/stdio/fseek.c @@ -1,10 +1,11 @@ #include +#include int main(void) { FILE *f = fopen("stdio/stdio.in", "r"); if (fseek(f, 14, SEEK_CUR) < 0) { puts("fseek error"); - return 1; + return EXIT_FAILURE; } char buffer[256]; printf("%s", fgets(buffer, 256, f)); diff --git a/tests/stdio/fwrite.c b/tests/stdio/fwrite.c index 37df8a75c9..93f412413c 100644 --- a/tests/stdio/fwrite.c +++ b/tests/stdio/fwrite.c @@ -7,18 +7,18 @@ int main(void) { const char ptr[] = "Hello World!"; if (fwrite(ptr, 0, 17, f)) { - return -1; + return EXIT_FAILURE; } if (fwrite(ptr, 7, 0, f)) { - return -1; + return EXIT_FAILURE; } if (fwrite(ptr, 0, 0, f)) { - return -1; + return EXIT_FAILURE; } fwrite(ptr, sizeof(ptr), 1, f); fclose(f); - return 0; + return EXIT_SUCCESS; } diff --git a/tests/stdio/getc_unget.c b/tests/stdio/getc_unget.c index 257170a04b..55eb6bbb3e 100644 --- a/tests/stdio/getc_unget.c +++ b/tests/stdio/getc_unget.c @@ -1,12 +1,13 @@ #include +#include int main(void) { ungetc('h', stdin); char c; if ((c = getchar()) == 'h') { printf("Worked!\n"); - return 0; + return EXIT_SUCCESS; } printf("failed :( %c\n", c); - return 0; + return EXIT_FAILURE; } diff --git a/tests/stdio/mutex.c b/tests/stdio/mutex.c index 04f7b386c9..d318ea3e2b 100644 --- a/tests/stdio/mutex.c +++ b/tests/stdio/mutex.c @@ -1,4 +1,5 @@ #include +#include int main(void) { FILE* f = fopen("stdio/stdio.in", "r"); @@ -10,17 +11,17 @@ int main(void) { if (!ftrylockfile(f)) { puts("Mutex unlocked but it shouldn't be"); - return -1; + return EXIT_FAILURE; } funlockfile(f); if (ftrylockfile(f)) { puts("Mutex locked but it shouldn't be"); - return -1; + return EXIT_FAILURE; } if (!ftrylockfile(f)) { puts("Mutex unlocked but it shouldn't be"); - return -1; + return EXIT_FAILURE; } funlockfile(f); } diff --git a/tests/stdio/popen.c b/tests/stdio/popen.c index 364b3753b5..89f1d9a097 100644 --- a/tests/stdio/popen.c +++ b/tests/stdio/popen.c @@ -1,4 +1,5 @@ #include +#include int main(void) { FILE *fp; @@ -9,7 +10,7 @@ int main(void) { fp = popen("ls -1 example_dir", "r"); if (fp == NULL) { perror("popen"); - return -1; + return EXIT_FAILURE; } while (fgets(path, 256, fp) != NULL) { @@ -20,10 +21,10 @@ int main(void) { status = pclose(fp); if (status == -1) { perror("pclose"); - return -1; + return EXIT_FAILURE; } else { printf("status %x\n", status); } - return 0; + return EXIT_SUCCESS; } diff --git a/tests/stdio/printf.c b/tests/stdio/printf.c index 833b39c84c..ebe84e79d0 100644 --- a/tests/stdio/printf.c +++ b/tests/stdio/printf.c @@ -1,4 +1,5 @@ #include +#include int main(void) { int sofar = 0; @@ -48,5 +49,5 @@ int main(void) { printf("%G\n", 0.0001); printf("%G\n", 0.00001); printf("%E\n", 0.00001); - return 0; + return EXIT_SUCCESS; } diff --git a/tests/stdio/rename.c b/tests/stdio/rename.c index 537b2dc6a4..df88c5f54f 100644 --- a/tests/stdio/rename.c +++ b/tests/stdio/rename.c @@ -1,5 +1,6 @@ #include #include +#include #include #include @@ -20,8 +21,8 @@ int main(void) { close(fd); remove(newpath); if (strcmp(str, buf) == 0) { - return 0; + return EXIT_SUCCESS; } else { - return -1; + return EXIT_FAILURE; } } diff --git a/tests/stdio/setvbuf.c b/tests/stdio/setvbuf.c index 46191f53cd..8d38913cf2 100644 --- a/tests/stdio/setvbuf.c +++ b/tests/stdio/setvbuf.c @@ -10,5 +10,5 @@ int main(void) { char *in = malloc(30); printf("%s\n", fgets(in, 30, f)); printf("Hello\n"); - return 0; + return EXIT_SUCCESS; } diff --git a/tests/stdio/sprintf.c b/tests/stdio/sprintf.c index 3205473e3b..829ce59989 100644 --- a/tests/stdio/sprintf.c +++ b/tests/stdio/sprintf.c @@ -1,4 +1,5 @@ #include +#include #include int main(void) { @@ -11,7 +12,7 @@ int main(void) { ); if (ret != 68) { printf("Failed! Return value was %d\n", ret); - return -1; + return EXIT_FAILURE; } memset(buffer, 0, sizeof(buffer)); @@ -24,7 +25,7 @@ int main(void) { ); if (ret != 86) { printf("Failed! Return value was %d\n", ret); - return -1; + return EXIT_FAILURE; } puts(buffer); diff --git a/tests/stdlib/a64l.c b/tests/stdlib/a64l.c index 14d44a9f83..0ffb73effc 100644 --- a/tests/stdlib/a64l.c +++ b/tests/stdlib/a64l.c @@ -6,7 +6,7 @@ int main(void) { long l = a64l(s); if (l != 194301926) { printf("Invalid result: a64l(%s) = %ld\n", s, l); - return 1; + return EXIT_FAILURE; } printf("Correct a64l: %s = %ld\n", s, l); @@ -15,8 +15,8 @@ int main(void) { l = a64l(s); if (l != 53222) { printf("Invalid result: a64l(%s) = %ld\n", s, l); - return 1; + return EXIT_FAILURE; } printf("Correct a64l: %s = %ld\n", s, l); - return 0; + return EXIT_SUCCESS; } diff --git a/tests/stdlib/alloc.c b/tests/stdlib/alloc.c index 85d6c9c076..4e0b72de3d 100644 --- a/tests/stdlib/alloc.c +++ b/tests/stdlib/alloc.c @@ -25,5 +25,5 @@ int main(void) { } free(ptra); - return 0; + return EXIT_SUCCESS; } diff --git a/tests/stdlib/atof.c b/tests/stdlib/atof.c index 37f8d11299..f686bd12c2 100644 --- a/tests/stdlib/atof.c +++ b/tests/stdlib/atof.c @@ -4,5 +4,5 @@ int main(void) { double d = atof("-3.14"); printf("%f\n", d); - return 0; + return EXIT_SUCCESS; } diff --git a/tests/stdlib/atoi.c b/tests/stdlib/atoi.c index 8ce33962f0..2960697f02 100644 --- a/tests/stdlib/atoi.c +++ b/tests/stdlib/atoi.c @@ -8,5 +8,5 @@ int main(void) { printf("%ld\n", atol(" -42")); printf("%ld\n", atol(" +555")); printf("%ld\n", atol(" 1234567890 ")); - return 0; + return EXIT_SUCCESS; } diff --git a/tests/stdlib/bsearch.c b/tests/stdlib/bsearch.c index 9ccd1a7d47..834e56e2cd 100644 --- a/tests/stdlib/bsearch.c +++ b/tests/stdlib/bsearch.c @@ -13,7 +13,7 @@ int int_cmp(const void* a, const void* b) { size_t i = 0; \ for (; i < len; ++i) printf("%d,", arr[i]); \ printf("] expected %p but got %p\n", (void*) expect, res); \ - return 1; \ + return EXIT_FAILURE; \ } \ } while (0); @@ -53,5 +53,5 @@ int main(void) { BSEARCH_TEST_INT(x, big, 7, NULL); printf("PASS bsearch\n"); - return 0; + return EXIT_SUCCESS; } diff --git a/tests/stdlib/div.c b/tests/stdlib/div.c index 7752fb5d17..9939f07b47 100644 --- a/tests/stdlib/div.c +++ b/tests/stdlib/div.c @@ -18,6 +18,6 @@ int main(void) { _Exit(0); ; - return 0; + return EXIT_SUCCESS; } diff --git a/tests/stdlib/env.c b/tests/stdlib/env.c index 684e78bedf..83cd0b44fc 100644 --- a/tests/stdlib/env.c +++ b/tests/stdlib/env.c @@ -34,7 +34,7 @@ int main(void) { if (env) { puts("This should be null, but isn't"); puts(env); - return 1; + return EXIT_FAILURE; } else { puts("Value deleted successfully!"); } diff --git a/tests/stdlib/mkostemps.c b/tests/stdlib/mkostemps.c index c3547f49c2..5af996f6b3 100644 --- a/tests/stdlib/mkostemps.c +++ b/tests/stdlib/mkostemps.c @@ -23,5 +23,5 @@ int main(void) { } fclose(fp); remove(file_name); - return 0; + return EXIT_SUCCESS; } diff --git a/tests/stdlib/mktemp.c b/tests/stdlib/mktemp.c index e2394f6360..02c2e72e26 100644 --- a/tests/stdlib/mktemp.c +++ b/tests/stdlib/mktemp.c @@ -8,5 +8,5 @@ int main(void) { mktemp(string); printf("%s\n",string); free(string); - return 0; + return EXIT_SUCCESS; } diff --git a/tests/stdlib/realpath.c b/tests/stdlib/realpath.c index 918874ee23..5bcea42717 100644 --- a/tests/stdlib/realpath.c +++ b/tests/stdlib/realpath.c @@ -8,7 +8,7 @@ int main(void) { char* path = realpath("stdlib/realpath.c", NULL); if (!path) { perror("realpath"); - return -1; + return EXIT_FAILURE; } puts(path); @@ -21,7 +21,7 @@ int main(void) { if (!path) { perror("realpath"); free(path); - return -1; + return EXIT_FAILURE; } puts(path); diff --git a/tests/stdlib/strtol.c b/tests/stdlib/strtol.c index e98964ad59..283a622c05 100644 --- a/tests/stdlib/strtol.c +++ b/tests/stdlib/strtol.c @@ -27,5 +27,5 @@ int main(void) { printf("errno is not 0 (%d), something went wrong\n", errno); } - return 0; + return EXIT_SUCCESS; } diff --git a/tests/stdlib/strtoul.c b/tests/stdlib/strtoul.c index 2e7f368673..d33ca9b7f8 100644 --- a/tests/stdlib/strtoul.c +++ b/tests/stdlib/strtoul.c @@ -26,5 +26,5 @@ int main(void) { printf("errno is not 0 (%d), something went wrong\n", errno); } - return 0; + return EXIT_SUCCESS; } diff --git a/tests/stdlib/system.c b/tests/stdlib/system.c index 9acc8d6b33..9b3270eb79 100644 --- a/tests/stdlib/system.c +++ b/tests/stdlib/system.c @@ -2,5 +2,5 @@ int main(void) { system("echo test of system"); - return 0; + return EXIT_SUCCESS; } diff --git a/tests/string/mem.c b/tests/string/mem.c index 43424b8165..9c8db1e8c0 100644 --- a/tests/string/mem.c +++ b/tests/string/mem.c @@ -9,7 +9,7 @@ int main(void) { arr[50] = 1; if ((size_t)memchr((void *)arr, 1, 100) - (size_t)arr != 50) { puts("Incorrect memchr"); - exit(1); + return EXIT_FAILURE; } puts("Correct memchr"); char arr2[51]; @@ -17,26 +17,26 @@ int main(void) { memccpy((void *)arr2, (void *)arr, 1, 100); if (arr[50] != 1) { puts("Incorrect memccpy"); - exit(1); + return EXIT_FAILURE; } puts("Correct memccpy"); int res; if ((res = memcmp("hello world", "hello world", 11))) { printf("Incorrect memcmp (1), expected 0 found %d\n", res); - exit(1); + return EXIT_FAILURE; } if ((res = memcmp("hello world", "hello worlt", 11)) >= 0) { printf("Incorrect memcmp (2), expected -, found %d\n", res); - exit(1); + return EXIT_FAILURE; } if ((res = memcmp("hello world", "hallo world", 5)) <= 0) { printf("Incorrect memcmp (3), expected +, found %d\n", res); - exit(1); + return EXIT_FAILURE; } if ((res = memcmp("hello world", "henlo world", 5)) >= 0) { printf("Incorrect memcmp (4), expected -, found %d\n", res); - exit(1); + return EXIT_FAILURE; } puts("Correct memcmp"); - return 0; + return EXIT_SUCCESS; } diff --git a/tests/string/strcat.c b/tests/string/strcat.c index 2ccc932729..cb58004d1d 100644 --- a/tests/string/strcat.c +++ b/tests/string/strcat.c @@ -1,5 +1,6 @@ #include #include +#include int main(void) { char dest1[12] = "hello"; @@ -8,5 +9,5 @@ int main(void) { char dest2[12] = "hello"; printf("%s\n", strncat(dest2, " world foobar", 6)); // should be hello world - return 0; + return EXIT_SUCCESS; } diff --git a/tests/string/strchr.c b/tests/string/strchr.c index 7ef4452eef..3273d88a73 100644 --- a/tests/string/strchr.c +++ b/tests/string/strchr.c @@ -1,10 +1,11 @@ #include #include +#include int main(void) { printf("%s\n", strchr("hello", 'e')); // should be ello printf("%s\n", strchr("world", 'l')); // should be ld printf("%i\n", strchr("world", 0) == NULL); // should be 1 - return 0; + return EXIT_SUCCESS; } diff --git a/tests/string/strcspn.c b/tests/string/strcspn.c index b9a81c8b28..8511b95cb9 100644 --- a/tests/string/strcspn.c +++ b/tests/string/strcspn.c @@ -1,10 +1,11 @@ #include #include +#include int main(void) { char *world = "world"; printf("%ld\n", strcspn("hello", world)); // should be 2 printf("%ld\n", strcspn("banana", world)); // should be 6 - return 0; + return EXIT_SUCCESS; } diff --git a/tests/string/strncmp.c b/tests/string/strncmp.c index 122a1ca647..913200be7c 100644 --- a/tests/string/strncmp.c +++ b/tests/string/strncmp.c @@ -1,5 +1,6 @@ #include #include +#include int main(void) { printf("%d\n", strncmp("a", "aa", 2)); @@ -9,5 +10,5 @@ int main(void) { printf("%d\n", strncmp("a", "c", 1)); printf("%d\n", strncmp("a", "a", 2)); - return 0; + return EXIT_SUCCESS; } diff --git a/tests/string/strpbrk.c b/tests/string/strpbrk.c index 248ade9393..d61de16956 100644 --- a/tests/string/strpbrk.c +++ b/tests/string/strpbrk.c @@ -1,5 +1,6 @@ #include #include +#include int main(void) { char* source = "The quick drawn fix jumps over the lazy bug"; @@ -16,5 +17,5 @@ int main(void) { char* res3 = strpbrk(source, "404"); printf("%s\n", (res3) ? res3 : "NULL"); - return 0; + return EXIT_SUCCESS; } diff --git a/tests/string/strrchr.c b/tests/string/strrchr.c index d999cacc42..c8d2f65ad5 100644 --- a/tests/string/strrchr.c +++ b/tests/string/strrchr.c @@ -1,5 +1,6 @@ #include #include +#include int main(void) { char s0[] = "hello, world"; @@ -7,15 +8,15 @@ int main(void) { if (ptr != &s0[10]) { printf("%p != %p\n", ptr, &s0[10]); printf("strrchr FAIL , exit with status code %d\n", 1); - return 1; + return EXIT_FAILURE; } char s1[] = ""; ptr = strrchr(s1, 'a'); if (ptr != NULL) { printf("%p != 0\n", ptr); printf("strrchr FAIL, exit with status code %d\n", 1); - return 1; + return EXIT_FAILURE; } printf("strrch PASS, exiting with status code %d\n", 0); - return 0; + return EXIT_SUCCESS; } diff --git a/tests/string/strspn.c b/tests/string/strspn.c index 30caaaaf97..cd9316fad7 100644 --- a/tests/string/strspn.c +++ b/tests/string/strspn.c @@ -1,5 +1,6 @@ #include #include +#include int main(void) { char *hello = "hello"; @@ -9,5 +10,5 @@ int main(void) { printf("%lu\n", strspn(world, "wendy")); // should be 1 printf("%lu\n", strspn(banana, "apple")); // should be 0 - return 0; + return EXIT_SUCCESS; } diff --git a/tests/string/strstr.c b/tests/string/strstr.c index 90c8f34975..1e9f38cf97 100644 --- a/tests/string/strstr.c +++ b/tests/string/strstr.c @@ -1,5 +1,6 @@ #include #include +#include int main(void) { printf("%s\n", strstr("In relibc we trust", "rust")); @@ -8,5 +9,5 @@ int main(void) { printf("%s\n", strstr("IN RELIBC WE TRUST", "rust")); printf("%s\n", strcasestr("IN RELIBC WE TRUST", "rust")); - return 0; + return EXIT_SUCCESS; } diff --git a/tests/string/strtok.c b/tests/string/strtok.c index 6333f5c3b8..cfa716fe7f 100644 --- a/tests/string/strtok.c +++ b/tests/string/strtok.c @@ -1,5 +1,6 @@ #include #include +#include int main(void) { char source[] = "I'd just like to interject for a moment. What you're referring to as Linux, " @@ -13,5 +14,5 @@ int main(void) { } } - return 0; + return EXIT_SUCCESS; } diff --git a/tests/string/strtok_r.c b/tests/string/strtok_r.c index 9238f0a185..2abe530b0e 100644 --- a/tests/string/strtok_r.c +++ b/tests/string/strtok_r.c @@ -1,5 +1,6 @@ #include #include +#include int main(void) { char source[] = "I'd just like to interject for a moment. What you're referring to as Linux, " @@ -14,5 +15,5 @@ int main(void) { } } - return 0; + return EXIT_SUCCESS; } diff --git a/tests/time/asctime.c b/tests/time/asctime.c index a76b032b23..2624ec9b7b 100644 --- a/tests/time/asctime.c +++ b/tests/time/asctime.c @@ -10,7 +10,7 @@ int main(void) { char *time_string = asctime(time_info); if (time_string == NULL || strcmp(time_string, "Thu Jan 1 00:00:00 1970\n") != 0) { - exit(1); + return EXIT_FAILURE; } - return 0; + return EXIT_SUCCESS; } diff --git a/tests/time/gmtime.c b/tests/time/gmtime.c index f8be76adce..38d0b8d347 100644 --- a/tests/time/gmtime.c +++ b/tests/time/gmtime.c @@ -14,7 +14,7 @@ int main(void) { info->tm_year != expected.tm_year || info->tm_wday != expected.tm_wday || info->tm_yday != expected.tm_yday || info->tm_isdst != expected.tm_isdst || info->tm_gmtoff != expected.tm_gmtoff || strcmp(info->tm_zone, expected.tm_zone) != 0) { - exit(1); + return EXIT_FAILURE; } if (info->tm_sec != expected.tm_sec || info->tm_min != expected.tm_min || @@ -22,7 +22,7 @@ int main(void) { info->tm_year != expected.tm_year || info->tm_wday != expected.tm_wday || info->tm_yday != expected.tm_yday || info->tm_isdst != expected.tm_isdst || info->tm_gmtoff != expected.tm_gmtoff || strcmp(info->tm_zone, expected.tm_zone) != 0) { - exit(1); + return EXIT_FAILURE; } - return 0; + return EXIT_SUCCESS; } diff --git a/tests/time/mktime.c b/tests/time/mktime.c index 94b96eb8c2..eba83363c0 100644 --- a/tests/time/mktime.c +++ b/tests/time/mktime.c @@ -14,9 +14,9 @@ int check(time_t input) { t->tm_year, t->tm_yday, t->tm_mon, t->tm_mday, t->tm_wday, t->tm_hour, t->tm_min, t->tm_sec ); puts("Failed!"); - return -1; + return EXIT_FAILURE; } - return 0; + return EXIT_SUCCESS; } int main(void) { @@ -31,7 +31,7 @@ int main(void) { time_t inputs[] = { -(day * 33), -day, -500, 0, 1531454950 }; for (int i = 0; i < 5; i += 1) { if (check(inputs[i])) { - return -1; + return EXIT_FAILURE; } } diff --git a/tests/time/time.c b/tests/time/time.c index 3fe2fc2322..3c5aed66b7 100644 --- a/tests/time/time.c +++ b/tests/time/time.c @@ -1,5 +1,6 @@ #include #include +#include int main(void) { struct timespec tm = {0, 0}; @@ -7,20 +8,20 @@ int main(void) { int cgt = clock_gettime(CLOCK_REALTIME, &tm); if (cgt == -1) { perror("clock_gettime"); - return 1; + return EXIT_FAILURE; } time_t t = time(NULL); if (t == (time_t)-1) { perror("time"); - return 1; + return EXIT_FAILURE; } clock_t c = clock(); if (c == (clock_t)-1) { perror("clock"); - return 1; + return EXIT_FAILURE; } - return 0; + return EXIT_SUCCESS; } diff --git a/tests/unistd/access.c b/tests/unistd/access.c index 2ba3d01849..9de843b6d1 100644 --- a/tests/unistd/access.c +++ b/tests/unistd/access.c @@ -1,14 +1,15 @@ #include #include +#include int main(void) { if (access("example_dir/1-never-gonna-give-you-up", R_OK | W_OK)) { perror("access"); - return 1; + return EXIT_FAILURE; } if (!access("example_dir/1-never-gonna-give-you-up", X_OK)) { puts("Accessing a file with X_OK worked even though it... probably... shouldn't?"); puts("Please run `chmod 644 example_dir/*` and try again."); - return 1; + return EXIT_FAILURE; } } diff --git a/tests/unistd/brk.c b/tests/unistd/brk.c index 60d3ad0d14..5b4ffc1418 100644 --- a/tests/unistd/brk.c +++ b/tests/unistd/brk.c @@ -1,8 +1,9 @@ #include #include +#include int main(void) { int status = brk((void*)100); printf("brk exited with status code %d\n", status); - return 0; + return EXIT_SUCCESS; } diff --git a/tests/unistd/chdir.c b/tests/unistd/chdir.c index f0cd849af0..eb8341eeb5 100644 --- a/tests/unistd/chdir.c +++ b/tests/unistd/chdir.c @@ -12,5 +12,5 @@ int main(void) { getcwd(cwd2, 4096); printf("final cwd: %s\n", cwd2); free(cwd2); - return 0; + return EXIT_SUCCESS; } diff --git a/tests/unistd/dup.c b/tests/unistd/dup.c index 10a56ea882..8a0ca9809e 100644 --- a/tests/unistd/dup.c +++ b/tests/unistd/dup.c @@ -1,6 +1,7 @@ #include #include #include +#include int main(void) { creat("dup.out", 0777); @@ -13,5 +14,5 @@ int main(void) { dup2(fd3, 1); printf("hello fd %d", fd3); close(fd3); - return 0; + return EXIT_SUCCESS; } diff --git a/tests/unistd/exec.c b/tests/unistd/exec.c index fd603471ef..97eae0fed9 100644 --- a/tests/unistd/exec.c +++ b/tests/unistd/exec.c @@ -1,9 +1,10 @@ #include #include +#include int main(void) { char* args[] = {"sh", "-c", "echo 'exec works :D'", NULL}; execv("/bin/sh", args); perror("execv"); - return 0; + return EXIT_SUCCESS; } diff --git a/tests/unistd/fchdir.c b/tests/unistd/fchdir.c index 07256cf28c..b2b4b7d00d 100644 --- a/tests/unistd/fchdir.c +++ b/tests/unistd/fchdir.c @@ -1,6 +1,7 @@ #include #include #include +#include int main(void) { int fd = open("..", 0, 0); @@ -8,5 +9,5 @@ int main(void) { status = fchdir(fd); printf("fchdir exited with status code %d\n", status); close(fd); - return 0; + return EXIT_SUCCESS; } diff --git a/tests/unistd/fsync.c b/tests/unistd/fsync.c index b7d2f76d58..0db9d00fcf 100644 --- a/tests/unistd/fsync.c +++ b/tests/unistd/fsync.c @@ -1,6 +1,7 @@ #include #include #include +#include int main(void) { int fd = open(".", 0, 0); @@ -8,5 +9,5 @@ int main(void) { status = fsync(fd); printf("fsync exited with status code %d\n", status); close(fd); - return 0; + return EXIT_SUCCESS; } diff --git a/tests/unistd/ftruncate.c b/tests/unistd/ftruncate.c index 05634015c1..df2212cfb3 100644 --- a/tests/unistd/ftruncate.c +++ b/tests/unistd/ftruncate.c @@ -1,6 +1,7 @@ #include #include #include +#include int main(void) { int fd = creat("ftruncate.out", 0777); @@ -8,5 +9,5 @@ int main(void) { status = ftruncate(fd, 100); printf("ftruncate exited with status code %d\n", status); close(fd); - return 0; + return EXIT_SUCCESS; } diff --git a/tests/unistd/getcwd.c b/tests/unistd/getcwd.c index fd5bd60cc5..f1e088f8ca 100644 --- a/tests/unistd/getcwd.c +++ b/tests/unistd/getcwd.c @@ -15,7 +15,7 @@ int main(void) { if (strcmp(first, second)) { puts("Not matching"); free(second); - return 1; + return EXIT_FAILURE; } free(second); diff --git a/tests/unistd/getid.c b/tests/unistd/getid.c index b6a8507dc2..e0719b4413 100644 --- a/tests/unistd/getid.c +++ b/tests/unistd/getid.c @@ -1,5 +1,6 @@ #include #include +#include int main(void) { gid_t egid = getegid(); @@ -11,5 +12,5 @@ int main(void) { uid_t uid = getuid(); printf("egid: %d, euid: %d, gid: %d, pgid: %d, pid: %d, ppid %d, uid %d\n", egid, euid, gid, pgid, pid, ppid, uid); - return 0; + return EXIT_SUCCESS; } diff --git a/tests/unistd/link.c b/tests/unistd/link.c index 264c2dda5f..7c2af4565e 100644 --- a/tests/unistd/link.c +++ b/tests/unistd/link.c @@ -1,5 +1,6 @@ #include #include +#include #include #include @@ -11,7 +12,7 @@ int main(void) { // Stat for the inode if (stat("unistd/link.c", &buf)) { perror("stat"); - return 1; + return EXIT_FAILURE; } unsigned long inode = buf.st_ino; printf("%ld\n", inode); @@ -19,7 +20,7 @@ int main(void) { // Create the link if (link("unistd/link.c", "link.out")) { perror("link"); - return 1; + return EXIT_FAILURE; } // Make sure inodes match @@ -37,10 +38,10 @@ int main(void) { // Remove link if (unlink("link.out")) { perror("unlink"); - return 1; + return EXIT_FAILURE; } if (!stat("link.out", &buf) || errno != ENOENT) { perror("stat"); - return 1; + return EXIT_FAILURE; } } diff --git a/tests/unistd/pathconf.c b/tests/unistd/pathconf.c index 77cb7d5466..c878efb24e 100644 --- a/tests/unistd/pathconf.c +++ b/tests/unistd/pathconf.c @@ -1,5 +1,6 @@ #include #include +#include #include #define PC(N) { \ @@ -29,5 +30,5 @@ int main(void) { PC(ALLOC_SIZE_MIN); PC(SYMLINK_MAX); PC(2_SYMLINKS); - return 0; + return EXIT_SUCCESS; } diff --git a/tests/unistd/pipe.c b/tests/unistd/pipe.c index 2e1edf2c9e..320b3906d7 100644 --- a/tests/unistd/pipe.c +++ b/tests/unistd/pipe.c @@ -1,5 +1,6 @@ //http://www2.cs.uregina.ca/~hamilton/courses/330/notes/unix/pipes/pipes.html #include +#include #include #include @@ -10,7 +11,7 @@ int main(void) { if (pipe(pip) < 0) { perror("pipe"); - return 1; + return EXIT_FAILURE; } pid = fork(); @@ -28,13 +29,13 @@ int main(void) { /* check result */ if (bytes < 0) { perror("pipe write"); - return 1; + return EXIT_FAILURE; } else if (bytes != strlen(outstring)) { fprintf(stderr, "pipe write: %d != %ld\n", bytes, strlen(outstring)); - return 1; + return EXIT_FAILURE; } - return 0; + return EXIT_SUCCESS; } else /* parent : receives message from child */ { @@ -53,18 +54,18 @@ int main(void) { /* check result */ if (bytes < 0) { perror("pipe read"); - return 1; + return EXIT_FAILURE; } else if (bytes != strlen(outstring)) { fprintf(stderr, "pipe read: %d != %ld\n", bytes, strlen(outstring)); - return 1; + return EXIT_FAILURE; } else if (memcmp(instring, outstring, strlen(outstring)) != 0) { fprintf(stderr, "pipe read does not match pipe write\n"); - return 1; + return EXIT_FAILURE; } else { printf("%s\n", instring); } - return 0; + return EXIT_SUCCESS; } - return 0; + return EXIT_SUCCESS; } diff --git a/tests/unistd/rmdir.c b/tests/unistd/rmdir.c index 11a8bd646e..2af003c3fe 100644 --- a/tests/unistd/rmdir.c +++ b/tests/unistd/rmdir.c @@ -1,10 +1,11 @@ #include #include #include +#include int main(void) { mkdir("foo", 0); int status = rmdir("foo"); printf("rmdir exited with status code %d\n", status); - return 0; + return EXIT_SUCCESS; } diff --git a/tests/unistd/setid.c b/tests/unistd/setid.c index 78b01dda2e..f267814d13 100644 --- a/tests/unistd/setid.c +++ b/tests/unistd/setid.c @@ -22,5 +22,5 @@ int main(void) { perror( "setreuid" ); } printf("%d has euid %d and uid %d\n", getpid(), geteuid(), getuid()); - return 0; + return EXIT_SUCCESS; } diff --git a/tests/unistd/sleep.c b/tests/unistd/sleep.c index df69754dd2..ab27aa303b 100644 --- a/tests/unistd/sleep.c +++ b/tests/unistd/sleep.c @@ -1,6 +1,7 @@ #include #include #include +#include int main(void) { sleep(2); @@ -10,5 +11,5 @@ int main(void) { struct timespec tm = {0, 10000}; nanosleep(&tm, NULL); perror("nanosleep"); - return 0; + return EXIT_SUCCESS; } diff --git a/tests/unistd/stat.c b/tests/unistd/stat.c index a0775bc535..7287c0018e 100644 --- a/tests/unistd/stat.c +++ b/tests/unistd/stat.c @@ -1,5 +1,6 @@ #include #include +#include #include #include @@ -10,7 +11,7 @@ int main(void) { if (stat("unistd/stat.c", &buf)) { perror("stat"); - return 1; + return EXIT_FAILURE; } printf("st_size: %lu\n", buf.st_size); diff --git a/tests/unistd/sysconf.c b/tests/unistd/sysconf.c index 6e53ee3c40..9aca5f4187 100644 --- a/tests/unistd/sysconf.c +++ b/tests/unistd/sysconf.c @@ -1,5 +1,6 @@ #include #include +#include #include #define SC(N) { \ @@ -22,5 +23,5 @@ int main(void) { SC(TTY_NAME_MAX); SC(SYMLOOP_MAX); SC(HOST_NAME_MAX); - return 0; + return EXIT_SUCCESS; } diff --git a/tests/unistd/write.c b/tests/unistd/write.c index bfc52a920b..e9af15ab7a 100644 --- a/tests/unistd/write.c +++ b/tests/unistd/write.c @@ -1,6 +1,7 @@ +#include #include int main(void) { write(STDOUT_FILENO, "Hello World!\n", 13); - return 0; + return EXIT_SUCCESS; } diff --git a/tests/waitpid.c b/tests/waitpid.c index 0a52eaa45a..5f94f5b7ca 100644 --- a/tests/waitpid.c +++ b/tests/waitpid.c @@ -7,11 +7,11 @@ int main(void) { if (pid == 0) { // child sleep(1); - exit(0); + return EXIT_SUCCESS; } else { // parent int stat_loc; waitpid(pid, &stat_loc, 0); } - return 0; + return EXIT_SUCCESS; } diff --git a/tests/wchar/putwchar.c b/tests/wchar/putwchar.c index a777854a53..0380d5ae33 100644 --- a/tests/wchar/putwchar.c +++ b/tests/wchar/putwchar.c @@ -12,9 +12,9 @@ int main(void) { if (0xFFFFFFFFu == putwchar(wcs[i])) { printf("Unable to putwchar() the wide character.\n"); - exit(EXIT_FAILURE); + return EXIT_FAILURE; } } - return 0; + return EXIT_SUCCESS; } From 4381bb2a223286519005d0296eb0a87a358a560b Mon Sep 17 00:00:00 2001 From: Tibor Nagy Date: Wed, 20 Feb 2019 21:09:03 +0100 Subject: [PATCH 5/6] tests: Remove redundant return statements When the execution reaches the end of the main functions, they implicitly return a successful status. --- tests/args.c | 2 -- tests/ctype.c | 7 ++++--- tests/dirent/main.c | 2 -- tests/error.c | 2 -- tests/fcntl/fcntl.c | 2 -- tests/libgen.c | 1 - tests/math.c | 2 -- tests/netdb/getaddrinfo.c | 2 -- tests/stdio/all.c | 1 - tests/stdio/fputs.c | 2 -- tests/stdio/fread.c | 2 -- tests/stdio/freopen.c | 2 -- tests/stdio/fwrite.c | 1 - tests/stdio/popen.c | 2 -- tests/stdio/printf.c | 2 -- tests/stdio/setvbuf.c | 1 - tests/stdlib/a64l.c | 1 - tests/stdlib/alloc.c | 2 -- tests/stdlib/atof.c | 1 - tests/stdlib/atoi.c | 1 - tests/stdlib/bsearch.c | 1 - tests/stdlib/div.c | 3 --- tests/stdlib/mkostemps.c | 1 - tests/stdlib/mktemp.c | 1 - tests/stdlib/strtol.c | 2 -- tests/stdlib/strtoul.c | 2 -- tests/stdlib/system.c | 1 - tests/string/mem.c | 1 - tests/string/strcat.c | 3 --- tests/string/strchr.c | 3 --- tests/string/strcspn.c | 3 --- tests/string/strncmp.c | 3 --- tests/string/strpbrk.c | 5 +---- tests/string/strrchr.c | 1 - tests/string/strspn.c | 3 --- tests/string/strstr.c | 3 --- tests/string/strtok.c | 3 --- tests/string/strtok_r.c | 3 --- tests/time/asctime.c | 1 - tests/time/gmtime.c | 1 - tests/time/time.c | 2 -- tests/unistd/brk.c | 2 -- tests/unistd/chdir.c | 1 - tests/unistd/dup.c | 2 -- tests/unistd/exec.c | 2 -- tests/unistd/fchdir.c | 2 -- tests/unistd/fsync.c | 2 -- tests/unistd/ftruncate.c | 2 -- tests/unistd/getid.c | 2 -- tests/unistd/pathconf.c | 2 -- tests/unistd/pipe.c | 1 - tests/unistd/rmdir.c | 2 -- tests/unistd/setid.c | 2 -- tests/unistd/sleep.c | 2 -- tests/unistd/sysconf.c | 2 -- tests/unistd/write.c | 2 -- tests/waitpid.c | 1 - tests/wchar/putwchar.c | 2 -- 58 files changed, 5 insertions(+), 110 deletions(-) diff --git a/tests/args.c b/tests/args.c index 9f59c9012d..49e7ae0ff4 100644 --- a/tests/args.c +++ b/tests/args.c @@ -1,4 +1,3 @@ -#include #include #include @@ -9,5 +8,4 @@ int main(int argc, char *argv[]) { write(STDOUT_FILENO, " ", 1); } write(STDOUT_FILENO, "\n", 1); - return EXIT_SUCCESS; } diff --git a/tests/ctype.c b/tests/ctype.c index 40ba65ae47..1dd70680f2 100644 --- a/tests/ctype.c +++ b/tests/ctype.c @@ -1,5 +1,6 @@ #include #include +#include struct test_case { int c; @@ -289,12 +290,12 @@ size_t num_test_cases = sizeof(test_cases) / sizeof(struct test_case); #define CHECK_TEST(tc, fn, retval) \ if (fn(tc.c) != tc.fn) { \ - retval = -1; \ + retval = EXIT_FAILURE; \ printf("Unexpected result: " #fn "('%c') != %d // Char value: %d\n", tc.c, tc.fn, tc.c); \ } int main(void) { - int retval = 0; + int retval = EXIT_SUCCESS; for(int i = 0; i < num_test_cases; ++i) { struct test_case tc = test_cases[i]; @@ -316,7 +317,7 @@ int main(void) { CHECK_TEST(tc, toupper, retval); } - if (!retval) { + if (retval == EXIT_SUCCESS) { printf("Success: %d\n", retval); } else { printf("Failure: %d\n", retval); diff --git a/tests/dirent/main.c b/tests/dirent/main.c index aa574ba7d3..92a4fe2467 100644 --- a/tests/dirent/main.c +++ b/tests/dirent/main.c @@ -38,6 +38,4 @@ int main(void) { // puts(entry->d_name); closedir(dir); - - return EXIT_SUCCESS; } diff --git a/tests/error.c b/tests/error.c index 3bfd5217ff..09756286f8 100644 --- a/tests/error.c +++ b/tests/error.c @@ -1,6 +1,5 @@ #include #include -#include #include #include @@ -8,5 +7,4 @@ int main(void) { chdir("nonexistent"); printf("errno: %d = %s\n", errno, strerror(errno)); perror("perror"); - return EXIT_SUCCESS; } diff --git a/tests/fcntl/fcntl.c b/tests/fcntl/fcntl.c index d6f85a9a46..3ec16a84d1 100644 --- a/tests/fcntl/fcntl.c +++ b/tests/fcntl/fcntl.c @@ -1,6 +1,5 @@ #include #include -#include #include int main(void) { @@ -11,5 +10,4 @@ int main(void) { printf("fd %d duped into fd %d\n", newfd, newfd2); close(newfd); close(newfd2); - return EXIT_SUCCESS; } diff --git a/tests/libgen.c b/tests/libgen.c index 4feee89bf0..91b18a4f3c 100644 --- a/tests/libgen.c +++ b/tests/libgen.c @@ -77,5 +77,4 @@ int main(void) { printf("Testing libgen.h\n"); test_basename(); test_dirname(); - return EXIT_SUCCESS; } diff --git a/tests/math.c b/tests/math.c index b061097755..9f485b1b0e 100644 --- a/tests/math.c +++ b/tests/math.c @@ -1,10 +1,8 @@ #include #include -#include int main(void) { double pi = 3.14; float c = cos(pi); printf("cos(%f) = %f\n", pi, c); - return EXIT_SUCCESS; } diff --git a/tests/netdb/getaddrinfo.c b/tests/netdb/getaddrinfo.c index efe4c5dfec..1c92a86307 100644 --- a/tests/netdb/getaddrinfo.c +++ b/tests/netdb/getaddrinfo.c @@ -45,6 +45,4 @@ int main(void) { res = res->ai_next; } - - return EXIT_SUCCESS; } diff --git a/tests/stdio/all.c b/tests/stdio/all.c index 33a5f905b1..d1e393e307 100644 --- a/tests/stdio/all.c +++ b/tests/stdio/all.c @@ -9,5 +9,4 @@ int main(void) { printf("%s\n", fgets(in, 30, f)); setvbuf(stdout, 0, _IONBF, 0); printf("Hello\n"); - return EXIT_SUCCESS; } diff --git a/tests/stdio/fputs.c b/tests/stdio/fputs.c index 74424b20ee..52aef7da68 100644 --- a/tests/stdio/fputs.c +++ b/tests/stdio/fputs.c @@ -1,5 +1,4 @@ #include -#include #include int main(void) { @@ -7,5 +6,4 @@ int main(void) { char *in = "Hello World!"; fputs(in, f); // calls fwrite, helpers::fwritex, internal::to_write and internal::stdio_write fclose(f); - return EXIT_SUCCESS; } diff --git a/tests/stdio/fread.c b/tests/stdio/fread.c index 6e95bc7291..e5e13b28cb 100644 --- a/tests/stdio/fread.c +++ b/tests/stdio/fread.c @@ -17,6 +17,4 @@ int main(void) { } fclose(fp); - - return EXIT_SUCCESS; } diff --git a/tests/stdio/freopen.c b/tests/stdio/freopen.c index b68a858383..e7ec2c271d 100644 --- a/tests/stdio/freopen.c +++ b/tests/stdio/freopen.c @@ -1,10 +1,8 @@ #include -#include int main(void) { freopen("stdio/stdio.in", "r", stdin); char in[6]; fgets(in, 6, stdin); printf("%s\n", in); // should print Hello - return EXIT_SUCCESS; } diff --git a/tests/stdio/fwrite.c b/tests/stdio/fwrite.c index 93f412413c..9132420bff 100644 --- a/tests/stdio/fwrite.c +++ b/tests/stdio/fwrite.c @@ -20,5 +20,4 @@ int main(void) { fwrite(ptr, sizeof(ptr), 1, f); fclose(f); - return EXIT_SUCCESS; } diff --git a/tests/stdio/popen.c b/tests/stdio/popen.c index 89f1d9a097..afa83fab0a 100644 --- a/tests/stdio/popen.c +++ b/tests/stdio/popen.c @@ -25,6 +25,4 @@ int main(void) { } else { printf("status %x\n", status); } - - return EXIT_SUCCESS; } diff --git a/tests/stdio/printf.c b/tests/stdio/printf.c index ebe84e79d0..ea7b8dde02 100644 --- a/tests/stdio/printf.c +++ b/tests/stdio/printf.c @@ -1,5 +1,4 @@ #include -#include int main(void) { int sofar = 0; @@ -49,5 +48,4 @@ int main(void) { printf("%G\n", 0.0001); printf("%G\n", 0.00001); printf("%E\n", 0.00001); - return EXIT_SUCCESS; } diff --git a/tests/stdio/setvbuf.c b/tests/stdio/setvbuf.c index 8d38913cf2..2b0356bf15 100644 --- a/tests/stdio/setvbuf.c +++ b/tests/stdio/setvbuf.c @@ -10,5 +10,4 @@ int main(void) { char *in = malloc(30); printf("%s\n", fgets(in, 30, f)); printf("Hello\n"); - return EXIT_SUCCESS; } diff --git a/tests/stdlib/a64l.c b/tests/stdlib/a64l.c index 0ffb73effc..7c44bb84ed 100644 --- a/tests/stdlib/a64l.c +++ b/tests/stdlib/a64l.c @@ -18,5 +18,4 @@ int main(void) { return EXIT_FAILURE; } printf("Correct a64l: %s = %ld\n", s, l); - return EXIT_SUCCESS; } diff --git a/tests/stdlib/alloc.c b/tests/stdlib/alloc.c index 4e0b72de3d..b21dfadb18 100644 --- a/tests/stdlib/alloc.c +++ b/tests/stdlib/alloc.c @@ -24,6 +24,4 @@ int main(void) { ptra[i] = (char)i; } free(ptra); - - return EXIT_SUCCESS; } diff --git a/tests/stdlib/atof.c b/tests/stdlib/atof.c index f686bd12c2..19f6e25c77 100644 --- a/tests/stdlib/atof.c +++ b/tests/stdlib/atof.c @@ -4,5 +4,4 @@ int main(void) { double d = atof("-3.14"); printf("%f\n", d); - return EXIT_SUCCESS; } diff --git a/tests/stdlib/atoi.c b/tests/stdlib/atoi.c index 2960697f02..3e06f29c89 100644 --- a/tests/stdlib/atoi.c +++ b/tests/stdlib/atoi.c @@ -8,5 +8,4 @@ int main(void) { printf("%ld\n", atol(" -42")); printf("%ld\n", atol(" +555")); printf("%ld\n", atol(" 1234567890 ")); - return EXIT_SUCCESS; } diff --git a/tests/stdlib/bsearch.c b/tests/stdlib/bsearch.c index 834e56e2cd..a56756a77a 100644 --- a/tests/stdlib/bsearch.c +++ b/tests/stdlib/bsearch.c @@ -53,5 +53,4 @@ int main(void) { BSEARCH_TEST_INT(x, big, 7, NULL); printf("PASS bsearch\n"); - return EXIT_SUCCESS; } diff --git a/tests/stdlib/div.c b/tests/stdlib/div.c index 9939f07b47..394e842378 100644 --- a/tests/stdlib/div.c +++ b/tests/stdlib/div.c @@ -16,8 +16,5 @@ int main(void) { ll = mydivt.rem; ll = atoll("10"); _Exit(0); - - ; - return EXIT_SUCCESS; } diff --git a/tests/stdlib/mkostemps.c b/tests/stdlib/mkostemps.c index 5af996f6b3..aa544e9aa7 100644 --- a/tests/stdlib/mkostemps.c +++ b/tests/stdlib/mkostemps.c @@ -23,5 +23,4 @@ int main(void) { } fclose(fp); remove(file_name); - return EXIT_SUCCESS; } diff --git a/tests/stdlib/mktemp.c b/tests/stdlib/mktemp.c index 02c2e72e26..0a23e6ed25 100644 --- a/tests/stdlib/mktemp.c +++ b/tests/stdlib/mktemp.c @@ -8,5 +8,4 @@ int main(void) { mktemp(string); printf("%s\n",string); free(string); - return EXIT_SUCCESS; } diff --git a/tests/stdlib/strtol.c b/tests/stdlib/strtol.c index 283a622c05..2977d64747 100644 --- a/tests/stdlib/strtol.c +++ b/tests/stdlib/strtol.c @@ -26,6 +26,4 @@ int main(void) { if(errno != 0) { printf("errno is not 0 (%d), something went wrong\n", errno); } - - return EXIT_SUCCESS; } diff --git a/tests/stdlib/strtoul.c b/tests/stdlib/strtoul.c index d33ca9b7f8..afb903cb38 100644 --- a/tests/stdlib/strtoul.c +++ b/tests/stdlib/strtoul.c @@ -25,6 +25,4 @@ int main(void) { if(errno != 0) { printf("errno is not 0 (%d), something went wrong\n", errno); } - - return EXIT_SUCCESS; } diff --git a/tests/stdlib/system.c b/tests/stdlib/system.c index 9b3270eb79..5e9d662cd6 100644 --- a/tests/stdlib/system.c +++ b/tests/stdlib/system.c @@ -2,5 +2,4 @@ int main(void) { system("echo test of system"); - return EXIT_SUCCESS; } diff --git a/tests/string/mem.c b/tests/string/mem.c index 9c8db1e8c0..2b717d6c75 100644 --- a/tests/string/mem.c +++ b/tests/string/mem.c @@ -38,5 +38,4 @@ int main(void) { return EXIT_FAILURE; } puts("Correct memcmp"); - return EXIT_SUCCESS; } diff --git a/tests/string/strcat.c b/tests/string/strcat.c index cb58004d1d..0653b7f480 100644 --- a/tests/string/strcat.c +++ b/tests/string/strcat.c @@ -1,6 +1,5 @@ #include #include -#include int main(void) { char dest1[12] = "hello"; @@ -8,6 +7,4 @@ int main(void) { char dest2[12] = "hello"; printf("%s\n", strncat(dest2, " world foobar", 6)); // should be hello world - - return EXIT_SUCCESS; } diff --git a/tests/string/strchr.c b/tests/string/strchr.c index 3273d88a73..fb2e07e056 100644 --- a/tests/string/strchr.c +++ b/tests/string/strchr.c @@ -1,11 +1,8 @@ #include #include -#include int main(void) { printf("%s\n", strchr("hello", 'e')); // should be ello printf("%s\n", strchr("world", 'l')); // should be ld printf("%i\n", strchr("world", 0) == NULL); // should be 1 - - return EXIT_SUCCESS; } diff --git a/tests/string/strcspn.c b/tests/string/strcspn.c index 8511b95cb9..7370558c91 100644 --- a/tests/string/strcspn.c +++ b/tests/string/strcspn.c @@ -1,11 +1,8 @@ #include #include -#include int main(void) { char *world = "world"; printf("%ld\n", strcspn("hello", world)); // should be 2 printf("%ld\n", strcspn("banana", world)); // should be 6 - - return EXIT_SUCCESS; } diff --git a/tests/string/strncmp.c b/tests/string/strncmp.c index 913200be7c..fd4033c8e6 100644 --- a/tests/string/strncmp.c +++ b/tests/string/strncmp.c @@ -1,6 +1,5 @@ #include #include -#include int main(void) { printf("%d\n", strncmp("a", "aa", 2)); @@ -9,6 +8,4 @@ int main(void) { printf("%d\n", strncmp("", "\xFF", 1)); printf("%d\n", strncmp("a", "c", 1)); printf("%d\n", strncmp("a", "a", 2)); - - return EXIT_SUCCESS; } diff --git a/tests/string/strpbrk.c b/tests/string/strpbrk.c index d61de16956..bb5ca56ee0 100644 --- a/tests/string/strpbrk.c +++ b/tests/string/strpbrk.c @@ -1,6 +1,5 @@ #include #include -#include int main(void) { char* source = "The quick drawn fix jumps over the lazy bug"; @@ -15,7 +14,5 @@ int main(void) { // should be "NULL" char* res3 = strpbrk(source, "404"); - printf("%s\n", (res3) ? res3 : "NULL"); - - return EXIT_SUCCESS; + printf("%s\n", (res3) ? res3 : "NULL"); } diff --git a/tests/string/strrchr.c b/tests/string/strrchr.c index c8d2f65ad5..d32c244ff1 100644 --- a/tests/string/strrchr.c +++ b/tests/string/strrchr.c @@ -18,5 +18,4 @@ int main(void) { return EXIT_FAILURE; } printf("strrch PASS, exiting with status code %d\n", 0); - return EXIT_SUCCESS; } diff --git a/tests/string/strspn.c b/tests/string/strspn.c index cd9316fad7..c198a20bf0 100644 --- a/tests/string/strspn.c +++ b/tests/string/strspn.c @@ -1,6 +1,5 @@ #include #include -#include int main(void) { char *hello = "hello"; @@ -9,6 +8,4 @@ int main(void) { printf("%lu\n", strspn(hello, "hello")); // should be 5 printf("%lu\n", strspn(world, "wendy")); // should be 1 printf("%lu\n", strspn(banana, "apple")); // should be 0 - - return EXIT_SUCCESS; } diff --git a/tests/string/strstr.c b/tests/string/strstr.c index 1e9f38cf97..d36b4d915a 100644 --- a/tests/string/strstr.c +++ b/tests/string/strstr.c @@ -1,6 +1,5 @@ #include #include -#include int main(void) { printf("%s\n", strstr("In relibc we trust", "rust")); @@ -8,6 +7,4 @@ int main(void) { printf("%s\n", strstr("In relibc we trust", "bugs")); printf("%s\n", strstr("IN RELIBC WE TRUST", "rust")); printf("%s\n", strcasestr("IN RELIBC WE TRUST", "rust")); - - return EXIT_SUCCESS; } diff --git a/tests/string/strtok.c b/tests/string/strtok.c index cfa716fe7f..d2e066acb3 100644 --- a/tests/string/strtok.c +++ b/tests/string/strtok.c @@ -1,6 +1,5 @@ #include #include -#include int main(void) { char source[] = "I'd just like to interject for a moment. What you're referring to as Linux, " @@ -13,6 +12,4 @@ int main(void) { printf("_"); } } - - return EXIT_SUCCESS; } diff --git a/tests/string/strtok_r.c b/tests/string/strtok_r.c index 2abe530b0e..8873635c69 100644 --- a/tests/string/strtok_r.c +++ b/tests/string/strtok_r.c @@ -1,6 +1,5 @@ #include #include -#include int main(void) { char source[] = "I'd just like to interject for a moment. What you're referring to as Linux, " @@ -14,6 +13,4 @@ int main(void) { printf("_"); } } - - return EXIT_SUCCESS; } diff --git a/tests/time/asctime.c b/tests/time/asctime.c index 2624ec9b7b..f2e57da1a6 100644 --- a/tests/time/asctime.c +++ b/tests/time/asctime.c @@ -12,5 +12,4 @@ int main(void) { if (time_string == NULL || strcmp(time_string, "Thu Jan 1 00:00:00 1970\n") != 0) { return EXIT_FAILURE; } - return EXIT_SUCCESS; } diff --git a/tests/time/gmtime.c b/tests/time/gmtime.c index 38d0b8d347..09bc97e5ef 100644 --- a/tests/time/gmtime.c +++ b/tests/time/gmtime.c @@ -24,5 +24,4 @@ int main(void) { info->tm_gmtoff != expected.tm_gmtoff || strcmp(info->tm_zone, expected.tm_zone) != 0) { return EXIT_FAILURE; } - return EXIT_SUCCESS; } diff --git a/tests/time/time.c b/tests/time/time.c index 3c5aed66b7..24d7b28d34 100644 --- a/tests/time/time.c +++ b/tests/time/time.c @@ -22,6 +22,4 @@ int main(void) { perror("clock"); return EXIT_FAILURE; } - - return EXIT_SUCCESS; } diff --git a/tests/unistd/brk.c b/tests/unistd/brk.c index 5b4ffc1418..811644e28d 100644 --- a/tests/unistd/brk.c +++ b/tests/unistd/brk.c @@ -1,9 +1,7 @@ #include #include -#include int main(void) { int status = brk((void*)100); printf("brk exited with status code %d\n", status); - return EXIT_SUCCESS; } diff --git a/tests/unistd/chdir.c b/tests/unistd/chdir.c index eb8341eeb5..28178922e8 100644 --- a/tests/unistd/chdir.c +++ b/tests/unistd/chdir.c @@ -12,5 +12,4 @@ int main(void) { getcwd(cwd2, 4096); printf("final cwd: %s\n", cwd2); free(cwd2); - return EXIT_SUCCESS; } diff --git a/tests/unistd/dup.c b/tests/unistd/dup.c index 8a0ca9809e..0c7ff8ecb9 100644 --- a/tests/unistd/dup.c +++ b/tests/unistd/dup.c @@ -1,7 +1,6 @@ #include #include #include -#include int main(void) { creat("dup.out", 0777); @@ -14,5 +13,4 @@ int main(void) { dup2(fd3, 1); printf("hello fd %d", fd3); close(fd3); - return EXIT_SUCCESS; } diff --git a/tests/unistd/exec.c b/tests/unistd/exec.c index 97eae0fed9..43b10ddccb 100644 --- a/tests/unistd/exec.c +++ b/tests/unistd/exec.c @@ -1,10 +1,8 @@ #include #include -#include int main(void) { char* args[] = {"sh", "-c", "echo 'exec works :D'", NULL}; execv("/bin/sh", args); perror("execv"); - return EXIT_SUCCESS; } diff --git a/tests/unistd/fchdir.c b/tests/unistd/fchdir.c index b2b4b7d00d..9e3ab29b7e 100644 --- a/tests/unistd/fchdir.c +++ b/tests/unistd/fchdir.c @@ -1,7 +1,6 @@ #include #include #include -#include int main(void) { int fd = open("..", 0, 0); @@ -9,5 +8,4 @@ int main(void) { status = fchdir(fd); printf("fchdir exited with status code %d\n", status); close(fd); - return EXIT_SUCCESS; } diff --git a/tests/unistd/fsync.c b/tests/unistd/fsync.c index 0db9d00fcf..7f337f1caa 100644 --- a/tests/unistd/fsync.c +++ b/tests/unistd/fsync.c @@ -1,7 +1,6 @@ #include #include #include -#include int main(void) { int fd = open(".", 0, 0); @@ -9,5 +8,4 @@ int main(void) { status = fsync(fd); printf("fsync exited with status code %d\n", status); close(fd); - return EXIT_SUCCESS; } diff --git a/tests/unistd/ftruncate.c b/tests/unistd/ftruncate.c index df2212cfb3..7eb4f9822d 100644 --- a/tests/unistd/ftruncate.c +++ b/tests/unistd/ftruncate.c @@ -1,7 +1,6 @@ #include #include #include -#include int main(void) { int fd = creat("ftruncate.out", 0777); @@ -9,5 +8,4 @@ int main(void) { status = ftruncate(fd, 100); printf("ftruncate exited with status code %d\n", status); close(fd); - return EXIT_SUCCESS; } diff --git a/tests/unistd/getid.c b/tests/unistd/getid.c index e0719b4413..d2a2bf579c 100644 --- a/tests/unistd/getid.c +++ b/tests/unistd/getid.c @@ -1,6 +1,5 @@ #include #include -#include int main(void) { gid_t egid = getegid(); @@ -12,5 +11,4 @@ int main(void) { uid_t uid = getuid(); printf("egid: %d, euid: %d, gid: %d, pgid: %d, pid: %d, ppid %d, uid %d\n", egid, euid, gid, pgid, pid, ppid, uid); - return EXIT_SUCCESS; } diff --git a/tests/unistd/pathconf.c b/tests/unistd/pathconf.c index c878efb24e..5aeaee8b67 100644 --- a/tests/unistd/pathconf.c +++ b/tests/unistd/pathconf.c @@ -1,6 +1,5 @@ #include #include -#include #include #define PC(N) { \ @@ -30,5 +29,4 @@ int main(void) { PC(ALLOC_SIZE_MIN); PC(SYMLINK_MAX); PC(2_SYMLINKS); - return EXIT_SUCCESS; } diff --git a/tests/unistd/pipe.c b/tests/unistd/pipe.c index 320b3906d7..90dfa64641 100644 --- a/tests/unistd/pipe.c +++ b/tests/unistd/pipe.c @@ -67,5 +67,4 @@ int main(void) { return EXIT_SUCCESS; } - return EXIT_SUCCESS; } diff --git a/tests/unistd/rmdir.c b/tests/unistd/rmdir.c index 2af003c3fe..212ad48dab 100644 --- a/tests/unistd/rmdir.c +++ b/tests/unistd/rmdir.c @@ -1,11 +1,9 @@ #include #include #include -#include int main(void) { mkdir("foo", 0); int status = rmdir("foo"); printf("rmdir exited with status code %d\n", status); - return EXIT_SUCCESS; } diff --git a/tests/unistd/setid.c b/tests/unistd/setid.c index f267814d13..5a35bbb54f 100644 --- a/tests/unistd/setid.c +++ b/tests/unistd/setid.c @@ -4,7 +4,6 @@ #include #include #include -#include int main(void) { if( setpgid( getpid(), 0 ) == -1 ) { @@ -22,5 +21,4 @@ int main(void) { perror( "setreuid" ); } printf("%d has euid %d and uid %d\n", getpid(), geteuid(), getuid()); - return EXIT_SUCCESS; } diff --git a/tests/unistd/sleep.c b/tests/unistd/sleep.c index ab27aa303b..7aa46108c9 100644 --- a/tests/unistd/sleep.c +++ b/tests/unistd/sleep.c @@ -1,7 +1,6 @@ #include #include #include -#include int main(void) { sleep(2); @@ -11,5 +10,4 @@ int main(void) { struct timespec tm = {0, 10000}; nanosleep(&tm, NULL); perror("nanosleep"); - return EXIT_SUCCESS; } diff --git a/tests/unistd/sysconf.c b/tests/unistd/sysconf.c index 9aca5f4187..be64b647c6 100644 --- a/tests/unistd/sysconf.c +++ b/tests/unistd/sysconf.c @@ -1,6 +1,5 @@ #include #include -#include #include #define SC(N) { \ @@ -23,5 +22,4 @@ int main(void) { SC(TTY_NAME_MAX); SC(SYMLOOP_MAX); SC(HOST_NAME_MAX); - return EXIT_SUCCESS; } diff --git a/tests/unistd/write.c b/tests/unistd/write.c index e9af15ab7a..47cc4e0213 100644 --- a/tests/unistd/write.c +++ b/tests/unistd/write.c @@ -1,7 +1,5 @@ -#include #include int main(void) { write(STDOUT_FILENO, "Hello World!\n", 13); - return EXIT_SUCCESS; } diff --git a/tests/waitpid.c b/tests/waitpid.c index 5f94f5b7ca..e25011d89a 100644 --- a/tests/waitpid.c +++ b/tests/waitpid.c @@ -13,5 +13,4 @@ int main(void) { int stat_loc; waitpid(pid, &stat_loc, 0); } - return EXIT_SUCCESS; } diff --git a/tests/wchar/putwchar.c b/tests/wchar/putwchar.c index 0380d5ae33..db5e276acc 100644 --- a/tests/wchar/putwchar.c +++ b/tests/wchar/putwchar.c @@ -15,6 +15,4 @@ int main(void) { return EXIT_FAILURE; } } - - return EXIT_SUCCESS; } From 27a3f2ab77815a2769f5e22e34a5be6cfa569487 Mon Sep 17 00:00:00 2001 From: Tibor Nagy Date: Wed, 20 Feb 2019 22:11:25 +0100 Subject: [PATCH 6/6] unistd: Generate correct C defines for PATH_SEPARATOR --- src/header/unistd/cbindgen.toml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/header/unistd/cbindgen.toml b/src/header/unistd/cbindgen.toml index 2c03074df9..585796ed34 100644 --- a/src/header/unistd/cbindgen.toml +++ b/src/header/unistd/cbindgen.toml @@ -6,3 +6,7 @@ style = "Tag" [enum] prefix_with_name = true + +[defines] +"target_os = linux" = "__linux__" +"target_os = redox" = "__redox__"