summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormichael <michael@82007160-df01-0410-b94d-b575c5fd34c7>2013-06-02 19:43:12 +0000
committermichael <michael@82007160-df01-0410-b94d-b575c5fd34c7>2013-06-02 19:43:12 +0000
commit0755cfe97ceee6e2377789bf1c85e71620328467 (patch)
tree37b8f839124f6cae739fbba971597763594c5bf4
parent7d23c46374b7c1258a8082fbe2acf6d76646efc7 (diff)
- motd.h, motd.c: minor cleanups. use 'unsigned' whenever possible
git-svn-id: svn://svn.ircd-hybrid.org/svnroot/ircd-hybrid/branches/8.1.x@2165 82007160-df01-0410-b94d-b575c5fd34c7
-rw-r--r--include/motd.h20
-rw-r--r--src/motd.c13
2 files changed, 16 insertions, 17 deletions
diff --git a/include/motd.h b/include/motd.h
index e78b64a..898b9af 100644
--- a/include/motd.h
+++ b/include/motd.h
@@ -43,13 +43,13 @@ struct Motd
{
dlink_node node; /**< Next MOTD in the linked list. */
enum MotdType type; /**< Type of MOTD. */
+ char *path; /**< Pathname of MOTD file. */
char *hostmask; /**< Hostmask if type==MOTD_HOSTMASK,
class name if type==MOTD_CLASS,
text IP mask if type==MOTD_IPMASK. */
struct irc_ssaddr address; /**< Address if type==MOTD_IPMASK. */
- int addrbits; /**< Number of bits checked in Motd::address. */
- char *path; /**< Pathname of MOTD file. */
- int maxcount; /**< Number of lines for MOTD. */
+ unsigned int addrbits; /**< Number of bits checked in Motd::address. */
+ unsigned int maxcount; /**< Number of lines for MOTD. */
struct MotdCache *cache; /**< MOTD cache entry. */
};
@@ -62,13 +62,13 @@ struct Motd
/** Cache entry for the contents of a MOTD file. */
struct MotdCache
{
- dlink_node node; /**< Next MotdCache in list. */
- int ref; /**< Number of references to this entry. */
- char *path; /**< Pathname of file. */
- int maxcount; /**< Number of lines allocated for message. */
- struct tm modtime; /**< Last modification time from file. */
- int count; /**< Actual number of lines used in message. */
- char motd[1][MOTD_LINESIZE]; /**< Message body. */
+ dlink_node node; /**< Next MotdCache in list. */
+ char *path; /**< Pathname of file. */
+ unsigned int ref; /**< Number of references to this entry. */
+ unsigned int maxcount; /**< Number of lines allocated for message. */
+ unsigned int count; /**< Actual number of lines used in message. */
+ struct tm modtime; /**< Last modification time from file. */
+ char motd[1][MOTD_LINESIZE]; /**< Message body. */
};
/* motd_send sends a MOTD off to a user */
diff --git a/src/motd.c b/src/motd.c
index ff93806..70866ba 100644
--- a/src/motd.c
+++ b/src/motd.c
@@ -87,8 +87,8 @@ motd_cache(struct Motd *motd)
struct MotdCache *cache = NULL;
struct stat sb;
char line[MOTD_LINESIZE + 2]; /* \r\n */
- char *tmp = NULL;
- int i;
+ char *tmp = line;
+ unsigned int i = 0;
dlink_node *ptr = NULL;
assert(motd);
@@ -135,8 +135,7 @@ motd_cache(struct Motd *motd)
while (cache->count < cache->maxcount && fgets(line, sizeof(line), file))
{
/* copy over line, stopping when we overflow or hit line end */
- for (tmp = line, i = 0; i < (MOTD_LINESIZE - 1) && *tmp &&
- *tmp != '\r' && *tmp != '\n'; tmp++, i++)
+ for (; i < (MOTD_LINESIZE - 1) && *tmp && *tmp != '\r' && *tmp != '\n'; ++tmp, ++i)
cache->motd[cache->count][i] = *tmp;
cache->motd[cache->count][i] = '\0';
@@ -174,7 +173,7 @@ motd_decache(struct Motd *motd)
motd->cache = NULL; /* zero the cache */
- if (!--cache->ref) /* reduce reference count... */
+ if (--cache->ref == 0) /* reduce reference count... */
{
dlinkDelete(&cache->node, &MotdList.cachelist);
MyFree(cache->path); /* free path info... */
@@ -250,7 +249,7 @@ motd_lookup(struct Client *client_p)
static void
motd_forward(struct Client *source_p, const struct MotdCache *cache)
{
- int i;
+ unsigned int i = 0;
const char *from = ID_or_name(&me, source_p->from);
const char *to = ID_or_name(source_p, source_p->from);
@@ -266,7 +265,7 @@ motd_forward(struct Client *source_p, const struct MotdCache *cache)
sendto_one(source_p, form_str(RPL_MOTDSTART),
from, to, me.name);
- for (i = 0; i < cache->count; i++)
+ for (; i < cache->count; ++i)
sendto_one(source_p, form_str(RPL_MOTD),
from, to, cache->motd[i]);
sendto_one(source_p, form_str(RPL_ENDOFMOTD), from, to);