Surprise: void x(); accepts any parameter in C!

Prevents accidentally passing parameters that would then be ignored.

C++ is more reasonable, so nothing to do there.
This commit is contained in:
def 2020-04-12 19:56:11 +02:00
parent 4c00e4533c
commit a951845083
2 changed files with 41 additions and 41 deletions

View file

@ -103,7 +103,7 @@ void dbg_assert_imp(const char *filename, int line, int test, const char *msg)
}
}
void dbg_break_imp()
void dbg_break_imp(void)
{
#ifdef __GNUC__
__builtin_trap();
@ -231,7 +231,7 @@ void dbg_logger(DBG_LOGGER logger, DBG_LOGGER_FINISH finish, void *user)
num_loggers++;
}
void dbg_logger_stdout()
void dbg_logger_stdout(void)
{
#if defined(CONF_FAMILY_WINDOWS)
dbg_logger(logger_stdout_sync, 0, 0);
@ -240,7 +240,7 @@ void dbg_logger_stdout()
#endif
}
void dbg_logger_debugger()
void dbg_logger_debugger(void)
{
#if defined(CONF_FAMILY_WINDOWS)
dbg_logger(logger_debugger, 0, 0);
@ -735,7 +735,7 @@ void thread_wait(void *thread)
#endif
}
void thread_yield()
void thread_yield(void)
{
#if defined(CONF_FAMILY_UNIX)
int result = sched_yield();
@ -793,7 +793,7 @@ typedef CRITICAL_SECTION LOCKINTERNAL;
#error not implemented on this platform
#endif
LOCK lock_create()
LOCK lock_create(void)
{
LOCKINTERNAL *lock = (LOCKINTERNAL *)malloc(sizeof(*lock));
#if defined(CONF_FAMILY_UNIX)
@ -917,13 +917,13 @@ void sphore_destroy(SEMAPHORE *sem)
static int new_tick = -1;
void set_new_tick()
void set_new_tick(void)
{
new_tick = 1;
}
/* ----- time ----- */
int64 time_get_impl()
int64 time_get_impl(void)
{
static int64 last = 0;
{
@ -964,7 +964,7 @@ int64 time_get_impl()
}
}
int64 time_get()
int64 time_get(void)
{
static int64 last = 0;
if(new_tick == 0)
@ -976,7 +976,7 @@ int64 time_get()
return last;
}
int64 time_freq()
int64 time_freq(void)
{
#if defined(CONF_PLATFORM_MACOSX)
return 1000000000;
@ -991,7 +991,7 @@ int64 time_freq()
#endif
}
int64 time_get_microseconds()
int64 time_get_microseconds(void)
{
#if defined(CONF_FAMILY_WINDOWS)
return (time_get_impl() * (int64)1000000) / time_freq();
@ -1902,7 +1902,7 @@ int net_tcp_close(NETSOCKET sock)
return priv_net_close_all_sockets(sock);
}
int net_errno()
int net_errno(void)
{
#if defined(CONF_FAMILY_WINDOWS)
return WSAGetLastError();
@ -1911,7 +1911,7 @@ int net_errno()
#endif
}
int net_would_block()
int net_would_block(void)
{
#if defined(CONF_FAMILY_WINDOWS)
return net_errno() == WSAEWOULDBLOCK;
@ -1920,7 +1920,7 @@ int net_would_block()
#endif
}
int net_init()
int net_init(void)
{
#if defined(CONF_FAMILY_WINDOWS)
WSADATA wsaData;
@ -1933,7 +1933,7 @@ int net_init()
}
#if defined(CONF_FAMILY_UNIX)
UNIXSOCKET net_unix_create_unnamed()
UNIXSOCKET net_unix_create_unnamed(void)
{
return socket(AF_UNIX, SOCK_DGRAM, 0);
}
@ -2292,7 +2292,7 @@ int net_socket_read_wait(NETSOCKET sock, int time)
return 0;
}
int time_timestamp()
int time_timestamp(void)
{
return time(0);
}
@ -3223,7 +3223,7 @@ const char *str_next_token(const char *str, const char *delim, char *buffer, int
return tok + len;
}
int pid()
int pid(void)
{
#if defined(CONF_FAMILY_WINDOWS)
return _getpid();
@ -3247,7 +3247,7 @@ void shell_execute(const char *file)
#endif
}
int os_is_winxp_or_lower()
int os_is_winxp_or_lower(void)
{
#if defined(CONF_FAMILY_WINDOWS)
static const DWORD WINXP_MAJOR = 5;
@ -3275,7 +3275,7 @@ struct SECURE_RANDOM_DATA
static struct SECURE_RANDOM_DATA secure_random_data = { 0 };
int secure_random_init()
int secure_random_init(void)
{
if(secure_random_data.initialized)
{
@ -3363,7 +3363,7 @@ void secure_random_fill(void *bytes, unsigned length)
#endif
}
int secure_rand()
int secure_rand(void)
{
unsigned int i;
secure_random_fill(&i, sizeof(i));

View file

@ -81,7 +81,7 @@ void dbg_assert_imp(const char *filename, int line, int test, const char *msg);
#else
#define dbg_break()
#endif
void dbg_break_imp();
void dbg_break_imp(void);
/*
Function: dbg_msg
@ -326,19 +326,19 @@ int io_error(IOHANDLE io);
Function: io_stdin
Returns an <IOHANDLE> to the standard input.
*/
IOHANDLE io_stdin();
IOHANDLE io_stdin(void);
/*
Function: io_stdout
Returns an <IOHANDLE> to the standard output.
*/
IOHANDLE io_stdout();
IOHANDLE io_stdout(void);
/*
Function: io_stderr
Returns an <IOHANDLE> to the standard error.
*/
IOHANDLE io_stderr();
IOHANDLE io_stderr(void);
typedef struct ASYNCIO ASYNCIO;
@ -504,7 +504,7 @@ void thread_wait(void *thread);
Function: thread_yield
Yield the current threads execution slice.
*/
void thread_yield();
void thread_yield(void);
/*
Function: thread_detach
@ -534,7 +534,7 @@ void *thread_init_and_detach(void (*threadfunc)(void *), void *user, const char
/* Group: Locks */
typedef void* LOCK;
LOCK lock_create();
LOCK lock_create(void);
void lock_destroy(LOCK lock);
int lock_trylock(LOCK lock);
@ -572,7 +572,7 @@ typedef long long int64;
typedef unsigned long long uint64;
#endif
void set_new_tick();
void set_new_tick(void);
/*
Function: time_get_impl
@ -584,7 +584,7 @@ void set_new_tick();
Remarks:
To know how fast the timer is ticking, see <time_freq>.
*/
int64 time_get_impl();
int64 time_get_impl(void);
/*
Function: time_get
@ -597,7 +597,7 @@ int64 time_get_impl();
To know how fast the timer is ticking, see <time_freq>.
Uses <time_get_impl> to fetch the sample.
*/
int64 time_get();
int64 time_get(void);
/*
Function: time_freq
@ -606,7 +606,7 @@ int64 time_get();
Returns:
Returns the frequency of the high resolution timer.
*/
int64 time_freq();
int64 time_freq(void);
/*
Function: time_timestamp
@ -615,7 +615,7 @@ int64 time_freq();
Returns:
The time as a UNIX timestamp
*/
int time_timestamp();
int time_timestamp(void);
/*
Function: time_get_microseconds
@ -624,7 +624,7 @@ Fetches a sample from a high resolution timer and converts it in microseconds.
Returns:
Current value of the timer in microseconds.
*/
int64 time_get_microseconds();
int64 time_get_microseconds(void);
/* Group: Network General */
typedef struct
@ -669,7 +669,7 @@ typedef struct sockaddr_un UNIXSOCKETADDR;
You must call this function before using any other network
functions.
*/
int net_init();
int net_init(void);
/*
Function: net_host_lookup
@ -926,7 +926,7 @@ int net_tcp_close(NETSOCKET sock);
Returns:
On success it returns a handle to the socket. On failure it returns -1.
*/
UNIXSOCKET net_unix_create_unnamed();
UNIXSOCKET net_unix_create_unnamed(void);
/*
Function: net_unix_send
@ -1645,14 +1645,14 @@ int net_set_blocking(NETSOCKET sock);
DOCTODO: serp
*/
int net_errno();
int net_errno(void);
/*
Function: net_would_block
DOCTODO: serp
*/
int net_would_block();
int net_would_block(void);
int net_socket_read_wait(NETSOCKET sock, int time);
@ -1663,8 +1663,8 @@ typedef void (*DBG_LOGGER)(const char *line, void *user);
typedef void (*DBG_LOGGER_FINISH)(void *user);
void dbg_logger(DBG_LOGGER logger, DBG_LOGGER_FINISH finish, void *user);
void dbg_logger_stdout();
void dbg_logger_debugger();
void dbg_logger_stdout(void);
void dbg_logger_debugger(void);
void dbg_logger_file(const char *filename);
typedef struct
@ -1934,7 +1934,7 @@ const char *str_next_token(const char *str, const char *delim, char *buffer, int
*/
int str_in_list(const char *list, const char *delim, const char *needle);
int pid();
int pid(void);
/*
Function: shell_execute
@ -1950,7 +1950,7 @@ void shell_execute(const char *file);
1 - Windows XP or lower.
0 - Higher Windows version, Linux, macOS, etc.
*/
int os_is_winxp_or_lower();
int os_is_winxp_or_lower(void);
/*
Function: generate_password
@ -1975,7 +1975,7 @@ void generate_password(char *buffer, unsigned length, unsigned short *random, un
0 - Initialization succeeded.
1 - Initialization failed.
*/
int secure_random_init();
int secure_random_init(void);
/*
Function: secure_random_password
@ -2006,7 +2006,7 @@ void secure_random_fill(void *bytes, unsigned length);
Function: secure_rand
Returns random int (replacement for rand()).
*/
int secure_rand();
int secure_rand(void);
#ifdef __cplusplus
}