summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormichael <michael@82007160-df01-0410-b94d-b575c5fd34c7>2013-04-23 16:42:02 +0000
committermichael <michael@82007160-df01-0410-b94d-b575c5fd34c7>2013-04-23 16:42:02 +0000
commit4fc632fe96ddc6b1efe881965eb34155c136cfcc (patch)
treeb0df0834ff27a2501a8bf09742f580cddf5decaf
parent7b0be4b0c2589115a59090246188c3797a798d45 (diff)
- Constification, replaced few sprintf with snprintf
git-svn-id: svn://svn.ircd-hybrid.org/svnroot/ircd-hybrid/trunk@1847 82007160-df01-0410-b94d-b575c5fd34c7
-rw-r--r--include/channel.h4
-rw-r--r--include/s_misc.h4
-rw-r--r--src/channel.c48
-rw-r--r--src/client.c2
-rw-r--r--src/s_misc.c4
5 files changed, 28 insertions, 34 deletions
diff --git a/include/channel.h b/include/channel.h
index a922715..564533e 100644
--- a/include/channel.h
+++ b/include/channel.h
@@ -114,11 +114,11 @@ struct Ban
extern dlink_list global_channel_list;
-extern int check_channel_name(const char *, int);
+extern int check_channel_name(const char *, const int);
extern int can_send(struct Channel *, struct Client *, struct Membership *);
extern int is_banned(const struct Channel *, const struct Client *);
extern int can_join(struct Client *, struct Channel *, const char *);
-extern int has_member_flags(struct Membership *, unsigned int);
+extern int has_member_flags(const struct Membership *, const unsigned int);
extern void remove_ban(struct Ban *, dlink_list *);
extern void channel_init(void);
diff --git a/include/s_misc.h b/include/s_misc.h
index 3c18976..c44344f 100644
--- a/include/s_misc.h
+++ b/include/s_misc.h
@@ -25,10 +25,10 @@
#ifndef INCLUDED_s_misc_h
#define INCLUDED_s_misc_h
-extern char *date(time_t);
+extern const char *date(time_t);
extern const char *smalldate(time_t);
#ifdef HAVE_LIBCRYPTO
-extern char *ssl_get_cipher(const SSL *);
+extern const char *ssl_get_cipher(const SSL *);
#endif
/* Just blindly define our own MIN/MAX macro */
diff --git a/src/channel.c b/src/channel.c
index ac31a36..888cf79 100644
--- a/src/channel.c
+++ b/src/channel.c
@@ -154,19 +154,18 @@ static void
send_members(struct Client *client_p, struct Channel *chptr,
char *lmodebuf, char *lparabuf)
{
- struct Membership *ms;
- dlink_node *ptr;
+ const dlink_node *ptr = NULL;
int tlen; /* length of text to append */
char *t, *start; /* temp char pointer */
- start = t = buf + sprintf(buf, ":%s SJOIN %lu %s %s %s:",
- ID_or_name(&me, client_p),
- (unsigned long)chptr->channelts,
- chptr->chname, lmodebuf, lparabuf);
+ start = t = buf + snprintf(buf, sizeof(buf), ":%s SJOIN %lu %s %s %s:",
+ ID_or_name(&me, client_p),
+ (unsigned long)chptr->channelts,
+ chptr->chname, lmodebuf, lparabuf);
DLINK_FOREACH(ptr, chptr->members.head)
{
- ms = ptr->data;
+ const struct Membership *ms = ptr->data;
tlen = strlen(IsCapable(client_p, CAP_TS6) ?
ID(ms->client_p) : ms->client_p->name) + 1; /* nick + space */
@@ -219,11 +218,10 @@ send_members(struct Client *client_p, struct Channel *chptr,
*/
static void
send_mode_list(struct Client *client_p, struct Channel *chptr,
- dlink_list *top, char flag)
+ const dlink_list *top, char flag)
{
int ts5 = !IsCapable(client_p, CAP_TS6);
- dlink_node *lp;
- struct Ban *banptr;
+ const dlink_node *lp = NULL;
char pbuf[IRCD_BUFSIZE];
int tlen, mlen, cur_len, count = 0;
char *mp = NULL, *pp = pbuf;
@@ -232,9 +230,9 @@ send_mode_list(struct Client *client_p, struct Channel *chptr,
return;
if (ts5)
- mlen = sprintf(buf, ":%s MODE %s +", me.name, chptr->chname);
+ mlen = snprintf(buf, sizeof(buf), ":%s MODE %s +", me.name, chptr->chname);
else
- mlen = sprintf(buf, ":%s BMASK %lu %s %c :", me.id,
+ mlen = snprintf(buf, sizeof(buf), ":%s BMASK %lu %s %c :", me.id,
(unsigned long)chptr->channelts, chptr->chname, flag);
/* MODE needs additional one byte for space between buf and pbuf */
@@ -243,7 +241,7 @@ send_mode_list(struct Client *client_p, struct Channel *chptr,
DLINK_FOREACH(lp, top->head)
{
- banptr = lp->data;
+ const struct Ban *banptr = lp->data;
/* must add another b/e/I letter if we use MODE */
tlen = banptr->len + 3 + ts5;
@@ -304,7 +302,7 @@ send_channel_modes(struct Client *client_p, struct Channel *chptr)
* \return 0 if invalid, 1 otherwise
*/
int
-check_channel_name(const char *name, int local)
+check_channel_name(const char *name, const int local)
{
const char *p = name;
const int max_length = local ? LOCAL_CHANNELLEN : CHANNELLEN;
@@ -433,9 +431,7 @@ void
channel_member_names(struct Client *source_p, struct Channel *chptr,
int show_eon)
{
- struct Client *target_p = NULL;
- struct Membership *ms = NULL;
- dlink_node *ptr = NULL;
+ const dlink_node *ptr = NULL;
char lbuf[IRCD_BUFSIZE + 1];
char *t = NULL, *start = NULL;
int tlen = 0;
@@ -444,21 +440,19 @@ channel_member_names(struct Client *source_p, struct Channel *chptr,
if (PubChannel(chptr) || is_member)
{
- t = lbuf + sprintf(lbuf, form_str(RPL_NAMREPLY),
- me.name, source_p->name,
- channel_pub_or_secret(chptr),
- chptr->chname);
+ t = lbuf + snprintf(lbuf, sizeof(lbuf), form_str(RPL_NAMREPLY),
+ me.name, source_p->name,
+ channel_pub_or_secret(chptr), chptr->chname);
start = t;
DLINK_FOREACH(ptr, chptr->members.head)
{
- ms = ptr->data;
- target_p = ms->client_p;
+ const struct Membership *ms = ptr->data;
- if (HasUMode(target_p, UMODE_INVISIBLE) && !is_member)
+ if (HasUMode(ms->client_p, UMODE_INVISIBLE) && !is_member)
continue;
- tlen = strlen(target_p->name) + 1; /* nick + space */
+ tlen = strlen(ms->client_p->name) + 1; /* nick + space */
if (!multi_prefix)
{
@@ -483,7 +477,7 @@ channel_member_names(struct Client *source_p, struct Channel *chptr,
}
t += sprintf(t, "%s%s ", get_member_status(ms, multi_prefix),
- target_p->name);
+ ms->client_p->name);
}
if (tlen != 0)
@@ -681,7 +675,7 @@ can_join(struct Client *source_p, struct Channel *chptr, const char *key)
}
int
-has_member_flags(struct Membership *ms, unsigned int flags)
+has_member_flags(const struct Membership *ms, const unsigned int flags)
{
if (ms != NULL)
return ms->flags & flags;
diff --git a/src/client.c b/src/client.c
index 17e5b34..1377dee 100644
--- a/src/client.c
+++ b/src/client.c
@@ -1182,7 +1182,7 @@ idle_time_get(const struct Client *source_p, const struct Client *target_p)
unsigned int idle = 0;
unsigned int min_idle = 0;
unsigned int max_idle = 0;
- struct ClassItem *class = get_class_ptr(&target_p->localClient->confs);
+ const struct ClassItem *class = get_class_ptr(&target_p->localClient->confs);
if (!(class->flags & CLASS_FLAGS_FAKE_IDLE) || target_p == source_p)
return CurrentTime - target_p->localClient->last_privmsg;
diff --git a/src/s_misc.c b/src/s_misc.c
index edb04bf..1c59655 100644
--- a/src/s_misc.c
+++ b/src/s_misc.c
@@ -50,7 +50,7 @@ static const char *weekdays[] =
"Thursday", "Friday", "Saturday"
};
-char *
+const char *
date(time_t lclock)
{
static char buf[80], plus;
@@ -114,7 +114,7 @@ smalldate(time_t lclock)
}
#ifdef HAVE_LIBCRYPTO
-char *
+const char *
ssl_get_cipher(const SSL *ssl)
{
static char buffer[IRCD_BUFSIZE / 4];