From 5cca794412bf6c50f321793e06423ce17c05712f Mon Sep 17 00:00:00 2001 From: michael Date: Sun, 14 Jun 2015 17:29:51 +0000 Subject: [PATCH] - Style corrections git-svn-id: svn://svn.ircd-hybrid.org/svnroot/hopm/trunk@6149 82007160-df01-0410-b94d-b575c5fd34c7 --- src/config-parser.y | 15 ++++++--------- src/config.c | 8 ++++---- src/config.h | 6 ++---- src/firedns.c | 6 +++--- src/irc.c | 4 ++-- src/libopm/src/libopm.c | 12 ++++++------ src/opercmd.c | 20 ++++++++++---------- src/scan.c | 6 +++--- 8 files changed, 36 insertions(+), 41 deletions(-) diff --git a/src/config-parser.y b/src/config-parser.y index 858d83c..181b2cd 100644 --- a/src/config-parser.y +++ b/src/config-parser.y @@ -304,7 +304,7 @@ channel_entry: node_t *node; struct ChannelConf *item; - item = xcalloc(sizeof *item); + item = xcalloc(sizeof(*item)); item->name = xstrdup(""); item->key = xstrdup(""); item->invite = xstrdup(""); @@ -354,7 +354,7 @@ user_entry: node_t *node; struct UserConf *item; - item = xcalloc(sizeof *item); + item = xcalloc(sizeof(*item)); item->masks = list_create(); item->scanners = list_create(); @@ -399,7 +399,7 @@ scanner_entry: node_t *node; struct ScannerConf *item, *olditem; - item = xcalloc(sizeof *item); + item = xcalloc(sizeof(*item)); /* Setup ScannerConf defaults */ item->name = xstrdup("undefined"); @@ -524,10 +524,9 @@ scanner_protocol: PROTOCOL '=' PROTOCOLTYPE ':' NUMBER ';' { struct ProtocolConf *item; struct ScannerConf *item2; - node_t *node; - item = xcalloc(sizeof *item); + item = xcalloc(sizeof(*item)); item->type = $3; item->port = $5; @@ -575,8 +574,7 @@ opm_blacklist_entry: node_t *node; struct BlacklistConf *item; - item = xcalloc(sizeof *item); - + item = xcalloc(sizeof(*item)); item->name = xstrdup(""); item->kline = xstrdup(""); item->ban_unknown = 0; @@ -646,8 +644,7 @@ blacklist_reply_item: NUMBER '=' STRING ';' struct BlacklistConf *blacklist = tmp; node_t *node; - item = xcalloc(sizeof *item); - + item = xcalloc(sizeof(*item)); item->number = $1; item->type = xstrdup($3); diff --git a/src/config.c b/src/config.c index 7009763..7655f8f 100644 --- a/src/config.c +++ b/src/config.c @@ -50,16 +50,16 @@ static void config_init(void) { /* Init IRC block */ - IRCItem = xcalloc(sizeof *IRCItem); + IRCItem = xcalloc(sizeof(*IRCItem)); IRCItem->channels = list_create(); IRCItem->performs = list_create(); IRCItem->notices = list_create(); /* Init Options block */ - OptionsItem = xcalloc(sizeof *OptionsItem); + OptionsItem = xcalloc(sizeof(*OptionsItem)); /* Init OPM block */ - OpmItem = xcalloc(sizeof *OpmItem); + OpmItem = xcalloc(sizeof(*OpmItem)); OpmItem->blacklists = list_create(); /* Init list of User blocks */ @@ -69,7 +69,7 @@ config_init(void) ScannerItemList = list_create(); /* Init list of Exempts */ - ExemptItem = xcalloc(sizeof *ExemptItem); + ExemptItem = xcalloc(sizeof(*ExemptItem)); ExemptItem->masks = list_create(); } diff --git a/src/config.h b/src/config.h index a397264..223b7b1 100644 --- a/src/config.h +++ b/src/config.h @@ -29,10 +29,6 @@ extern char linebuf[512]; extern unsigned int linenum; -extern void yyerror(const char *); -extern void config_load(const char *); - - struct IRCConf { char *nick; @@ -141,4 +137,6 @@ extern struct ExemptConf *ExemptItem; extern list_t *UserItemList; extern list_t *ScannerItemList; +extern void yyerror(const char *); +extern void config_load(const char *); #endif /* CONFIG_H */ diff --git a/src/firedns.c b/src/firedns.c index b9ffa0d..aa10126 100644 --- a/src/firedns.c +++ b/src/firedns.c @@ -356,7 +356,7 @@ firedns_add_query(void) struct s_connection *s; /* create new connection object */ - s = xcalloc(sizeof *s); + s = xcalloc(sizeof(*s)); /* verified by firedns_getresult() */ s->id[0] = rand() % 255; @@ -606,7 +606,7 @@ firedns_getresult(const int fd) return &result; /* query found -- we remove in cleanup */ - l = recv(c->fd, &h,sizeof(struct s_header), 0); + l = recv(c->fd, &h, sizeof(struct s_header), 0); result.info = c->info; strlcpy(result.lookup, c->lookup, sizeof(result.lookup)); @@ -770,7 +770,7 @@ firedns_cycle(void) return; if (ufds == NULL) - ufds = xcalloc((sizeof *ufds) * OptionsItem->dns_fdlimit); + ufds = xcalloc(sizeof(*ufds) * OptionsItem->dns_fdlimit); time(&timenow); size = 0; diff --git a/src/irc.c b/src/irc.c index 478f85d..702e859 100644 --- a/src/irc.c +++ b/src/irc.c @@ -617,7 +617,7 @@ userinfo_create(const char *source) if (username == NULL || hostname == NULL) return NULL; - ret = xcalloc(sizeof *ret); + ret = xcalloc(sizeof(*ret)); ret->irc_nick = xstrdup(nick); ret->irc_username = xstrdup(username); ret->irc_hostname = xstrdup(hostname); @@ -846,7 +846,7 @@ m_notice(char *parv[], unsigned int parc, const char *msg, const struct UserInfo /* Compile the regular expression if it has not been already */ if (preg == NULL) { - preg = xcalloc(sizeof *preg); + preg = xcalloc(sizeof(*preg)); if ((errnum = regcomp(preg, IRCItem->connregex, REG_ICASE | REG_EXTENDED))) { diff --git a/src/libopm/src/libopm.c b/src/libopm/src/libopm.c index 605fc97..d78458e 100644 --- a/src/libopm/src/libopm.c +++ b/src/libopm/src/libopm.c @@ -108,7 +108,7 @@ opm_create(void) { OPM_T *ret; - ret = xcalloc(sizeof *ret); + ret = xcalloc(sizeof(*ret)); ret->config = libopm_config_create(); ret->scans = libopm_list_create(); ret->queue = libopm_list_create(); @@ -137,7 +137,7 @@ opm_remote_create(const char *ip) { OPM_REMOTE_T *ret; - ret = xcalloc(sizeof *ret); + ret = xcalloc(sizeof(*ret)); ret->ip = libopm_xstrdup(ip); ret->protocols = libopm_list_create(); /* Setup protocol list */ @@ -360,7 +360,7 @@ OPM_ERR_T opm_remote_addtype(OPM_REMOTE_T *remote, int type, unsigned short int static OPM_PROTOCOL_T *libopm_protocol_create(void) { OPM_PROTOCOL_T *ret; - ret = xcalloc(sizeof(OPM_PROTOCOL_T)); + ret = xcalloc(sizeof(*ret)); ret->type = 0; ret->write_function = NULL; @@ -408,7 +408,7 @@ libopm_protocol_config_create(void) { OPM_PROTOCOL_CONFIG_T *ret; - ret = xcalloc(sizeof *ret); + ret = xcalloc(sizeof(*ret)); return ret; } @@ -596,7 +596,7 @@ libopm_scan_create(OPM_T *scanner, OPM_REMOTE_T *remote) OPM_CONNECTION_T *conn; OPM_NODE_T *node, *p; - ret = xcalloc(sizeof *ret); + ret = xcalloc(sizeof(*ret)); ret->remote = remote; ret->connections = libopm_list_create(); @@ -674,7 +674,7 @@ libopm_connection_create(void) { OPM_CONNECTION_T *ret; - ret = xcalloc(sizeof *ret); + ret = xcalloc(sizeof(*ret)); ret->state = OPM_STATE_UNESTABLISHED; return ret; diff --git a/src/opercmd.c b/src/opercmd.c index 507e4bd..bf02964 100644 --- a/src/opercmd.c +++ b/src/opercmd.c @@ -133,7 +133,7 @@ static struct Command * command_create(const struct OperCommandHash *tab, char *param, char *irc_nick, const struct ChannelConf *target) { - struct Command *command = xcalloc(sizeof *command); + struct Command *command = xcalloc(sizeof(*command)); if (param) command->param = xstrdup(param); @@ -238,9 +238,9 @@ command_parse(char *command, const struct ChannelConf *target, if (strcasecmp(command, tab->command) == 0) { /* Queue this command */ - struct Command *cs = command_create(tab, param, source_p->irc_nick, target); + struct Command *command = command_create(tab, param, source_p->irc_nick, target); - list_add(COMMANDS, node_create(cs)); + list_add(COMMANDS, node_create(command)); break; } } @@ -274,11 +274,11 @@ command_timer(void) LIST_FOREACH_SAFE(node, node_next, COMMANDS->head) { - struct Command *cs = node->data; + struct Command *command = node->data; - if ((present - cs->added) > COMMANDTIMEOUT) + if ((present - command->added) > COMMANDTIMEOUT) { - command_free(cs); + command_free(command); list_remove(COMMANDS, node); node_free(node); } @@ -325,15 +325,15 @@ command_userhost(const char *reply) /* Find any queued commands that match this user */ LIST_FOREACH_SAFE(node, node_next, COMMANDS->head) { - struct Command *cs = node->data; + struct Command *command = node->data; - if (strcmp(cs->irc_nick, reply) == 0) + if (strcmp(command->irc_nick, reply) == 0) { if (oper) - cs->tab->handler(cs->param, cs->target); + command->tab->handler(command->param, command->target); /* Cleanup the command */ - command_free(cs); + command_free(command); list_remove(COMMANDS, node); node_free(node); } diff --git a/src/scan.c b/src/scan.c index d39971e..76a0347 100644 --- a/src/scan.c +++ b/src/scan.c @@ -187,7 +187,7 @@ scan_init(void) LIST_FOREACH(p, ScannerItemList->head) { sc = p->data; - scs = xcalloc(sizeof *scs); + scs = xcalloc(sizeof(*scs)); if (OPT_DEBUG) log_printf("SCAN -> Setting up scanner [%s]", sc->name); @@ -418,7 +418,7 @@ scan_connect(const char *user[], const char *msg) static struct scan_struct * scan_create(const char *user[], const char *msg) { - struct scan_struct *const ss = xcalloc(sizeof *ss); + struct scan_struct *ss = xcalloc(sizeof(*ss)); ss->irc_nick = xstrdup(user[0]); ss->irc_username = xstrdup(user[1]); @@ -902,7 +902,7 @@ scan_manual(char *param, const struct ChannelConf *target) return; } - ss = xcalloc(sizeof *ss); + ss = xcalloc(sizeof(*ss)); ss->ip = xstrdup(ip); ss->remote = opm_remote_create(ss->ip); ss->remote->data = ss; -- 2.30.2