Browse Source

tests: Remove redundant return statements
When the execution reaches the end of the main functions, they implicitly return a successful status.

Tibor Nagy 6 years ago
parent
commit
4381bb2a22
58 changed files with 5 additions and 110 deletions
  1. 0 2
      tests/args.c
  2. 4 3
      tests/ctype.c
  3. 0 2
      tests/dirent/main.c
  4. 0 2
      tests/error.c
  5. 0 2
      tests/fcntl/fcntl.c
  6. 0 1
      tests/libgen.c
  7. 0 2
      tests/math.c
  8. 0 2
      tests/netdb/getaddrinfo.c
  9. 0 1
      tests/stdio/all.c
  10. 0 2
      tests/stdio/fputs.c
  11. 0 2
      tests/stdio/fread.c
  12. 0 2
      tests/stdio/freopen.c
  13. 0 1
      tests/stdio/fwrite.c
  14. 0 2
      tests/stdio/popen.c
  15. 0 2
      tests/stdio/printf.c
  16. 0 1
      tests/stdio/setvbuf.c
  17. 0 1
      tests/stdlib/a64l.c
  18. 0 2
      tests/stdlib/alloc.c
  19. 0 1
      tests/stdlib/atof.c
  20. 0 1
      tests/stdlib/atoi.c
  21. 0 1
      tests/stdlib/bsearch.c
  22. 0 3
      tests/stdlib/div.c
  23. 0 1
      tests/stdlib/mkostemps.c
  24. 0 1
      tests/stdlib/mktemp.c
  25. 0 2
      tests/stdlib/strtol.c
  26. 0 2
      tests/stdlib/strtoul.c
  27. 0 1
      tests/stdlib/system.c
  28. 0 1
      tests/string/mem.c
  29. 0 3
      tests/string/strcat.c
  30. 0 3
      tests/string/strchr.c
  31. 0 3
      tests/string/strcspn.c
  32. 0 3
      tests/string/strncmp.c
  33. 1 4
      tests/string/strpbrk.c
  34. 0 1
      tests/string/strrchr.c
  35. 0 3
      tests/string/strspn.c
  36. 0 3
      tests/string/strstr.c
  37. 0 3
      tests/string/strtok.c
  38. 0 3
      tests/string/strtok_r.c
  39. 0 1
      tests/time/asctime.c
  40. 0 1
      tests/time/gmtime.c
  41. 0 2
      tests/time/time.c
  42. 0 2
      tests/unistd/brk.c
  43. 0 1
      tests/unistd/chdir.c
  44. 0 2
      tests/unistd/dup.c
  45. 0 2
      tests/unistd/exec.c
  46. 0 2
      tests/unistd/fchdir.c
  47. 0 2
      tests/unistd/fsync.c
  48. 0 2
      tests/unistd/ftruncate.c
  49. 0 2
      tests/unistd/getid.c
  50. 0 2
      tests/unistd/pathconf.c
  51. 0 1
      tests/unistd/pipe.c
  52. 0 2
      tests/unistd/rmdir.c
  53. 0 2
      tests/unistd/setid.c
  54. 0 2
      tests/unistd/sleep.c
  55. 0 2
      tests/unistd/sysconf.c
  56. 0 2
      tests/unistd/write.c
  57. 0 1
      tests/waitpid.c
  58. 0 2
      tests/wchar/putwchar.c

+ 0 - 2
tests/args.c

@@ -1,4 +1,3 @@
-#include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
 
@@ -9,5 +8,4 @@ int main(int argc, char *argv[]) {
         write(STDOUT_FILENO, " ", 1);
     }
     write(STDOUT_FILENO, "\n", 1);
-    return EXIT_SUCCESS;
 }

+ 4 - 3
tests/ctype.c

@@ -1,5 +1,6 @@
 #include <ctype.h>
 #include <stdio.h>
+#include <stdlib.h>
 
 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);

+ 0 - 2
tests/dirent/main.c

@@ -38,6 +38,4 @@ int main(void) {
     // puts(entry->d_name);
 
     closedir(dir);
-
-    return EXIT_SUCCESS;
 }

+ 0 - 2
tests/error.c

@@ -1,6 +1,5 @@
 #include <unistd.h>
 #include <stdio.h>
-#include <stdlib.h>
 #include <string.h>
 #include <errno.h>
 
@@ -8,5 +7,4 @@ int main(void) {
     chdir("nonexistent");
     printf("errno: %d = %s\n", errno, strerror(errno));
     perror("perror");
-    return EXIT_SUCCESS;
 }

+ 0 - 2
tests/fcntl/fcntl.c

@@ -1,6 +1,5 @@
 #include <fcntl.h>
 #include <stdio.h>
-#include <stdlib.h>
 #include <unistd.h>
 
 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;
 }

+ 0 - 1
tests/libgen.c

@@ -77,5 +77,4 @@ int main(void) {
   printf("Testing libgen.h\n");
   test_basename();
   test_dirname();
-  return EXIT_SUCCESS;
 }

+ 0 - 2
tests/math.c

@@ -1,10 +1,8 @@
 #include <math.h>
 #include <stdio.h>
