tests: Fix function signatures
This commit is contained in:
+8
-8
@@ -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.
|
||||
if you need to rebuild relibc.
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
int main(int argc, char ** argv) {
|
||||
int main(void) {
|
||||
char *str = (char *) alloca(17);
|
||||
|
||||
memset(str, 'A', 16);
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
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]));
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
int main(void) {
|
||||
uint32_t hl = 0xBADFACED;
|
||||
uint32_t nl = htonl(hl);
|
||||
assert(nl == 0xEDACDFBA);
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main() {
|
||||
int main(void) {
|
||||
assert(1 == 1);
|
||||
assert(1 + 1 == 2);
|
||||
puts("yay!");
|
||||
|
||||
+1
-1
@@ -16,6 +16,6 @@ TEST(102)
|
||||
TEST(103)
|
||||
TEST(104)
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
int main(void) {
|
||||
puts("main");
|
||||
}
|
||||
|
||||
+1
-1
@@ -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) {
|
||||
|
||||
+1
-1
@@ -16,6 +16,6 @@ TEST(102)
|
||||
TEST(103)
|
||||
TEST(104)
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
int main(void) {
|
||||
puts("main");
|
||||
}
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main() {
|
||||
int main(void) {
|
||||
printf("%lu\n", sizeof(struct dirent));
|
||||
|
||||
DIR* dir = opendir("example_dir/");
|
||||
|
||||
@@ -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) {
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
int main(void) {
|
||||
chdir("nonexistent");
|
||||
printf("errno: %d = %s\n", errno, strerror(errno));
|
||||
perror("perror");
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int main(int argc, char ** argv) {
|
||||
int main(void) {
|
||||
int fd = creat("create.out", 0755);
|
||||
if (fd >= 0) {
|
||||
write(fd, "Hello World!\n", 13);
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int main() {
|
||||
int main(void) {
|
||||
//Lose our fd and pull it again
|
||||
creat("fcntl.out", 0777);
|
||||
int newfd = open("fcntl.out", 0);
|
||||
|
||||
+1
-1
@@ -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);
|
||||
|
||||
+3
-3
@@ -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();
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
int main() {
|
||||
int main(void) {
|
||||
// TODO: Implement locale properly and test it here
|
||||
char* val = setlocale(LC_ALL, NULL);
|
||||
if (strcmp(val, "C") == 0) {
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char ** argv) {
|
||||
int main(void) {
|
||||
double pi = 3.14;
|
||||
float c = cos(pi);
|
||||
printf("cos(%f) = %f\n", pi, c);
|
||||
|
||||
+1
-1
@@ -225,6 +225,6 @@ do_test (void)
|
||||
return (error_count != 0);
|
||||
}
|
||||
|
||||
int main() {
|
||||
int main(void) {
|
||||
do_test();
|
||||
}
|
||||
|
||||
+1
-1
@@ -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);
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
#include <regex.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main() {
|
||||
int main(void) {
|
||||
regex_t regex;
|
||||
char error_buf[256];
|
||||
|
||||
|
||||
@@ -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");
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
#include <sys/select.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int main() {
|
||||
int main(void) {
|
||||
int fd = open("select.c", 0, 0);
|
||||
|
||||
fd_set read;
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
#include <stdio.h>
|
||||
#include <setjmp.h>
|
||||
|
||||
int main() {
|
||||
int main(void) {
|
||||
jmp_buf buf;
|
||||
if (setjmp(buf)) {
|
||||
puts("hi from jump");
|
||||
|
||||
+1
-1
@@ -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);
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(int argc, char ** argv) {
|
||||
int main(void) {
|
||||
FILE *f = fopen("stdio/stdio.in", "r");
|
||||
printf("%c\n", fgetc(f));
|
||||
ungetc('H', f);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include <stdio.h>
|
||||
|
||||
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);
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
#include <stdio.h>
|
||||
|
||||
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];
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
|
||||
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
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
int main(void) {
|
||||
FILE *fp = fopen("stdio/fread.in", "rb");
|
||||
|
||||
char buf[33] = { 0 };
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char ** argv) {
|
||||
int main(void) {
|
||||
freopen("stdio/stdio.in", "r", stdin);
|
||||
char in[6];
|
||||
fgets(in, 6, stdin);
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main() {
|
||||
int main(void) {
|
||||
FILE *f = fopen("stdio/stdio.in", "r");
|
||||
if (fseek(f, 14, SEEK_CUR) < 0) {
|
||||
puts("fseek error");
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
|
||||
int main(int argc, char ** argv) {
|
||||
int main(void) {
|
||||
FILE *f = fopen("stdio/fwrite.out", "w");
|
||||
const char ptr[] = "Hello World!";
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char ** argv) {
|
||||
int main(void) {
|
||||
ungetc('h', stdin);
|
||||
char c;
|
||||
if ((c = getchar()) == 'h') {
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main() {
|
||||
int main(void) {
|
||||
FILE* f = fopen("stdio/stdio.in", "r");
|
||||
|
||||
flockfile(f);
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int main(void) {
|
||||
FILE *fp;
|
||||
int status;
|
||||
char path[256];
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include <stdio.h>
|
||||
|
||||
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",
|
||||
|
||||
@@ -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);
|
||||
|
||||
+1
-1
@@ -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);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
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);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
int main(int argc, char ** argv) {
|
||||
int main(void) {
|
||||
char buffer[72];
|
||||
|
||||
int ret = sprintf(
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
int main(void) {
|
||||
char * s = "azAZ9."; // test boundaries
|
||||
long l = a64l(s);
|
||||
if (l != 194301926) {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(int argc, char ** argv) {
|
||||
int main(void) {
|
||||
char * ptr = (char *)malloc(256);
|
||||
printf("malloc %p\n", ptr);
|
||||
int i;
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
int main(void) {
|
||||
double d = atof("-3.14");
|
||||
printf("%f\n", d);
|
||||
return 0;
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
int main(void) {
|
||||
printf("%d\n", atoi(" -42"));
|
||||
printf("%d\n", atoi(" +555"));
|
||||
printf("%d\n", atoi(" 1234567890 "));
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
+3
-4
@@ -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);
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
int main() {
|
||||
int main(void) {
|
||||
//puts(getenv("SHELL"));
|
||||
//puts(getenv("CC"));
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
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);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
int main(void) {
|
||||
char* string = (char*) calloc(20, sizeof(char));
|
||||
strcpy(string, "tempXXXXXX");
|
||||
mktemp(string);
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
int main(void) {
|
||||
printf("%d\n", rand());
|
||||
srand(259);
|
||||
printf("%d\n", rand());
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
int main() {
|
||||
int main(void) {
|
||||
char* path = realpath("stdlib/realpath.c", NULL);
|
||||
if (!path) {
|
||||
perror("realpath");
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main() {
|
||||
int main(void) {
|
||||
char* endptr = 0;
|
||||
double d;
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
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));
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
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));
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(int argc, char ** argv) {
|
||||
int main(void) {
|
||||
system("echo test of system");
|
||||
return 0;
|
||||
}
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
int main(int argc, char ** argv) {
|
||||
int main(void) {
|
||||
puts("# mem #");
|
||||
char arr[100];
|
||||
memset(arr, 0, 100); // Compiler builtin, should work
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
int main(void) {
|
||||
char dest1[12] = "hello";
|
||||
printf("%s\n", strcat(dest1, " world")); // should be hello world
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
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
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
int main() {
|
||||
int main(void) {
|
||||
char dst[20];
|
||||
|
||||
strcpy(dst, "strcpy works!");
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
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
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
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));
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
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"
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
int main(void) {
|
||||
char s0[] = "hello, world";
|
||||
char* ptr = strrchr(s0, 'l');
|
||||
if (ptr != &s0[10]) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
int main(void) {
|
||||
char *hello = "hello";
|
||||
char *world = "world";
|
||||
char *banana = "banana";
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
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"));
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
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";
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
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;
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
#include <stdio.h>
|
||||
#include <strings.h>
|
||||
|
||||
int main() {
|
||||
int main(void) {
|
||||
assert(!bcmp("hello", "hehe", 2));
|
||||
assert(bcmp("hello", "haha", 2));
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include <stdio.h>
|
||||
#include <sys/utsname.h>
|
||||
|
||||
int main() {
|
||||
int main(void) {
|
||||
struct utsname system_info;
|
||||
|
||||
int result = uname(&system_info);
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
int main(void) {
|
||||
time_t a = 0;
|
||||
struct tm *time_info = gmtime(&a);
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include <sys/time.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main() {
|
||||
int main(void) {
|
||||
struct timeval tv;
|
||||
gettimeofday(&tv, NULL);
|
||||
printf("%ld: %ld\n", tv.tv_sec, tv.tv_usec);
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
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" };
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
|
||||
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) {
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
#include <assert.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
int main() {
|
||||
int main(void) {
|
||||
struct timeval x = { .tv_usec = 15 };
|
||||
struct timeval y = { 0 };
|
||||
struct timeval z = { 0 };
|
||||
|
||||
+2
-1
@@ -18,7 +18,8 @@ int check(time_t input) {
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
int main() {
|
||||
|
||||
int main(void) {
|
||||
struct tm t = { 0 };
|
||||
|
||||
t.tm_year = 71;
|
||||
|
||||
@@ -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");
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
#include <time.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
int main(void) {
|
||||
struct timespec tm = {0, 0};
|
||||
|
||||
int cgt = clock_gettime(CLOCK_REALTIME, &tm);
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
#include <sys/times.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int main() {
|
||||
int main(void) {
|
||||
struct tms tms;
|
||||
printf("return: %ld\n", times(&tms));
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int main() {
|
||||
int main(void) {
|
||||
if (access("example_dir/1-never-gonna-give-you-up", R_OK | W_OK)) {
|
||||
perror("access");
|
||||
return 1;
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
|
||||
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;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
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);
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
int main(void) {
|
||||
creat("dup.out", 0777);
|
||||
int fd1 = open("dup.out", 0);
|
||||
int fd2 = dup(fd1);
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
int main(void) {
|
||||
char* args[] = {"sh", "-c", "echo 'exec works :D'", NULL};
|
||||
execv("/bin/sh", args);
|
||||
perror("execv");
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main (int argc, char** argv) {
|
||||
int main(void) {
|
||||
int fd = open("..", 0, 0);
|
||||
int status;
|
||||
status = fchdir(fd);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main (int argc, char** argv) {
|
||||
int main(void) {
|
||||
int fd = open(".", 0, 0);
|
||||
int status;
|
||||
status = fsync(fd);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main (int argc, char** argv) {
|
||||
int main(void) {
|
||||
int fd = creat("ftruncate.out", 0777);
|
||||
int status;
|
||||
status = ftruncate(fd, 100);
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int main() {
|
||||
int main(void) {
|
||||
char first[PATH_MAX];
|
||||
getcwd(first, PATH_MAX);
|
||||
puts(first);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int main() {
|
||||
int main(void) {
|
||||
char* hostname = malloc(256);
|
||||
if (gethostname(hostname, 256) == 0) {
|
||||
printf("Hostname: %s\n", hostname);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
int main(void) {
|
||||
gid_t egid = getegid();
|
||||
uid_t euid = geteuid();
|
||||
gid_t gid = getgid();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int main() {
|
||||
int main(void) {
|
||||
// 1 is stdout
|
||||
if (isatty(1)) {
|
||||
puts("'Tis a tty :D");
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
int main(void) {
|
||||
printf("%ld\n", sizeof(struct stat));
|
||||
|
||||
struct stat buf;
|
||||
|
||||
@@ -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);
|
||||
|
||||
+1
-3
@@ -3,9 +3,7 @@
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
|
||||
int main(void) {
|
||||
int pid, pip[2];
|
||||
char instring[20];
|
||||
char * outstring = "Hello World!";
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include <sys/stat.h>
|
||||
#include <stdio.h>
|
||||
|
||||
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);
|
||||
|
||||
@@ -6,8 +6,7 @@
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
int main(void) {
|
||||
sleep(2);
|
||||
perror("sleep");
|
||||
usleep(1000);
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int main() {
|
||||
int main(void) {
|
||||
printf("%ld\n", sizeof(struct stat));
|
||||
|
||||
struct stat buf;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include <unistd.h>
|
||||
|
||||
int main(int argc, char ** argv) {
|
||||
int main(void) {
|
||||
write(STDOUT_FILENO, "Hello World!\n", 13);
|
||||
return 0;
|
||||
}
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
int main(void) {
|
||||
pid_t pid = fork();
|
||||
if (pid == 0) {
|
||||
// child
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user