Skip to content

Commit

Permalink
Use 'void' for zero-argument functions
Browse files Browse the repository at this point in the history
According to the C standard,
it is desirable to give the type 'void'
to functions have no argument.

Closes #1631
  • Loading branch information
cubicdaiya authored and mattsta committed Aug 2, 2014
1 parent 2af2c63 commit 4b99ecb
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/config.c
Expand Up @@ -73,7 +73,7 @@ void appendServerSaveParams(time_t seconds, int changes) {
server.saveparamslen++;
}

void resetServerSaveParams() {
void resetServerSaveParams(void) {
zfree(server.saveparams);
server.saveparams = NULL;
server.saveparamslen = 0;
Expand Down
4 changes: 2 additions & 2 deletions src/rand.c
Expand Up @@ -66,7 +66,7 @@
#define HI_BIT (1L << (2 * N - 1))

static uint32_t x[3] = { X0, X1, X2 }, a[3] = { A0, A1, A2 }, c = C;
static void next();
static void next(void);

int32_t redisLrand48() {
next();
Expand All @@ -77,7 +77,7 @@ void redisSrand48(int32_t seedval) {
SEED(X0, LOW(seedval), HIGH(seedval));
}

static void next() {
static void next(void) {
uint32_t p[2], q[2], r[2], carry0, carry1;

MUL(a[0], x[0], p);
Expand Down
4 changes: 2 additions & 2 deletions src/redis-check-dump.c
Expand Up @@ -168,7 +168,7 @@ int readBytes(void *target, long num) {
return 1;
}

int processHeader() {
int processHeader(void) {
char buf[10] = "_________";
int dump_version;

Expand Down Expand Up @@ -602,7 +602,7 @@ void printErrorStack(entry *e) {
}
}

void process() {
void process(void) {
uint64_t num_errors = 0, num_valid_ops = 0, num_valid_bytes = 0;
entry entry;
int dump_version = processHeader();
Expand Down
18 changes: 9 additions & 9 deletions src/redis-cli.c
Expand Up @@ -98,7 +98,7 @@ static struct config {
} config;

static volatile sig_atomic_t force_cancel_loop = 0;
static void usage();
static void usage(void);
static void slaveMode(void);
char *redisGitSHA1(void);
char *redisGitDirty(void);
Expand Down Expand Up @@ -158,7 +158,7 @@ typedef struct {
static helpEntry *helpEntries;
static int helpEntriesLen;

static sds cliVersion() {
static sds cliVersion(void) {
sds version;
version = sdscatprintf(sdsempty(), "%s", REDIS_VERSION);

Expand All @@ -172,7 +172,7 @@ static sds cliVersion() {
return version;
}

static void cliInitHelp() {
static void cliInitHelp(void) {
int commandslen = sizeof(commandHelp)/sizeof(struct commandHelp);
int groupslen = sizeof(commandGroups)/sizeof(char*);
int i, len, pos = 0;
Expand Down Expand Up @@ -211,7 +211,7 @@ static void cliOutputCommandHelp(struct commandHelp *help, int group) {
}

/* Print generic help. */
static void cliOutputGenericHelp() {
static void cliOutputGenericHelp(void) {
sds version = cliVersion();
printf(
"redis-cli %s\r\n"
Expand Down Expand Up @@ -368,7 +368,7 @@ static int cliConnect(int force) {
return REDIS_OK;
}

static void cliPrintContextError() {
static void cliPrintContextError(void) {
if (context == NULL) return;
fprintf(stderr,"Error: %s\n",context->errstr);
}
Expand Down Expand Up @@ -805,7 +805,7 @@ static sds readArgFromStdin(void) {
return arg;
}

static void usage() {
static void usage(void) {
sds version = cliVersion();
fprintf(stderr,
"redis-cli %s\n"
Expand Down Expand Up @@ -874,7 +874,7 @@ static char **convertToSds(int count, char** args) {
}

#define LINE_BUFLEN 4096
static void repl() {
static void repl(void) {
sds historyfile = NULL;
int history = 0;
char *line;
Expand Down Expand Up @@ -1677,7 +1677,7 @@ void bytesToHuman(char *s, long long n) {
}
}

static void statMode() {
static void statMode(void) {
redisReply *reply;
long aux, requests = 0;
int i = 0;
Expand Down Expand Up @@ -1763,7 +1763,7 @@ static void statMode() {
* Scan mode
*--------------------------------------------------------------------------- */

static void scanMode() {
static void scanMode(void) {
redisReply *reply;
unsigned long long cur = 0;

Expand Down
8 changes: 4 additions & 4 deletions src/redis.c
Expand Up @@ -1376,7 +1376,7 @@ void createSharedObjects(void) {
shared.maxstring = createStringObject("maxstring",9);
}

void initServerConfig() {
void initServerConfig(void) {
int j;

getRandomHexChars(server.runid,REDIS_RUN_ID_SIZE);
Expand Down Expand Up @@ -1696,7 +1696,7 @@ void resetServerStats(void) {
server.ops_sec_last_sample_ops = 0;
}

void initServer() {
void initServer(void) {
int j;

signal(SIGHUP, SIG_IGN);
Expand Down Expand Up @@ -3351,7 +3351,7 @@ void daemonize(void) {
}
}

void version() {
void version(void) {
printf("Redis server v=%s sha=%s:%d malloc=%s bits=%d build=%llx\n",
REDIS_VERSION,
redisGitSHA1(),
Expand All @@ -3362,7 +3362,7 @@ void version() {
exit(0);
}

void usage() {
void usage(void) {
fprintf(stderr,"Usage: ./redis-server [/path/to/redis.conf] [options]\n");
fprintf(stderr," ./redis-server - (read config from stdin)\n");
fprintf(stderr," ./redis-server -v or --version\n");
Expand Down
4 changes: 2 additions & 2 deletions src/redis.h
Expand Up @@ -1215,7 +1215,7 @@ void redisLog(int level, const char *fmt, ...);
#endif
void redisLogRaw(int level, const char *msg);
void redisLogFromHandler(int level, const char *msg);
void usage();
void usage(void);
void updateDictResizePolicy(void);
int htNeedsResize(dict *dict);
void oom(const char *msg);
Expand Down Expand Up @@ -1275,7 +1275,7 @@ sds keyspaceEventsFlagsToString(int flags);
/* Configuration */
void loadServerConfig(char *filename, char *options);
void appendServerSaveParams(time_t seconds, int changes);
void resetServerSaveParams();
void resetServerSaveParams(void);
struct rewriteConfigState; /* Forward declaration to export API. */
void rewriteConfigRewriteLine(struct rewriteConfigState *state, char *option, sds line, int force);
int rewriteConfig(char *path);
Expand Down

0 comments on commit 4b99ecb

Please sign in to comment.