-#include <stdlib.h>
 
 int main(void) {
     double pi = 3.14;
     float c = cos(pi);
     printf("cos(%f) = %f\n", pi, c);
-    return EXIT_SUCCESS;
 }

+ 0 - 2
tests/netdb/getaddrinfo.c

@@ -45,6 +45,4 @@ int main(void) {
 
         res = res->ai_next;
     }
-
-    return EXIT_SUCCESS;
 }

+ 0 - 1
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;
 }

+ 0 - 2
tests/stdio/fputs.c

@@ -1,5 +1,4 @@
 #include <stdio.h>
-#include <stdlib.h>
 #include <errno.h>
 
 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;
 }

+ 0 - 2
tests/stdio/fread.c

@@ -17,6 +17,4 @@ int main(void) {
     }
 
     fclose(fp);
-
-    return EXIT_SUCCESS;
 }

+ 0 - 2
tests/stdio/freopen.c

@@ -1,10 +1,8 @@
 #include <stdio.h>
-#include <stdlib.h>
 
 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;
 }

+ 0 - 1
tests/stdio/fwrite.c

@@ -20,5 +20,4 @@ int main(void) {
 
 	fwrite(ptr, sizeof(ptr), 1, f);
 	fclose(f);
-	return EXIT_SUCCESS;
 }

+ 0 - 2
tests/stdio/popen.c

@@ -25,6 +25,4 @@ int main(void) {
     } else {
         printf("status %x\n", status);
     }
-
-    return EXIT_SUCCESS;
 }

+ 0 - 2
tests/stdio/printf.c

@@ -1,5 +1,4 @@
 #include <stdio.h>
-#include <stdlib.h>
 
 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;
 }

+ 0 - 1
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;
 }

+ 0 - 1
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;
 }

+ 0 - 2
tests/stdlib/alloc.c

@@ -24,6 +24,4 @@ int main(void) {
         ptra[i] = (char)i;
     }
     free(ptra);
-
-    return EXIT_SUCCESS;
 }

+ 0 - 1
tests/stdlib/atof.c

@@ -4,5 +4,4 @@
 int main(void) {
     double d = atof("-3.14");
     printf("%f\n", d);
-    return EXIT_SUCCESS;
 }

+ 0 - 1
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;
 }

+ 0 - 1
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;
 }

+ 0 - 3
tests/stdlib/div.c

@@ -16,8 +16,5 @@ int main(void) {
          ll = mydivt.rem;
          ll = atoll("10");
          _Exit(0);
-
-  ;
-  return EXIT_SUCCESS;
 }
 

+ 0 - 1
tests/stdlib/mkostemps.c

@@ -23,5 +23,4 @@ int main(void) {
     }
     fclose(fp);
     remove(file_name);
-    return EXIT_SUCCESS;
 }

+ 0 - 1
tests/stdlib/mktemp.c

@@ -8,5 +8,4 @@ int main(void) {
     mktemp(string);
     printf("%s\n",string);
     free(string);
-    return EXIT_SUCCESS;
 }

+ 0 - 2
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;
 }

+ 0 - 2
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;
 }

+ 0 - 1
tests/stdlib/system.c

@@ -2,5 +2,4 @@
 
 int main(void) {
     system("echo test of system");
-    return EXIT_SUCCESS;
 }

+ 0 - 1
tests/string/mem.c

@@ -38,5 +38,4 @@ int main(void) {
         return EXIT_FAILURE;
     }
     puts("Correct memcmp");
-    return EXIT_SUCCESS;
 }

+ 0 - 3
tests/string/strcat.c

@@ -1,6 +1,5 @@
 #include <string.h>
 #include <stdio.h>
-#include <stdlib.h>
 
 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;
 }

+ 0 - 3
tests/string/strchr.c

@@ -1,11 +1,8 @@
 #include <string.h>
 #include <stdio.h>
-#include <stdlib.h>
 
 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;
 }

+ 0 - 3
tests/string/strcspn.c

@@ -1,11 +1,8 @@
 #include <string.h>
 #include <stdio.h>
-#include <stdlib.h>
 
 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;
 }

+ 0 - 3
tests/string/strncmp.c

@@ -1,6 +1,5 @@
 #include <string.h>
 #include <stdio.h>
-#include <stdlib.h>
 
 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;
 }

+ 1 - 4
tests/string/strpbrk.c

@@ -1,6 +1,5 @@
 #include <string.h>
 #include <stdio.h>
-#include <stdlib.h>
 
 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");
 }

+ 0 - 1
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;
 }

+ 0 - 3
tests/string/strspn.c

@@ -1,6 +1,5 @@
 #include <string.h>
 #include <stdio.h>
-#include <stdlib.h>
 
 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;
 }

+ 0 - 3
tests/string/strstr.c

@@ -1,6 +1,5 @@
 #include <string.h>
 #include <stdio.h>
-#include <stdlib.h>
 
 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;
 }

+ 0 - 3
tests/string/strtok.c

@@ -1,6 +1,5 @@
 #include <string.h>
 #include <stdio.h>
-#include <stdlib.h>
 
 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;
 }

+ 0 - 3
tests/string/strtok_r.c

