]> git.pond.sub.org Git - empserver/commitdiff
Don't use 0 as null pointer constant, part 2
authorMarkus Armbruster <armbru@pond.sub.org>
Mon, 23 Mar 2009 19:17:44 +0000 (20:17 +0100)
committerMarkus Armbruster <armbru@pond.sub.org>
Tue, 24 Mar 2009 20:46:01 +0000 (21:46 +0100)
This part replaces E != 0 by E, where E has pointer type.

15 files changed:
src/lib/commands/edit.c
src/lib/commands/head.c
src/lib/commands/info.c
src/lib/commands/thre.c
src/lib/common/emp_config.c
src/lib/common/wantupd.c
src/lib/empthread/io.c
src/lib/lwp/sel.c
src/lib/subs/mtch.c
src/lib/subs/paths.c
src/lib/subs/sarg.c
src/lib/update/revolt.c
src/lib/update/sail.c
src/server/main.c
src/server/update.c

index 2c0293d140a62b0cb1c4c6fcc26e7feedc1e2c03..72eefce93f4425f8694c0cc9152ff37460e6cfbf 100644 (file)
@@ -150,8 +150,8 @@ edit(void)
        }
     }
     for (;;) {
-       if (player->argp[arg_index] != 0) {
-           if (player->argp[arg_index+1] != 0) {
+       if (player->argp[arg_index]) {
+           if (player->argp[arg_index+1]) {
                thing = player->argp[arg_index++][0];
                ptr = player->argp[arg_index++];
                arg = atoi(ptr);
index 76a9662fa2b74a2f299e0e529dd7b228c44453ab..811a27345abcc87b6f7d7ed29c7911574d3024f2 100644 (file)
@@ -68,7 +68,7 @@ head(void)
 
     (void)time(&now);
     natp = getnatp(player->cnum);
-    if (player->argp[1] != 0 && *player->argp[1] != 0) {
+    if (player->argp[1] && *player->argp[1]) {
        news_per = days(atoi(player->argp[1]));
        if (news_per > days(3))
            news_per = days(3);
index d5a6743c1222d02b52131b612e32edda5649b868..8b3993a9f2c51b42101ee62f972dacebdc61602a 100644 (file)
@@ -100,7 +100,7 @@ info(void)
            return RET_FAIL;
        }
 
-       while ((dp = readdir(info_dp)) != 0) {
+       while ((dp = readdir(info_dp))) {
            if (strncasecmp(name, dp->d_name, strlen(name)) != 0)
                continue;
            nmatch++;
@@ -153,7 +153,7 @@ info(void)
        return RET_FAIL;
     }
 
-    while (fgets(buf, sizeof(buf), fp) != 0)
+    while (fgets(buf, sizeof(buf), fp))
        pr("%s", buf);
     (void)fclose(fp);
     return RET_OK;
@@ -207,7 +207,7 @@ apro(void)
      *  search
      */
     nf = nhf = nl = nhl = 0;
-    while ((dp = readdir(info_dp)) != 0) {
+    while ((dp = readdir(info_dp))) {
        if (dp->d_name[0] == '.')
            continue;
        snprintf(filename, sizeof(filename), "%s/%s", infodir,
index 70290e6892ae492baca0539e30b4064d377ff9b7..568474ea94beac0af30f134365d8cea63fdaf1e9 100644 (file)
@@ -86,7 +86,7 @@ thre(void)
               xyas(nstr.x, nstr.y, player->cnum), val);
            continue;
        }
-       if (val > 0 && (player->argp[3] != 0 && *player->argp[3] != 0))
+       if (val > 0 && player->argp[3] && *player->argp[3])
            pr("%s old threshold %d\n",
               xyas(nstr.x, nstr.y, player->cnum), val);
        sect.sct_dist[type] = thresh;
index 93d65cde5e5bd13a3ca8481ecb9978e31a667176..0186352e92d4e04a24b43b4991632b9bfdd55de4 100644 (file)
@@ -155,7 +155,7 @@ keylookup(char *command, struct keymatch *tbl)
 
     if (command == 0 || *command == 0)
        return NULL;
-    for (kp = tbl; kp->km_key != 0; kp++) {
+    for (kp = tbl; kp->km_key; kp++) {
        if (strcmp(kp->km_key, command) == 0)
            return kp;
     }
index 5b79aac1d6ca2ecda35f89f02969c57e5354339a..694b07afd8b6a75e3c880b46351b51a8cabc5a21 100644 (file)
@@ -61,7 +61,7 @@ demand_update_want(int *want, int *pop, int which)
     int whichwants;
 
     whichwants = totpop = totwant = 0;
-    for (cn = 1; 0 != (natp = getnatp(cn)); cn++) {
+    for (cn = 1; (natp = getnatp(cn)); cn++) {
        /* Only countries which are normal. */
        /* Should probably include sanctuaries ..... */
        if (natp->nat_stat == STAT_ACTIVE) {
index 3a48eae4bd126ee1ea595dd8c8fc1c124209b863..32aa9a02682b60890a800bfed4e93e7dd51ddffe 100644 (file)
@@ -101,9 +101,9 @@ void
 io_close(struct iop *iop)
 {
 
-    if (iop->input != 0)
+    if (iop->input)
        ioq_destroy(iop->input);
-    if (iop->output != 0)
+    if (iop->output)
        ioq_destroy(iop->output);
     (void)close(iop->fd);
     free(iop);
index 0f72681470bee9354c0384a2e2eb6813fa437250..1a44d272201b02bbf272b5c406c170e379597182 100644 (file)
@@ -87,7 +87,7 @@ lwpSleepFd(int fd, int mask, struct timeval *timeout)
        errno = EBADF;
        return -1;
     }
-    if (LwpFdwait[fd] != 0) {
+    if (LwpFdwait[fd]) {
        lwpStatus(LwpCurrent,
                  "multiple sleeps attempted on file descriptor %d", fd);
        errno = EBADF;
@@ -237,8 +237,7 @@ lwpSelect(void *arg)
        tv.tv_usec = 0;
        if (LwpDelayq.head) {
            time(&now);
-           proc = LwpDelayq.head;
-           for (; proc != 0; proc = proc->next) {
+           for (proc = LwpDelayq.head; proc; proc = proc->next) {
                delta = proc->runtime - now;
                if (delta < tv.tv_sec)
                    tv.tv_sec = delta;
index 9b02f1d25ff88860d6129457985ffa9e5ae6eaea..e6a2835bf2946ea3cf151282b5f74e9e0f21dc12 100644 (file)
@@ -52,7 +52,7 @@ comtch(char *command, struct cmndstr *coms, int comstat)
     if (command == 0 || *command == 0)
        return M_IGNORE;
     status = M_NOTFOUND;
-    for (com = coms; com->c_form != 0; com++) {
+    for (com = coms; com->c_form; com++) {
        if ((com->c_permit & comstat) != com->c_permit)
            continue;
        switch (mineq(command, com->c_form)) {
index ae77fbb15977e28cd61e16637ab961de70c4fe31..74871ad3bb7be83b8bde067dbed80bae57574a4e 100644 (file)
@@ -58,11 +58,11 @@ direrr(char *stop_msg, char *view_msg, char *map_msg)
     pr(" %c %c\n", dirch[DIR_UL], dirch[DIR_UR]);
     pr("%c   %c\n", dirch[DIR_L], dirch[DIR_R]);
     pr(" %c %c\n", dirch[DIR_DL], dirch[DIR_DR]);
-    if (stop_msg != 0)
+    if (stop_msg)
        pr(stop_msg, dirch[DIR_STOP]);
-    if (view_msg != 0)
+    if (view_msg)
        pr(view_msg, dirch[DIR_VIEW]);
-    if (map_msg != 0)
+    if (map_msg)
        pr(map_msg, dirch[DIR_MAP]);
 }
 
index 645f87a1930b8b4a629f087e79aa88c7099ba76e..fbe69009094c7a4fe709f467ba1030fb36853936 100644 (file)
@@ -65,7 +65,7 @@ sarg_type(char *str)
        return NS_DIST;
     if (c == '*')
        return NS_ALL;
-    if (c == '#' || strchr(str, ',') != 0)
+    if (c == '#' || strchr(str, ','))
        return NS_AREA;
     if (isdigit(c))
        return NS_LIST;
index 10f866bf49aadf5603855bcf47d151c1a98712e7..5b775e6d2330968c3a4a43cf487fc5ff18b376c5 100644 (file)
@@ -383,7 +383,7 @@ guerrilla(struct sctstr *sp)
            min_mil = val;
        }
        /* if we found a nice sector, go there */
-       if (nicest_sp != 0) {
+       if (nicest_sp) {
            nicest_sp->sct_che += che;
            nicest_sp->sct_che_target = target;
            che = 0;
index ba1376de3b38af913997d6ede04d8defbb5b50e2..c10c211ea1cf09e550a801b898003bc591e6e501 100644 (file)
@@ -317,11 +317,11 @@ sail_ship(natid cn)
     }
 
     /* Free up the memory, 'cause I want to. */
-    for (fltp = head; fltp != 0;) {
+    for (fltp = head; fltp;) {
        struct fltelemstr *fe;
        struct fltheadstr *saveh;
        saveh = fltp->next;
-       for (fe = fltp->head; fe != 0;) {
+       for (fe = fltp->head; fe;) {
            struct fltelemstr *saveel;
            saveel = fe->next;
            free(fe);
index e04884ce7e6fe56e4e253b0b212c1ac596385313..44a4f9a49e2042f3437354b0ab908f58a37667b7 100644 (file)
@@ -422,7 +422,7 @@ shutdwn(int sig)
     logerror("Shutdown commencing (cleaning up threads.)");
 
     play_wrlock_wanted = 1;
-    for (p = player_next(NULL); p != 0; p = player_next(p)) {
+    for (p = player_next(NULL); p; p = player_next(p)) {
        if (p->state != PS_PLAYING)
            continue;
        pr_flash(p, "Server shutting down...\n");
index cb73724f123a4dc020d04576c020748611e08e34..704d6d3d229e7abfbe2423b7095e39a4ade4f2a4 100644 (file)
@@ -194,7 +194,7 @@ update_run(void)
     struct player *p;
 
     play_wrlock_wanted = 1;
-    for (p = player_next(NULL); p != 0; p = player_next(p)) {
+    for (p = player_next(NULL); p; p = player_next(p)) {
        if (p->state != PS_PLAYING)
            continue;
        if (p->command) {