tests: Remove redundant return statements
When the execution reaches the end of the main functions, they implicitly return a successful status.
This commit is contained in:
@@ -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
@@ -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);
|
||||
|
||||
@@ -38,6 +38,4 @@ int main(void) {
|
||||
// puts(entry->d_name);
|
||||
|
||||
closedir(dir);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -77,5 +77,4 @@ int main(void) {
|
||||
printf("Testing libgen.h\n");
|
||||
test_basename();
|
||||
test_dirname();
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -45,6 +45,4 @@ int main(void) {
|
||||
|
||||
res = res->ai_next;
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -17,6 +17,4 @@ int main(void) {
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -20,5 +20,4 @@ int main(void) {
|
||||
|
||||
fwrite(ptr, sizeof(ptr), 1, f);
|
||||
fclose(f);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -25,6 +25,4 @@ int main(void) {
|
||||
} else {
|
||||
printf("status %x\n", status);
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -10,5 +10,4 @@ int main(void) {
|
||||
char *in = malloc(30);
|
||||
printf("%s\n", fgets(in, 30, f));
|
||||
printf("Hello\n");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -18,5 +18,4 @@ int main(void) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
printf("Correct a64l: %s = %ld\n", s, l);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -24,6 +24,4 @@ int main(void) {
|
||||
ptra[i] = (char)i;
|
||||
}
|
||||
free(ptra);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -4,5 +4,4 @@
|
||||
int main(void) {
|
||||
double d = atof("-3.14");
|
||||
printf("%f\n", d);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -53,5 +53,4 @@ int main(void) {
|
||||
BSEARCH_TEST_INT(x, big, 7, NULL);
|
||||
|
||||
printf("PASS bsearch\n");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -16,8 +16,5 @@ int main(void) {
|
||||
ll = mydivt.rem;
|
||||
ll = atoll("10");
|
||||
_Exit(0);
|
||||
|
||||
;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,5 +23,4 @@ int main(void) {
|
||||
}
|
||||
fclose(fp);
|
||||
remove(file_name);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -8,5 +8,4 @@ int main(void) {
|
||||
mktemp(string);
|
||||
printf("%s\n",string);
|
||||
free(string);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -26,6 +26,4 @@ int main(void) {
|
||||
if(errno != 0) {
|
||||
printf("errno is not 0 (%d), something went wrong\n", errno);
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -25,6 +25,4 @@ int main(void) {
|
||||
if(errno != 0) {
|
||||
printf("errno is not 0 (%d), something went wrong\n", errno);
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -2,5 +2,4 @@
|
||||
|
||||
int main(void) {
|
||||
system("echo test of system");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -38,5 +38,4 @@ int main(void) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
puts("Correct memcmp");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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,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");
|
||||
}
|
||||
|
||||
@@ -18,5 +18,4 @@ int main(void) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
printf("strrch PASS, exiting with status code %d\n", 0);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -22,6 +22,4 @@ int main(void) {
|
||||
perror("clock");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -12,5 +12,4 @@ int main(void) {
|
||||
getcwd(cwd2, 4096);
|
||||
printf("final cwd: %s\n", cwd2);
|
||||
free(cwd2);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -67,5 +67,4 @@ int main(void) {
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int main(void) {
|
||||
write(STDOUT_FILENO, "Hello World!\n", 13);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -13,5 +13,4 @@ int main(void) {
|
||||
int stat_loc;
|
||||
waitpid(pid, &stat_loc, 0);
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,4 @@ int main(void) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user