Fix compiler warnings (#95)

Fix compiler warnings
This commit is contained in:
Ozan Tezcan 2022-08-20 18:56:21 +03:00 committed by GitHub
parent eb751789eb
commit 53d4a9158a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
57 changed files with 205 additions and 206 deletions

View File

@ -13,7 +13,7 @@
#include <stdio.h>
void example_str()
void example_str(void)
{
const char *it;
struct sc_array_str arr;
@ -34,7 +34,7 @@ void example_str()
sc_array_term(&arr);
}
void example_int()
void example_int(void)
{
struct sc_array_int arr;
@ -51,7 +51,7 @@ void example_int()
sc_array_term(&arr);
}
int main()
int main(void)
{
example_int();
example_str();

View File

@ -2,7 +2,7 @@
#include <stdio.h>
void example_str()
void example_str(void)
{
const char *it;
struct sc_array_str arr;
@ -23,7 +23,7 @@ void example_str()
sc_array_term(&arr);
}
void example_int()
void example_int(void)
{
struct sc_array_int arr;
@ -40,7 +40,7 @@ void example_int()
sc_array_term(&arr);
}
int main()
int main(void)
{
example_int();
example_str();

View File

@ -4,7 +4,7 @@
#include <stdio.h>
#include <stdlib.h>
void example_str()
void example_str(void)
{
const char *it;
struct sc_array_str arr;
@ -25,7 +25,7 @@ void example_str()
sc_array_term(&arr);
}
void example_int()
void example_int(void)
{
struct sc_array_int arr;
@ -101,7 +101,7 @@ static void test1(void)
sc_array_term(&arr);
}
void test2()
void test2(void)
{
int val;
struct sc_array_int arr;
@ -156,7 +156,7 @@ void test2()
sc_array_term(&arr);
}
void bounds_test()
void bounds_test(void)
{
int total = 0;
int val;
@ -225,7 +225,7 @@ void *__wrap_realloc(void *p, size_t n)
return __real_realloc(p, n);
}
void fail_test()
void fail_test(void)
{
int tmp;
int total = 0;

View File

@ -17,7 +17,7 @@
#include "sc_buf.h"
#include <stdio.h>
void basic()
void basic(void)
{
struct sc_buf buf;
sc_buf_init(&buf, 1024);
@ -33,7 +33,7 @@ void basic()
sc_buf_term(&buf);
}
void error_check()
void error_check(void)
{
uint32_t val, val2;
struct sc_buf buf;
@ -52,7 +52,7 @@ void error_check()
sc_buf_term(&buf);
}
int main()
int main(void)
{
basic();
error_check();
@ -72,7 +72,7 @@ int main()
#include "sc_buf.h"
#include <stdio.h>
int main()
int main(void)
{
uint32_t val, val2;
struct sc_buf buf;
@ -100,7 +100,7 @@ int main()
#include "sc_buf.h"
#include <stdio.h>
int main()
int main(void)
{
uint32_t val;
struct sc_buf buf;

View File

@ -2,7 +2,7 @@
#include <stdio.h>
void basic()
void basic(void)
{
struct sc_buf buf;
sc_buf_init(&buf, 1024);
@ -18,7 +18,7 @@ void basic()
sc_buf_term(&buf);
}
void error_check()
void error_check(void)
{
uint32_t val, val2;
struct sc_buf buf;
@ -38,7 +38,7 @@ void error_check()
sc_buf_term(&buf);
}
int main()
int main(void)
{
basic();
error_check();

View File

@ -4,7 +4,7 @@
#include <stdio.h>
#include <string.h>
void test1()
void test1(void)
{
const char *xstr;
struct sc_buf buf, buf2;
@ -257,7 +257,7 @@ void test1()
sc_buf_term(&buf);
}
void test2()
void test2(void)
{
unsigned char tmp[32];
struct sc_buf buf;
@ -410,7 +410,7 @@ int __wrap_vsnprintf(char *str, size_t size, const char *format, va_list ap)
return fail_vsnprintf_value;
}
void fail_test()
void fail_test(void)
{
int tmp;
unsigned char *p;
@ -622,7 +622,7 @@ void fail_test()
}
#endif
int main()
int main(void)
{
test1();
test2();

View File

@ -16,14 +16,14 @@
#include <stdio.h>
int main()
int main(void)
{
struct sc_cond cond;
sc_cond_init(&cond); // Init once
sc_cond_signal(&cond, "test"); // Call this on thread-1
char* p = sc_cond_wait(&cond); // Call this on another thread.
char *p = sc_cond_wait(&cond); // Call this on another thread.
printf("%s \n", p); // Prints "test"

View File

@ -241,7 +241,7 @@ int __wrap_pthread_cond_destroy(pthread_cond_t *c)
return -1;
}
void fail_test()
void fail_test(void)
{
struct sc_cond cond;
@ -285,7 +285,7 @@ void fail_test()
}
#endif
void test1()
void test1(void)
{
struct sc_cond cond;
struct sc_thread thread1;
@ -322,7 +322,7 @@ void test1()
assert(sc_cond_term(&cond) == 0);
}
int main()
int main(void)
{
test1();
fail_test();

View File

@ -2,7 +2,7 @@
#include <stdio.h>
int main()
int main(void)
{
uint32_t crc;
const uint8_t buf[100] = {0};

View File

@ -433,7 +433,7 @@ uint32_t sc_crc32(uint32_t crc, const uint8_t *buf, uint32_t len)
#endif
}
void sc_crc32_init()
void sc_crc32_init(void)
{
#ifdef HAVE_CRC32C
crc32_init_hw();

View File

@ -2,7 +2,7 @@
#include <stdio.h>
int main()
int main(void)
{
struct data {
int priority;

View File

@ -244,7 +244,7 @@ void fail_test()
}
#endif
int main()
int main(void)
{
example();
fail_test();

View File

@ -46,7 +46,7 @@ void string_example(void)
assert(rc == 0);
}
int main()
int main(void)
{
string_example();
file_example();

View File

@ -42,7 +42,7 @@ int cb2(void *arg, int line, const char *section, const char *key,
return 0;
}
void test2()
void test2(void)
{
int rc;
int count = 0;
@ -70,7 +70,7 @@ int cb3(void *arg, int line, const char *section, const char *key,
return 0;
}
void test3()
void test3(void)
{
int rc;
int count = 0;
@ -103,7 +103,7 @@ int cb4(void *arg, int line, const char *section, const char *key,
return 0;
}
void test4()
void test4(void)
{
int rc;
int count = 0;
@ -141,7 +141,7 @@ int cb5(int line, void *arg, const char *section, const char *key,
return 0;
}
void test5()
void test5(void)
{
int rc;
int count = 0;
@ -179,7 +179,7 @@ int cb6(void *arg, int line, const char *section, const char *key,
return -1;
}
void test6()
void test6(void)
{
int rc;
int count = 0;
@ -217,7 +217,7 @@ int cb7(void *arg, int line, const char *section, const char *key,
return 0;
}
void test7()
void test7(void)
{
int rc;
int count = 0;
@ -251,7 +251,7 @@ int cb8(void *arg, int line, const char *section, const char *key,
return 0;
}
void test8()
void test8(void)
{
int rc;
int count = 0;
@ -357,7 +357,7 @@ int cb9(void *arg, int line, const char *section, const char *key,
return 0;
}
void test9()
void test9(void)
{
int rc;
int count = 0;
@ -371,7 +371,7 @@ void test9()
assert(rc == 0);
}
void test10()
void test10(void)
{
int rc;
int count = 0;
@ -397,7 +397,7 @@ int cb11(void *arg, int line, const char *section, const char *key,
return 0;
}
void test11()
void test11(void)
{
int rc;
int count = 0;
@ -427,7 +427,7 @@ int cb12(void *arg, int line, const char *section, const char *key,
return 0;
}
void test12()
void test12(void)
{
int rc;
int count = 0;
@ -463,7 +463,7 @@ int cb13(void *arg, int line, const char *section, const char *key,
return 0;
}
void test13()
void test13(void)
{
int rc;
int count = 0;
@ -491,7 +491,7 @@ int cb14(void *arg, int line, const char *section, const char *key,
return -1;
}
void test14()
void test14(void)
{
int rc;
int count = 0;
@ -517,7 +517,7 @@ int cb15(void *arg, int line, const char *section, const char *key,
return -1;
}
void test15()
void test15(void)
{
int rc;
int count = 0;
@ -550,7 +550,7 @@ int cb16(void *arg, int line, const char *section, const char *key,
return 0;
}
void test16()
void test16(void)
{
int rc;
@ -636,7 +636,7 @@ int cb_fail(void *arg, int line, const char *section, const char *key,
return 0;
}
void test_fail()
void test_fail(void)
{
int rc;
FILE *fp;
@ -656,12 +656,12 @@ void test_fail()
fail_ferror = false;
}
#else
void test_fail()
void test_fail(void)
{
}
#endif
int main()
int main(void)
{
example();
test1();

View File

@ -16,7 +16,7 @@
#include <stdio.h>
int main()
int main(void)
{
struct user
{

View File

@ -2,7 +2,7 @@
#include <stdio.h>
int main()
int main(void)
{
struct user {
char *name;

View File

@ -174,7 +174,7 @@ static void test1(void)
}
}
int main()
int main(void)
{
test1();

View File

@ -14,7 +14,7 @@ int log_callback(void *arg, enum sc_log_level level, const char *fmt,
return 0;
}
int main()
int main(void)
{
const char *my_app_name = "my app";

View File

@ -363,7 +363,7 @@ void example(void)
sc_log_term(); // Call once on shutdown.
}
int main()
int main(void)
{
sc_log_set_thread_name("My thread");

View File

@ -59,7 +59,7 @@ void example_str(void)
sc_map_term_str(&map);
}
void example_int_to_str()
void example_int_to_str(void)
{
uint32_t key;
const char *value;
@ -98,7 +98,7 @@ void example_int_to_str()
sc_map_term_64s(&map);
}
int main()
int main(void)
{
example_str();
example_int_to_str();

View File

@ -20,7 +20,7 @@ void example_str(void)
sc_map_term_str(&map);
}
void example_int_to_str()
void example_int_to_str(void)
{
uint32_t key;
const char *value;
@ -59,7 +59,7 @@ void example_int_to_str()
sc_map_term_64s(&map);
}
int main()
int main(void)
{
example_str();
example_int_to_str();

View File

@ -23,7 +23,7 @@ void example(void)
sc_map_term_str(&map);
}
void example_int_to_str()
void example_int_to_str(void)
{
uint32_t key;
const char *value;
@ -81,7 +81,7 @@ static char *str_random(size_t size)
return dest;
}
void test_32()
void test_32(void)
{
struct sc_map_32 map;
@ -158,7 +158,7 @@ void test_32()
sc_map_term_32(&map);
}
void test_64()
void test_64(void)
{
struct sc_map_64 map;
@ -234,7 +234,7 @@ void test_64()
sc_map_term_64(&map);
}
void test_64v()
void test_64v(void)
{
struct sc_map_64v map;
@ -310,7 +310,7 @@ void test_64v()
sc_map_term_64v(&map);
}
void test_64s()
void test_64s(void)
{
struct sc_map_64s map;
@ -385,7 +385,7 @@ void test_64s()
sc_map_term_64s(&map);
}
void test_str()
void test_str(void)
{
const char *arr = "abcdefghijklmnoprstuvyzabcdefghijklmnoprstuvyzabcdef"
"ghijklmnoprstuvyz";
@ -490,7 +490,7 @@ void test_str()
sc_map_term_str(&map);
}
void test_sv()
void test_sv(void)
{
const char *arr = "abcdefghijklmnoprstuvyzabcdefghijklmnoprstuvyzabcdef"
"ghijklmnoprstuvyz";
@ -593,7 +593,7 @@ void test_sv()
sc_map_term_sv(&map);
}
void test_s64()
void test_s64(void)
{
const char *arr = "abcdefghijklmnoprstuvyzabcdefghijklmnoprstuvyzabcdef"
"ghijklmnoprstuvyz";
@ -701,7 +701,7 @@ void test_s64()
sc_map_term_s64(&map);
}
void test0()
void test0(void)
{
uint64_t val;
struct sc_map_64 map;
@ -749,7 +749,7 @@ void test0()
sc_map_term_64(&map);
}
void test1()
void test1(void)
{
struct sc_map_str map;
char *keys[128];
@ -901,7 +901,7 @@ void test1()
}
}
void test2()
void test2(void)
{
struct sc_map_32 map;
uint32_t keys[128];
@ -983,7 +983,7 @@ retry:
sc_map_term_32(&map);
}
void test3()
void test3(void)
{
struct sc_map_64 map;
uint64_t keys[128];
@ -1065,7 +1065,7 @@ retry:
sc_map_term_64(&map);
}
void test4()
void test4(void)
{
const char *c;
struct sc_map_64s map64s;
@ -1184,7 +1184,7 @@ void test4()
}
}
static void test5()
static void test5(void)
{
int t = 0;
uint64_t key, value;
@ -1219,7 +1219,7 @@ static void test5()
sc_map_term_64(&map);
}
static void test6()
static void test6(void)
{
const int count = 120000;
uint32_t val;
@ -1260,7 +1260,7 @@ static void test6()
free(values);
}
static void test_loop_foreach()
static void test_loop_foreach(void)
{
struct sc_map_32 map;
@ -1306,7 +1306,7 @@ static void test_loop_foreach()
sc_map_term_32(&map);
}
static void test_loop_foreach_key()
static void test_loop_foreach_key(void)
{
struct sc_map_32 map;
@ -1350,7 +1350,7 @@ static void test_loop_foreach_key()
sc_map_term_32(&map);
}
static void test_loop_foreach_value()
static void test_loop_foreach_value(void)
{
struct sc_map_32 map;
@ -1394,7 +1394,7 @@ static void test_loop_foreach_value()
sc_map_term_32(&map);
}
void test_loop_generic()
void test_loop_generic(void)
{
struct sc_map_64 map;
@ -1494,7 +1494,7 @@ void *__wrap_calloc(size_t n, size_t size)
return __real_calloc(n, size);
}
void fail_test_32()
void fail_test_32(void)
{
struct sc_map_32 map;
@ -1521,7 +1521,7 @@ void fail_test_32()
sc_map_term_32(&map);
}
void fail_test_64()
void fail_test_64(void)
{
struct sc_map_64 map;
@ -1548,7 +1548,7 @@ void fail_test_64()
sc_map_term_64(&map);
}
void fail_test_64v()
void fail_test_64v(void)
{
struct sc_map_64v map;
@ -1575,7 +1575,7 @@ void fail_test_64v()
sc_map_term_64v(&map);
}
void fail_test_64s()
void fail_test_64s(void)
{
struct sc_map_64s map;
@ -1602,7 +1602,7 @@ void fail_test_64s()
sc_map_term_64s(&map);
}
void fail_test_str()
void fail_test_str(void)
{
struct sc_map_str map;
const char *v;
@ -1642,7 +1642,7 @@ void fail_test_str()
sc_map_term_str(&map);
}
void fail_test_sv()
void fail_test_sv(void)
{
struct sc_map_sv map;
const char *v;
@ -1681,7 +1681,7 @@ void fail_test_sv()
sc_map_term_sv(&map);
}
void fail_test_s64()
void fail_test_s64(void)
{
struct sc_map_s64 map;
const char *v;
@ -1744,7 +1744,7 @@ void fail_test_s64(void)
}
#endif
int main()
int main(void)
{
example();
example_int_to_str();

View File

@ -4,7 +4,7 @@
#include <assert.h>
#include <stdio.h>
int main()
int main(void)
{
int rc;
struct sc_mmap mmap;

View File

@ -8,7 +8,7 @@
#include <fcntl.h>
#include <stdio.h>
void test1()
void test1(void)
{
int rc;
unsigned char *p;
@ -210,7 +210,7 @@ int __wrap_posix_fallocate64(int fd, off_t offset, off_t len)
return __real_posix_fallocate64(fd, offset, len);
}
void fail_test()
void fail_test(void)
{
int rc;
struct sc_mmap mmap;
@ -302,7 +302,7 @@ void fail_test()
}
#endif
int main()
int main(void)
{
test1();
fail_test();

View File

@ -258,7 +258,7 @@ int sc_mmap_init(struct sc_mmap *m, const char *name, int file_flags, int prot,
}
#else
do {
rc = posix_fallocate(fd, offset, len);
rc = posix_fallocate(fd, (off_t) offset, (off_t) len);
} while (rc == EINTR);
if (rc != 0) {
@ -268,7 +268,7 @@ int sc_mmap_init(struct sc_mmap *m, const char *name, int file_flags, int prot,
#endif
}
p = mmap(NULL, len, prot, map_flags, fd, offset);
p = mmap(NULL, len, prot, map_flags, fd, (off_t) offset);
if (p == MAP_FAILED) {
goto cleanup_fd;
}

View File

@ -1,6 +1,6 @@
#include "sc_mutex.h"
int main()
int main(void)
{
struct sc_mutex mutex;

View File

@ -72,7 +72,7 @@ int __wrap_pthread_mutex_init(pthread_mutex_t *__mutex,
#endif
int main()
int main(void)
{
struct sc_mutex mutex;
#ifdef SC_HAVE_WRAP

View File

@ -43,5 +43,6 @@ int main(int argc, char *argv[])
return 0;
}```
}
```

View File

@ -9,7 +9,7 @@ static struct sc_option_item options[] = {{.letter = 's', .name = NULL},
{.letter = 'k', .name = "key"},
{.letter = 'h', .name = "help"}};
void test1()
void test1(void)
{
char *value;
int argc = 5;
@ -43,7 +43,7 @@ void test1()
}
}
void test2()
void test2(void)
{
char *value;
int argc = 2;
@ -66,7 +66,7 @@ void test2()
}
}
void test3()
void test3(void)
{
char *value;
int argc = 2;
@ -90,7 +90,7 @@ void test3()
}
}
void test4()
void test4(void)
{
char *value;
@ -118,7 +118,7 @@ static struct sc_option_item options2[] = {{.letter = 's', .name = "sadsa"},
{.letter = 'm', .name = "sad"},
{.letter = 'k', .name = "key3"},
{.letter = 'h', .name = "dsadsa"}};
void test5()
void test5(void)
{
char *value;
@ -142,7 +142,7 @@ void test5()
}
}
void test6()
void test6(void)
{
char *value;
int argc = 2;
@ -165,7 +165,7 @@ void test6()
}
}
void test7()
void test7(void)
{
char *value;
int argc = 2;
@ -188,7 +188,7 @@ void test7()
}
}
void test8()
void test8(void)
{
char *value;
int argc = 2;
@ -211,7 +211,7 @@ void test8()
}
}
int main()
int main(void)
{
test1();
test2();

View File

@ -2,7 +2,7 @@
#include <stdlib.h>
int main()
int main(void)
{
size_t total = 0;

View File

@ -94,8 +94,8 @@ static void sc_perf_set(struct sc_perf_item *items, size_t size)
.exclude_kernel = false,
.exclude_hv = false};
fd = syscall(__NR_perf_event_open, &p, 0, -1, -1,
PERF_FLAG_FD_CLOEXEC);
fd = (int) syscall(__NR_perf_event_open, &p, 0, -1, -1,
PERF_FLAG_FD_CLOEXEC);
if (fd == -1) {
fprintf(stderr,
"Failed to set counter : %s , probably your "
@ -129,7 +129,7 @@ static void sc_read(struct sc_perf_item *items, size_t size)
items[i].active = n;
}
items[i].value += fmt.value * n;
items[i].value += (double) fmt.value * n;
}
}

View File

@ -116,8 +116,8 @@ static const struct sc_perf_event sc_perf_hw[] = {
// clang-format on
void sc_perf_start();
void sc_perf_pause();
void sc_perf_end();
void sc_perf_start(void);
void sc_perf_pause(void);
void sc_perf_end(void);
#endif

View File

@ -122,7 +122,7 @@ void example(void)
sc_queue_term(&queue);
}
void test0()
void test0(void)
{
uint32_t val;
struct sc_queue_32 q;
@ -257,7 +257,7 @@ void test1(void)
sc_queue_term(&p);
}
int main()
int main(void)
{
fail_test();
example();

View File

@ -1,4 +1,4 @@
int main()
int main(void)
{
return 0;
}

View File

@ -8,7 +8,7 @@
#include <stdio.h>
#include <string.h>
void test1()
void test1(void)
{
int64_t x;
char *t;
@ -127,7 +127,7 @@ void test1()
assert(strcmp(t, "16.00 EB") == 0);
}
void test_rand()
void test_rand(void)
{
unsigned char tmp[256] = {0, 1, 2, 3, 4, 5, 6, 6,
6, 6, 1, 5, 3, 5, 5, 6};
@ -200,7 +200,7 @@ extern long long int __wrap_strtoll(const char *__restrict nptr,
return __real_strtoll(nptr, endptr, base);
}
void fail_test()
void fail_test(void)
{
char *t;
int64_t val;
@ -239,11 +239,11 @@ void fail_test()
}
#else
void fail_test()
void fail_test(void)
{
}
#endif
int main()
int main(void)
{
test1();
test_rand();

View File

@ -22,7 +22,7 @@
#include <stdio.h>
#include <unistd.h>
int main()
int main(void)
{
char tmp[1];
int fds[2];

View File

@ -472,7 +472,7 @@ static void sc_signal_on_fatal(int sig, siginfo_t *info, void *context)
#endif
}
int sc_signal_init()
int sc_signal_init(void)
{
bool rc = true;
struct sigaction action;

View File

@ -66,7 +66,7 @@ extern volatile sig_atomic_t sc_signal_will_shutdown;
* Init signal handler, hooks for shutdown signals and some fatal signals.
* @return '0' on success, '-1' on failure
*/
int sc_signal_init();
int sc_signal_init(void);
/**
* Signal safe logging

View File

@ -1,6 +1,6 @@
#include "sc_signal.h"
int main()
int main(void)
{
return 0;
}

View File

@ -3,7 +3,7 @@
#include <assert.h>
#include <string.h>
void test1()
void test1(void)
{
char tmp[128] = "";
@ -41,7 +41,7 @@ void test1()
sc_signal_log(1, tmp, sizeof(tmp), "%s", "test");
}
void test2()
void test2(void)
{
assert(sc_signal_init() == 0);
}
@ -91,7 +91,7 @@ void test3x(int signal)
}
}
void test3()
void test3(void)
{
test3x(SIGSEGV);
test3x(SIGABRT);
@ -129,14 +129,14 @@ void test4x(int signal)
}
}
void test4()
void test4(void)
{
test4x(SIGINT);
test4x(SIGTERM);
test4x(SIGUSR2);
}
void test5()
void test5(void)
{
pid_t pid = fork();
if (pid == -1) {
@ -161,7 +161,7 @@ void test5()
}
}
void test6()
void test6(void)
{
pid_t pid = fork();
if (pid == -1) {
@ -185,7 +185,7 @@ void test6()
}
}
void test7()
void test7(void)
{
pid_t pid = fork();
if (pid == -1) {
@ -208,7 +208,7 @@ void test7()
}
}
void test8()
void test8(void)
{
pid_t pid = fork();
if (pid == -1) {
@ -232,7 +232,7 @@ void test8()
}
}
void test9()
void test9(void)
{
fail_signal = true;
assert(sc_signal_init() != 0);
@ -240,30 +240,30 @@ void test9()
}
#else
void test3()
void test3(void)
{
}
void test4()
void test4(void)
{
}
void test5()
void test5(void)
{
}
void test6()
void test6(void)
{
}
void test7()
void test7(void)
{
}
void test8()
void test8(void)
{
}
void test9()
void test9(void)
{
}
#endif
int main()
int main(void)
{
test1();
test2();

View File

@ -183,24 +183,24 @@ int sc_sock_notify_systemd(const char *msg)
msghdr.msg_namelen = sizeof(struct sockaddr_un);
}
rc = sendmsg(fd, &msghdr, MSG_NOSIGNAL);
rc = (int) sendmsg(fd, &msghdr, MSG_NOSIGNAL);
close(fd);
return rc < 0 ? -1 : 0;
}
int sc_sock_startup()
int sc_sock_startup(void)
{
return 0;
}
int sc_sock_cleanup()
int sc_sock_cleanup(void)
{
return 0;
}
static int sc_sock_err()
static int sc_sock_err(void)
{
return errno;
}
@ -1028,7 +1028,7 @@ retry:
goto retry;
}
return n;
return (int) n;
}
int sc_sock_pipe_read(struct sc_sock_pipe *p, void *data, unsigned int len)
@ -1042,7 +1042,7 @@ retry:
goto retry;
}
return n;
return (int) n;
}
#endif

View File

@ -92,13 +92,13 @@ struct sc_sock {
* Call once when your application starts.
* @return 0 on success, negative on failure.
*/
int sc_sock_startup();
int sc_sock_startup(void);
/**
* Call once before your application terminates
* @return 0 on success, negative on failure.
*/
int sc_sock_cleanup();
int sc_sock_cleanup(void);
/**
* Initialize sock

View File

@ -1,5 +1,5 @@
int main()
int main(void)
{
return 0;
}

View File

@ -207,7 +207,7 @@ void *client_ip4(void *arg)
return NULL;
}
void test_ip4()
void test_ip4(void)
{
struct sc_thread thread1;
struct sc_thread thread2;
@ -267,7 +267,7 @@ void *client_ip6(void *arg)
return NULL;
}
void test_ip6()
void test_ip6(void)
{
struct sc_thread thread1;
struct sc_thread thread2;
@ -335,7 +335,7 @@ void *client_unix(void *arg)
return NULL;
}
void test_unix()
void test_unix(void)
{
struct sc_thread thread1;
struct sc_thread thread2;
@ -350,7 +350,7 @@ void test_unix()
assert(sc_thread_term(&thread2) == 0);
}
void test1()
void test1(void)
{
int rc;
char tmp[5];
@ -835,7 +835,7 @@ int __wrap_getsockname(int fd, struct sockaddr *addr, socklen_t *len)
return __real_getsockname(fd, addr, len);
}
void poll_fail_test()
void poll_fail_test(void)
{
bool fail;
int i;
@ -1027,7 +1027,7 @@ void poll_fail_test()
assert(sc_sock_poll_term(&poll) == 0);
}
void pipe_fail_test()
void pipe_fail_test(void)
{
struct sc_sock_pipe pipe;
fail_pipe = true;
@ -1062,7 +1062,7 @@ void pipe_fail_test()
fail_read_errno = 0;
}
void sock_fail_test()
void sock_fail_test(void)
{
struct sc_sock sock;
struct sc_sock sock2;
@ -1162,7 +1162,7 @@ void sock_fail_test()
fail_socket = 0;
}
void sock_fail_test2()
void sock_fail_test2(void)
{
int rc;
struct sc_sock sock, client, in;
@ -1281,7 +1281,7 @@ void sock_fail_test2()
assert(sc_sock_term(&client) == 0);
}
void sock_fail_test3()
void sock_fail_test3(void)
{
struct sc_sock client;
struct sc_sock_poll poll;
@ -1404,20 +1404,20 @@ void sock_fail_test3()
}
#else
void sock_fail_test()
void sock_fail_test(void)
{
}
void sock_fail_test2()
void sock_fail_test2(void)
{
}
void sock_fail_test3()
void sock_fail_test3(void)
{
}
void poll_fail_test()
void poll_fail_test(void)
{
}
void pipe_fail_test()
void pipe_fail_test(void)
{
}
@ -1426,7 +1426,8 @@ void pipe_fail_test()
void *server(void *arg)
{
(void) arg;
int wr = 2, ev;
uint32_t ev;
int wr = 2;
int rc, received = 0;
struct sc_sock srv, in, *sock;
struct sc_sock_poll p;
@ -1552,7 +1553,7 @@ void *client(void *arg)
return NULL;
}
void test_poll()
void test_poll(void)
{
struct sc_thread thread1;
struct sc_thread thread2;
@ -1567,7 +1568,7 @@ void test_poll()
assert(sc_thread_term(&thread2) == 0);
}
void test_err()
void test_err(void)
{
struct sc_sock sock;
char buf[128];
@ -1606,7 +1607,7 @@ void test_err()
assert(*sc_sock_poll_err(&p) != '\0');
}
int main()
int main(void)
{
#ifdef SC_HAVE_WRAP
assert(sc_mutex_init(&mutex) == 0);

View File

@ -2,7 +2,7 @@
#include <stdio.h>
int main()
int main(void)
{
char *s1;

View File

@ -60,7 +60,7 @@ int __wrap_vsnprintf(char *str, size_t size, const char *format, va_list ap)
return fail_vnsprintf_value;
}
void test1()
void test1(void)
{
char *m = sc_str_create(NULL);
sc_str_destroy(&m);
@ -170,7 +170,7 @@ void test1()
fail_vsnprintf = false;
}
void test2()
void test2(void)
{
char buf[4000];
memset(buf, 'x', 4000);
@ -267,7 +267,7 @@ void test2()
#endif
void test3()
void test3(void)
{
const char *tokens = "token;token;token;token";
char *save = NULL;
@ -350,7 +350,7 @@ void test3()
sc_str_destroy(&str);
}
void test4()
void test4(void)
{
char *save = NULL;
const char *token;
@ -415,7 +415,7 @@ void test4()
sc_str_destroy(&str);
}
void test5()
void test5(void)
{
char *s1, *s2;
@ -519,7 +519,7 @@ void test5()
sc_str_destroy(&s1);
}
void test6()
void test6(void)
{
char *s1, *s2;
char *save = NULL;
@ -588,7 +588,7 @@ void test6()
sc_str_destroy(&s2);
}
int main()
int main(void)
{
#ifdef SC_HAVE_WRAP

View File

@ -8,7 +8,7 @@ void *fn(void *arg)
return arg;
}
int main()
int main(void)
{
struct sc_thread thread;

View File

@ -11,7 +11,7 @@ void *fn(void *arg)
return arg;
}
void test1()
void test1(void)
{
int rc;
void *ret;
@ -76,7 +76,7 @@ int __wrap_pthread_join(pthread_t th, void **thread_return)
return rc;
}
void fail_test()
void fail_test(void)
{
struct sc_thread thread;
@ -99,12 +99,12 @@ void fail_test()
}
#else
void fail_test()
void fail_test(void)
{
}
#endif
int main()
int main(void)
{
test1();
fail_test();

View File

@ -44,7 +44,7 @@
#include <time.h>
#endif
uint64_t sc_time_ms()
uint64_t sc_time_ms(void)
{
#if defined(_WIN32) || defined(_WIN64)
FILETIME ft;
@ -63,11 +63,11 @@ uint64_t sc_time_ms()
assert(rc == 0);
(void) rc;
return ts.tv_sec * 1000 + (uint64_t) (ts.tv_nsec / 10e6);
return ts.tv_sec * 1000 + (uint64_t) (ts.tv_nsec / 1000000);
#endif
}
uint64_t sc_time_ns()
uint64_t sc_time_ns(void)
{
#if defined(_WIN32) || defined(_WIN64)
FILETIME ft;
@ -90,7 +90,7 @@ uint64_t sc_time_ns()
#endif
}
uint64_t sc_time_mono_ms()
uint64_t sc_time_mono_ms(void)
{
#if defined(_WIN32) || defined(_WIN64)
// System frequency does not change at run-time, cache it
@ -117,7 +117,7 @@ uint64_t sc_time_mono_ms()
#endif
}
uint64_t sc_time_mono_ns()
uint64_t sc_time_mono_ns(void)
{
#if defined(_WIN32) || defined(_WIN64)
static int64_t frequency = 0;
@ -151,8 +151,8 @@ int sc_time_sleep(uint64_t millis)
int rc;
struct timespec t, rem;
rem.tv_sec = millis / 1000;
rem.tv_nsec = (millis % 1000) * 1000000;
rem.tv_sec = (time_t) millis / 1000;
rem.tv_nsec = (long) (millis % 1000) * 1000000;
do {
t = rem;

View File

@ -39,25 +39,25 @@
* Wall clock time. Gets CLOCK_REALTIME on Posix.
* @return current timestamp in milliseconds.
*/
uint64_t sc_time_ms();
uint64_t sc_time_ms(void);
/**
* Wall clock time. Gets CLOCK_REALTIME on Posix.
* @return current timestamp in nanoseconds.
*/
uint64_t sc_time_ns();
uint64_t sc_time_ns(void);
/**
* Monotonic timer. Gets CLOCK_MONOTONIC on Posix
* @return current timestamp in milliseconds.
*/
uint64_t sc_time_mono_ms();
uint64_t sc_time_mono_ms(void);
/**
* Monotonic timer. Gets CLOCK_MONOTONIC on Posix
* @return Current timestamp in nanoseconds.
*/
uint64_t sc_time_mono_ns();
uint64_t sc_time_mono_ns(void);
/**
* @param millis milliseconds to sleep.

View File

@ -2,7 +2,7 @@
#include <stdio.h>
int main()
int main(void)
{
uint64_t t = sc_time_ms();
sc_time_sleep(1000);

View File

@ -109,7 +109,7 @@ void test4(void)
}
#endif
int main()
int main(void)
{
test1();
test2();

View File

@ -192,7 +192,7 @@ uint64_t sc_timer_timeout(struct sc_timer *t, uint64_t timestamp, void *arg,
callback(arg, timeout, item->type, item->data);
// Recalculates position each time because there
// might be newly added timers in the callback
// might be newly added timers in the callback,
// and it might require expansion of the list.
base = t->wheel * head;
}

View File

@ -8,7 +8,7 @@
#include <stdio.h>
#include <time.h>
uint64_t time_ms();
uint64_t time_ms(void);
void sleep_ms(uint64_t milliseconds);
void callback(void *arg, uint64_t timeout, uint64_t type, void *data)
@ -24,7 +24,7 @@ void callback(void *arg, uint64_t timeout, uint64_t type, void *data)
sc_timer_add(timer, 1000, 1, "timer1");
}
int main()
int main(void)
{
uint64_t next_timeout;
struct sc_timer timer;
@ -47,7 +47,7 @@ int main()
#include <sys/time.h>
#endif
uint64_t time_ms()
uint64_t time_ms(void)
{
#if defined(_WIN32) || defined(_WIN64)
// System frequency does not change at run-time, cache it

View File

@ -17,7 +17,7 @@
#include <unistd.h>
#endif
uint64_t time_ms()
uint64_t time_ms(void)
{
#if defined(_WIN32) || defined(_WIN64)
// System frequency does not change at run-time, cache it
@ -68,14 +68,11 @@ void callback(void *arg, uint64_t timeout, uint64_t type, void *data)
(void) timeout;
(void) type;
static int idx = 0;
count--;
uint64_t id = (uintptr_t) data;
assert(ids[id] != SC_TIMER_INVALID);
ids[id] = SC_TIMER_INVALID;
assert((int) (uintptr_t) arg == 333);
idx++;
}
void test1(void)
@ -326,7 +323,7 @@ void fail_test(void)
}
#endif
int main()
int main(void)
{
fail_test();
test1();

View File

@ -2,7 +2,7 @@
#include <stdio.h>
int main()
int main(void)
{
struct sc_uri *uri;
uri = sc_uri_create("http://user:pass@any.com:8042/over/"

View File

@ -317,7 +317,7 @@ int __wrap_sprintf(char *str, const char *format, ...)
return fail_sprintf;
}
void fail_test()
void fail_test(void)
{
struct sc_uri *uri;
fail_malloc = true;
@ -362,7 +362,7 @@ void fail_test()
}
#endif
int main()
int main(void)
{
test1();
test2();