@@ -1,6 +1,5 @@
 #include <string.h>
 #include <stdio.h>
-#include <stdlib.h>
 
 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;
 }

+ 0 - 1
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;
 }

+ 0 - 1
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;
 }

+ 0 - 2
tests/time/time.c

@@ -22,6 +22,4 @@ int main(void) {
         perror("clock");
         return EXIT_FAILURE;
     }
-
-    return EXIT_SUCCESS;
 }

+ 0 - 2
tests/unistd/brk.c

@@ -1,9 +1,7 @@
 #include <unistd.h>
 #include <stdio.h>
-#include <stdlib.h>
 
 int main(void) {
     int status = brk((void*)100);
     printf("brk exited with status code %d\n", status);
-    return EXIT_SUCCESS;
 }

+ 0 - 1
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;
 }

+ 0 - 2
tests/unistd/dup.c

@@ -1,7 +1,6 @@
 #include <unistd.h>
 #include <fcntl.h>
 #include <stdio.h>
-#include <stdlib.h>
 
 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;
 }

+ 0 - 2
tests/unistd/exec.c

@@ -1,10 +1,8 @@
 #include <unistd.h>
 #include <stdio.h>
-#include <stdlib.h>
 
 int main(void) {
     char* args[] = {"sh", "-c", "echo 'exec works :D'", NULL};
     execv("/bin/sh", args);
     perror("execv");
-    return EXIT_SUCCESS;
 }

+ 0 - 2
tests/unistd/fchdir.c

@@ -1,7 +1,6 @@
 #include <unistd.h>
 #include <fcntl.h>
 #include <stdio.h>
-#include <stdlib.h>
 
 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;
 }

+ 0 - 2
tests/unistd/fsync.c

@@ -1,7 +1,6 @@
 #include <unistd.h>
 #include <fcntl.h>
 #include <stdio.h>
-#include <stdlib.h>
 
 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;
 }

+ 0 - 2
tests/unistd/ftruncate.c

@@ -1,7 +1,6 @@
 #include <unistd.h>
 #include <fcntl.h>
 #include <stdio.h>
-#include <stdlib.h>
 
 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;
 }

+ 0 - 2
tests/unistd/getid.c

@@ -1,6 +1,5 @@
 #include <unistd.h>
 #include <stdio.h>
-#include <stdlib.h>
 
 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;
 }

+ 0 - 2
tests/unistd/pathconf.c

@@ -1,6 +1,5 @@
 #include <errno.h>
 #include <stdio.h>
-#include <stdlib.h>
 #include <unistd.h>
 
 #define PC(N) { \
@@ -30,5 +29,4 @@ int main(void) {
 	PC(ALLOC_SIZE_MIN);
 	PC(SYMLINK_MAX);
 	PC(2_SYMLINKS);
-	return EXIT_SUCCESS;
 }

+ 0 - 1
tests/unistd/pipe.c

@@ -67,5 +67,4 @@ int main(void) {
 
         return EXIT_SUCCESS;
     }
-    return EXIT_SUCCESS;
 }

+ 0 - 2
tests/unistd/rmdir.c

@@ -1,11 +1,9 @@
 #include <unistd.h>
 #include <sys/stat.h>
 #include <stdio.h>
-#include <stdlib.h>
 
 int main(void) {
     mkdir("foo", 0);
     int status = rmdir("foo");
     printf("rmdir exited with status code %d\n", status);
-    return EXIT_SUCCESS;
 }

+ 0 - 2
tests/unistd/setid.c

@@ -4,7 +4,6 @@
 #include <stdio.h>
 #include <sys/types.h>
 #include <unistd.h>
-#include <stdlib.h>
 
 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;
 }

+ 0 - 2
tests/unistd/sleep.c

@@ -1,7 +1,6 @@
 #include <time.h>
 #include <unistd.h>
 #include <stdio.h>
-#include <stdlib.h>
 
 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;
 }

+ 0 - 2
tests/unistd/sysconf.c

@@ -1,6 +1,5 @@
 #include <errno.h>
 #include <stdio.h>
-#include <stdlib.h>
 #include <unistd.h>
 
 #define SC(N) { \
@@ -23,5 +22,4 @@ int main(void) {
 	SC(TTY_NAME_MAX);
 	SC(SYMLOOP_MAX);
 	SC(HOST_NAME_MAX);
-	return EXIT_SUCCESS;
 }

+ 0 - 2
tests/unistd/write.c

@@ -1,7 +1,5 @@
-#include <stdlib.h>
 #include <unistd.h>
 
 int main(void) {
     write(STDOUT_FILENO, "Hello World!\n", 13);
-    return EXIT_SUCCESS;
 }

+ 0 - 1
tests/waitpid.c

@@ -13,5 +13,4 @@ int main(void) {
         int stat_loc;
         waitpid(pid, &stat_loc, 0);
     }
-    return EXIT_SUCCESS;
 }

+ 0 - 2
tests/wchar/putwchar.c

@@ -15,6 +15,4 @@ int main(void) {
             return EXIT_FAILURE;
         }
     }
-
-    return EXIT_SUCCESS;
 }