Skip to content

Commit

Permalink
Remove prototypes with empty declarations (redis#12020)
Browse files Browse the repository at this point in the history
Technically declaring a prototype with an empty declaration has been deprecated since the early days of C, but we never got a warning for it. C2x will apparently be introducing a breaking change if you are using this type of declarator, so Clang 15 has started issuing a warning with -pedantic. Although not apparently a problem for any of the compiler we build on, if feels like the right thing is to properly adhere to the C standard and use (void).
  • Loading branch information
madolson authored May 3, 2023
1 parent 8163e81 commit 5e3be1b
Show file tree
Hide file tree
Showing 43 changed files with 210 additions and 211 deletions.
2 changes: 1 addition & 1 deletion src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ ifneq (,$(findstring FreeBSD,$(uname_S)))
STD+=-Wno-c11-extensions
endif
endif
WARN=-Wall -W -Wno-missing-field-initializers -Werror=deprecated-declarations
WARN=-Wall -W -Wno-missing-field-initializers -Werror=deprecated-declarations -Wstrict-prototypes
OPT=$(OPTIMIZATION)

# Detect if the compiler supports C11 _Atomic.
Expand Down
2 changes: 1 addition & 1 deletion src/acl.c
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@ void ACLSetSelectorCommandBitsForCategory(dict *commands, aclSelector *selector,
/* This function is responsible for recomputing the command bits for all selectors of the existing users.
* It uses the 'command_rules', a string representation of the ordered categories and commands,
* to recompute the command bits. */
void ACLRecomputeCommandBitsFromCommandRulesAllUsers() {
void ACLRecomputeCommandBitsFromCommandRulesAllUsers(void) {
raxIterator ri;
raxStart(&ri,Users);
raxSeek(&ri,"^",NULL,0);
Expand Down
8 changes: 4 additions & 4 deletions src/aof.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,12 +164,12 @@ void aofManifestFree(aofManifest *am) {
zfree(am);
}

sds getAofManifestFileName() {
sds getAofManifestFileName(void) {
return sdscatprintf(sdsempty(), "%s%s", server.aof_filename,
MANIFEST_NAME_SUFFIX);
}

sds getTempAofManifestFileName() {
sds getTempAofManifestFileName(void) {
return sdscatprintf(sdsempty(), "%s%s%s", TEMP_FILE_NAME_PREFIX,
server.aof_filename, MANIFEST_NAME_SUFFIX);
}
Expand Down Expand Up @@ -464,7 +464,7 @@ sds getNewIncrAofName(aofManifest *am) {
}

/* Get temp INCR type AOF name. */
sds getTempIncrAofName() {
sds getTempIncrAofName(void) {
return sdscatprintf(sdsempty(), "%s%s%s", TEMP_FILE_NAME_PREFIX, server.aof_filename,
INCR_FILE_SUFFIX);
}
Expand Down Expand Up @@ -692,7 +692,7 @@ int aofDelHistoryFiles(void) {
}

/* Used to clean up temp INCR AOF when AOFRW fails. */
void aofDelTempIncrAofFile() {
void aofDelTempIncrAofFile(void) {
sds aof_filename = getTempIncrAofName();
sds aof_filepath = makePath(server.aof_dirname, aof_filename);
serverLog(LL_NOTICE, "Removing the temp incr aof file %s in the background", aof_filename);
Expand Down
2 changes: 1 addition & 1 deletion src/cli_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ ssize_t cliWriteConn(redisContext *c, const char *buf, size_t buf_len)

/* Wrapper around OpenSSL (libssl and libcrypto) initialisation
*/
int cliSecureInit()
int cliSecureInit(void)
{
#ifdef USE_OPENSSL
ERR_load_crypto_strings();
Expand Down
2 changes: 1 addition & 1 deletion src/cli_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ int cliSecureConnection(redisContext *c, cliSSLconfig config, const char **err);

ssize_t cliWriteConn(redisContext *c, const char *buf, size_t buf_len);

int cliSecureInit();
int cliSecureInit(void);

sds readArgFromStdin(void);

Expand Down
10 changes: 5 additions & 5 deletions src/cluster.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ dictType clusterNodesBlackListDictType = {
NULL /* allow to expand */
};

static ConnectionType *connTypeOfCluster() {
static ConnectionType *connTypeOfCluster(void) {
if (server.tls_cluster) {
return connectionTypeTls();
}
Expand Down Expand Up @@ -2321,18 +2321,18 @@ uint32_t getAlignedPingExtSize(uint32_t dataSize) {
return sizeof(clusterMsgPingExt) + EIGHT_BYTE_ALIGN(dataSize);
}

uint32_t getHostnamePingExtSize() {
uint32_t getHostnamePingExtSize(void) {
if (sdslen(myself->hostname) == 0) {
return 0;
}
return getAlignedPingExtSize(sdslen(myself->hostname) + 1);
}

uint32_t getShardIdPingExtSize() {
uint32_t getShardIdPingExtSize(void) {
return getAlignedPingExtSize(sizeof(clusterMsgPingExtShardId));
}

uint32_t getForgottenNodeExtSize() {
uint32_t getForgottenNodeExtSize(void) {
return getAlignedPingExtSize(sizeof(clusterMsgPingExtForgottenNode));
}

Expand Down Expand Up @@ -5559,7 +5559,7 @@ void clusterReplyMultiBulkSlots(client * c) {
setDeferredArrayLen(c, slot_replylen, num_masters);
}

sds genClusterInfoString() {
sds genClusterInfoString(void) {
sds info = sdsempty();
char *statestr[] = {"ok","fail"};
int slots_assigned = 0, slots_ok = 0, slots_pfail = 0, slots_fail = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/cluster.h
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ void slotToChannelDel(sds channel);
void clusterUpdateMyselfHostname(void);
void clusterUpdateMyselfAnnouncedPorts(void);
sds clusterGenNodesDescription(int filter, int use_pport);
sds genClusterInfoString();
sds genClusterInfoString(void);
void freeClusterLink(clusterLink *link);

#endif /* __CLUSTER_H */
6 changes: 3 additions & 3 deletions src/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -1065,7 +1065,7 @@ void rewriteConfigReleaseState(struct rewriteConfigState *state) {
}

/* Create the configuration rewrite state */
struct rewriteConfigState *rewriteConfigCreateState() {
struct rewriteConfigState *rewriteConfigCreateState(void) {
struct rewriteConfigState *state = zmalloc(sizeof(*state));
state->option_to_line = dictCreate(&optionToLineDictType);
state->rewritten = dictCreate(&optionSetDictType);
Expand Down Expand Up @@ -1643,7 +1643,7 @@ void rewriteConfigRemoveOrphaned(struct rewriteConfigState *state) {

/* This function returns a string representation of all the config options
* marked with DEBUG_CONFIG, which can be used to help with debugging. */
sds getConfigDebugInfo() {
sds getConfigDebugInfo(void) {
struct rewriteConfigState *state = rewriteConfigCreateState();
state->force_write = 1; /* Force the output */
state->needs_signature = 0; /* Omit the rewrite signature */
Expand Down Expand Up @@ -3260,7 +3260,7 @@ int registerConfigValue(const char *name, const standardConfig *config, int alia

/* Initialize configs to their default values and create and populate the
* runtime configuration dictionary. */
void initConfigValues() {
void initConfigValues(void) {
configs = dictCreate(&sdsHashDictType);
dictExpand(configs, sizeof(static_configs) / sizeof(standardConfig));
for (standardConfig *config = static_configs; config->name != NULL; config++) {
Expand Down
10 changes: 5 additions & 5 deletions src/connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ int connTypeRegister(ConnectionType *ct) {
return C_OK;
}

int connTypeInitialize() {
int connTypeInitialize(void) {
/* currently socket connection type is necessary */
serverAssert(RedisRegisterConnectionTypeSocket() == C_OK);

Expand Down Expand Up @@ -88,7 +88,7 @@ ConnectionType *connectionByType(const char *typename) {
}

/* Cache TCP connection type, query it by string once */
ConnectionType *connectionTypeTcp() {
ConnectionType *connectionTypeTcp(void) {
static ConnectionType *ct_tcp = NULL;

if (ct_tcp != NULL)
Expand All @@ -101,7 +101,7 @@ ConnectionType *connectionTypeTcp() {
}

/* Cache TLS connection type, query it by string once */
ConnectionType *connectionTypeTls() {
ConnectionType *connectionTypeTls(void) {
static ConnectionType *ct_tls = NULL;
static int cached = 0;

Expand All @@ -116,7 +116,7 @@ ConnectionType *connectionTypeTls() {
}

/* Cache Unix connection type, query it by string once */
ConnectionType *connectionTypeUnix() {
ConnectionType *connectionTypeUnix(void) {
static ConnectionType *ct_unix = NULL;

if (ct_unix != NULL)
Expand All @@ -141,7 +141,7 @@ int connectionIndexByType(const char *typename) {
return -1;
}

void connTypeCleanupAll() {
void connTypeCleanupAll(void) {
ConnectionType *ct;
int type;

Expand Down
16 changes: 8 additions & 8 deletions src/connection.h
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ static inline sds connGetPeerCert(connection *conn) {
}

/* Initialize the redis connection framework */
int connTypeInitialize();
int connTypeInitialize(void);

/* Register a connection type into redis connection framework */
int connTypeRegister(ConnectionType *ct);
Expand All @@ -388,13 +388,13 @@ int connTypeRegister(ConnectionType *ct);
ConnectionType *connectionByType(const char *typename);

/* Fast path to get TCP connection type */
ConnectionType *connectionTypeTcp();
ConnectionType *connectionTypeTcp(void);

/* Fast path to get TLS connection type */
ConnectionType *connectionTypeTls();
ConnectionType *connectionTypeTls(void);

/* Fast path to get Unix connection type */
ConnectionType *connectionTypeUnix();
ConnectionType *connectionTypeUnix(void);

/* Lookup the index of a connection type by type name, return -1 if not found */
int connectionIndexByType(const char *typename);
Expand All @@ -418,7 +418,7 @@ static inline int connTypeConfigure(ConnectionType *ct, void *priv, int reconfig
}

/* Walk all the connection types and cleanup them all if possible */
void connTypeCleanupAll();
void connTypeCleanupAll(void);

/* Test all the connection type has pending data or not. */
int connTypeHasPendingData(void);
Expand All @@ -441,8 +441,8 @@ static inline aeFileProc *connAcceptHandler(ConnectionType *ct) {
/* Get Listeners information, note that caller should free the non-empty string */
sds getListensInfoString(sds info);

int RedisRegisterConnectionTypeSocket();
int RedisRegisterConnectionTypeUnix();
int RedisRegisterConnectionTypeTLS();
int RedisRegisterConnectionTypeSocket(void);
int RedisRegisterConnectionTypeUnix(void);
int RedisRegisterConnectionTypeTLS(void);

#endif /* __REDIS_CONNECTION_H */
2 changes: 1 addition & 1 deletion src/db.c
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ int selectDb(client *c, int id) {
return C_OK;
}

long long dbTotalServerKeyCount() {
long long dbTotalServerKeyCount(void) {
long long total = 0;
int j;
for (j = 0; j < server.dbnum; j++) {
Expand Down
6 changes: 3 additions & 3 deletions src/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -2056,9 +2056,9 @@ void dumpCodeAroundEIP(void *eip) {
}
}

void invalidFunctionWasCalled() {}
void invalidFunctionWasCalled(void) {}

typedef void (*invalidFunctionWasCalledType)();
typedef void (*invalidFunctionWasCalledType)(void);

void sigsegvHandler(int sig, siginfo_t *info, void *secret) {
UNUSED(secret);
Expand Down Expand Up @@ -2227,7 +2227,7 @@ void watchdogScheduleSignal(int period) {
it.it_interval.tv_usec = 0;
setitimer(ITIMER_REAL, &it, NULL);
}
void applyWatchdogPeriod() {
void applyWatchdogPeriod(void) {
struct sigaction act;

/* Disable watchdog when period is 0 */
Expand Down
4 changes: 2 additions & 2 deletions src/defrag.c
Original file line number Diff line number Diff line change
Expand Up @@ -781,7 +781,7 @@ float getAllocatorFragmentation(size_t *out_frag_bytes) {

/* We may need to defrag other globals, one small allocation can hold a full allocator run.
* so although small, it is still important to defrag these */
void defragOtherGlobals() {
void defragOtherGlobals(void) {

/* there are many more pointers to defrag (e.g. client argv, output / aof buffers, etc.
* but we assume most of these are short lived, we only need to defrag allocations
Expand Down Expand Up @@ -887,7 +887,7 @@ int defragLaterStep(redisDb *db, long long endtime) {
#define LIMIT(y, min, max) ((y)<(min)? min: ((y)>(max)? max: (y)))

/* decide if defrag is needed, and at what CPU effort to invest in it */
void computeDefragCycles() {
void computeDefragCycles(void) {
size_t frag_bytes;
float frag_pct = getAllocatorFragmentation(&frag_bytes);
/* If we're not already running, and below the threshold, exit. */
Expand Down
8 changes: 4 additions & 4 deletions src/eval.c
Original file line number Diff line number Diff line change
Expand Up @@ -650,15 +650,15 @@ NULL
}
}

unsigned long evalMemory() {
unsigned long evalMemory(void) {
return luaMemory(lctx.lua);
}

dict* evalScriptsDict() {
dict* evalScriptsDict(void) {
return lctx.lua_scripts;
}

unsigned long evalScriptsMemory() {
unsigned long evalScriptsMemory(void) {
return lctx.lua_scripts_mem +
dictMemUsage(lctx.lua_scripts) +
dictSize(lctx.lua_scripts) * sizeof(luaScript);
Expand Down Expand Up @@ -688,7 +688,7 @@ void ldbFlushLog(list *log) {
listDelNode(log,ln);
}

int ldbIsEnabled(){
int ldbIsEnabled(void){
return ldb.active && ldb.step;
}

Expand Down
2 changes: 1 addition & 1 deletion src/evict.c
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ static int isSafeToPerformEvictions(void) {
}

/* Algorithm for converting tenacity (0-100) to a time limit. */
static unsigned long evictionTimeLimitUs() {
static unsigned long evictionTimeLimitUs(void) {
serverAssert(server.maxmemory_eviction_tenacity >= 0);
serverAssert(server.maxmemory_eviction_tenacity <= 100);

Expand Down
2 changes: 1 addition & 1 deletion src/function_lua.c
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ static int luaRegisterFunction(lua_State *lua) {
}

/* Initialize Lua engine, should be called once on start. */
int luaEngineInitEngine() {
int luaEngineInitEngine(void) {
luaEngineCtx *lua_engine_ctx = zmalloc(sizeof(*lua_engine_ctx));
lua_engine_ctx->lua = lua_open();

Expand Down
16 changes: 8 additions & 8 deletions src/functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,12 +212,12 @@ void functionsLibCtxSwapWithCurrent(functionsLibCtx *new_lib_ctx) {
}

/* return the current functions ctx */
functionsLibCtx* functionsLibCtxGetCurrent() {
functionsLibCtx* functionsLibCtxGetCurrent(void) {
return curr_functions_lib_ctx;
}

/* Create a new functions ctx */
functionsLibCtx* functionsLibCtxCreate() {
functionsLibCtx* functionsLibCtxCreate(void) {
functionsLibCtx *ret = zmalloc(sizeof(functionsLibCtx));
ret->libraries = dictCreate(&librariesDictType);
ret->functions = dictCreate(&functionDictType);
Expand Down Expand Up @@ -1075,7 +1075,7 @@ void functionLoadCommand(client *c) {
}

/* Return memory usage of all the engines combine */
unsigned long functionsMemory() {
unsigned long functionsMemory(void) {
dictIterator *iter = dictGetIterator(engines);
dictEntry *entry = NULL;
size_t engines_nemory = 0;
Expand All @@ -1090,7 +1090,7 @@ unsigned long functionsMemory() {
}

/* Return memory overhead of all the engines combine */
unsigned long functionsMemoryOverhead() {
unsigned long functionsMemoryOverhead(void) {
size_t memory_overhead = dictMemUsage(engines);
memory_overhead += dictMemUsage(curr_functions_lib_ctx->functions);
memory_overhead += sizeof(functionsLibCtx);
Expand All @@ -1101,15 +1101,15 @@ unsigned long functionsMemoryOverhead() {
}

/* Returns the number of functions */
unsigned long functionsNum() {
unsigned long functionsNum(void) {
return dictSize(curr_functions_lib_ctx->functions);
}

unsigned long functionsLibNum() {
unsigned long functionsLibNum(void) {
return dictSize(curr_functions_lib_ctx->libraries);
}

dict* functionsLibGet() {
dict* functionsLibGet(void) {
return curr_functions_lib_ctx->libraries;
}

Expand All @@ -1119,7 +1119,7 @@ size_t functionsLibCtxfunctionsLen(functionsLibCtx *functions_ctx) {

/* Initialize engine data structures.
* Should be called once on server initialization */
int functionsInit() {
int functionsInit(void) {
engines = dictCreate(&engineDictType);

if (luaEngineInitEngine() != C_OK) {
Expand Down
Loading

0 comments on commit 5e3be1b

Please sign in to comment.