Don't use 0 as null pointer constant, part 2

This part replaces E != 0 by E, where E has pointer type.
This commit is contained in:
Markus Armbruster 2009-03-23 20:17:44 +01:00
parent 615681ce16
commit 90f8f2b099
15 changed files with 23 additions and 24 deletions

View file

@ -150,8 +150,8 @@ edit(void)
} }
} }
for (;;) { for (;;) {
if (player->argp[arg_index] != 0) { if (player->argp[arg_index]) {
if (player->argp[arg_index+1] != 0) { if (player->argp[arg_index+1]) {
thing = player->argp[arg_index++][0]; thing = player->argp[arg_index++][0];
ptr = player->argp[arg_index++]; ptr = player->argp[arg_index++];
arg = atoi(ptr); arg = atoi(ptr);

View file

@ -68,7 +68,7 @@ head(void)
(void)time(&now); (void)time(&now);
natp = getnatp(player->cnum); 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])); news_per = days(atoi(player->argp[1]));
if (news_per > days(3)) if (news_per > days(3))
news_per = days(3); news_per = days(3);

View file

@ -100,7 +100,7 @@ info(void)
return RET_FAIL; return RET_FAIL;
} }
while ((dp = readdir(info_dp)) != 0) { while ((dp = readdir(info_dp))) {
if (strncasecmp(name, dp->d_name, strlen(name)) != 0) if (strncasecmp(name, dp->d_name, strlen(name)) != 0)
continue; continue;
nmatch++; nmatch++;
@ -153,7 +153,7 @@ info(void)
return RET_FAIL; return RET_FAIL;
} }
while (fgets(buf, sizeof(buf), fp) != 0) while (fgets(buf, sizeof(buf), fp))
pr("%s", buf); pr("%s", buf);
(void)fclose(fp); (void)fclose(fp);
return RET_OK; return RET_OK;
@ -207,7 +207,7 @@ apro(void)
* search * search
*/ */
nf = nhf = nl = nhl = 0; nf = nhf = nl = nhl = 0;
while ((dp = readdir(info_dp)) != 0) { while ((dp = readdir(info_dp))) {
if (dp->d_name[0] == '.') if (dp->d_name[0] == '.')
continue; continue;
snprintf(filename, sizeof(filename), "%s/%s", infodir, snprintf(filename, sizeof(filename), "%s/%s", infodir,

View file

@ -86,7 +86,7 @@ thre(void)
xyas(nstr.x, nstr.y, player->cnum), val); xyas(nstr.x, nstr.y, player->cnum), val);
continue; 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", pr("%s old threshold %d\n",
xyas(nstr.x, nstr.y, player->cnum), val); xyas(nstr.x, nstr.y, player->cnum), val);
sect.sct_dist[type] = thresh; sect.sct_dist[type] = thresh;

View file

@ -155,7 +155,7 @@ keylookup(char *command, struct keymatch *tbl)
if (command == 0 || *command == 0) if (command == 0 || *command == 0)
return NULL; return NULL;
for (kp = tbl; kp->km_key != 0; kp++) { for (kp = tbl; kp->km_key; kp++) {
if (strcmp(kp->km_key, command) == 0) if (strcmp(kp->km_key, command) == 0)
return kp; return kp;
} }

View file

@ -61,7 +61,7 @@ demand_update_want(int *want, int *pop, int which)
int whichwants; int whichwants;
whichwants = totpop = totwant = 0; whichwants = totpop = totwant = 0;
for (cn = 1; 0 != (natp = getnatp(cn)); cn++) { for (cn = 1; (natp = getnatp(cn)); cn++) {
/* Only countries which are normal. */ /* Only countries which are normal. */
/* Should probably include sanctuaries ..... */ /* Should probably include sanctuaries ..... */
if (natp->nat_stat == STAT_ACTIVE) { if (natp->nat_stat == STAT_ACTIVE) {

View file

@ -101,9 +101,9 @@ void
io_close(struct iop *iop) io_close(struct iop *iop)
{ {
if (iop->input != 0) if (iop->input)
ioq_destroy(iop->input); ioq_destroy(iop->input);
if (iop->output != 0) if (iop->output)
ioq_destroy(iop->output); ioq_destroy(iop->output);
(void)close(iop->fd); (void)close(iop->fd);
free(iop); free(iop);

View file

@ -87,7 +87,7 @@ lwpSleepFd(int fd, int mask, struct timeval *timeout)
errno = EBADF; errno = EBADF;
return -1; return -1;
} }
if (LwpFdwait[fd] != 0) { if (LwpFdwait[fd]) {
lwpStatus(LwpCurrent, lwpStatus(LwpCurrent,
"multiple sleeps attempted on file descriptor %d", fd); "multiple sleeps attempted on file descriptor %d", fd);
errno = EBADF; errno = EBADF;
@ -237,8 +237,7 @@ lwpSelect(void *arg)
tv.tv_usec = 0; tv.tv_usec = 0;
if (LwpDelayq.head) { if (LwpDelayq.head) {
time(&now); time(&now);
proc = LwpDelayq.head; for (proc = LwpDelayq.head; proc; proc = proc->next) {
for (; proc != 0; proc = proc->next) {
delta = proc->runtime - now; delta = proc->runtime - now;
if (delta < tv.tv_sec) if (delta < tv.tv_sec)
tv.tv_sec = delta; tv.tv_sec = delta;

View file

@ -52,7 +52,7 @@ comtch(char *command, struct cmndstr *coms, int comstat)
if (command == 0 || *command == 0) if (command == 0 || *command == 0)
return M_IGNORE; return M_IGNORE;
status = M_NOTFOUND; 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) if ((com->c_permit & comstat) != com->c_permit)
continue; continue;
switch (mineq(command, com->c_form)) { switch (mineq(command, com->c_form)) {

View 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_UL], dirch[DIR_UR]);
pr("%c %c\n", dirch[DIR_L], dirch[DIR_R]); pr("%c %c\n", dirch[DIR_L], dirch[DIR_R]);
pr(" %c %c\n", dirch[DIR_DL], dirch[DIR_DR]); pr(" %c %c\n", dirch[DIR_DL], dirch[DIR_DR]);
if (stop_msg != 0) if (stop_msg)
pr(stop_msg, dirch[DIR_STOP]); pr(stop_msg, dirch[DIR_STOP]);
if (view_msg != 0) if (view_msg)
pr(view_msg, dirch[DIR_VIEW]); pr(view_msg, dirch[DIR_VIEW]);
if (map_msg != 0) if (map_msg)
pr(map_msg, dirch[DIR_MAP]); pr(map_msg, dirch[DIR_MAP]);
} }

View file

@ -65,7 +65,7 @@ sarg_type(char *str)
return NS_DIST; return NS_DIST;
if (c == '*') if (c == '*')
return NS_ALL; return NS_ALL;
if (c == '#' || strchr(str, ',') != 0) if (c == '#' || strchr(str, ','))
return NS_AREA; return NS_AREA;
if (isdigit(c)) if (isdigit(c))
return NS_LIST; return NS_LIST;

View file

@ -383,7 +383,7 @@ guerrilla(struct sctstr *sp)
min_mil = val; min_mil = val;
} }
/* if we found a nice sector, go there */ /* if we found a nice sector, go there */
if (nicest_sp != 0) { if (nicest_sp) {
nicest_sp->sct_che += che; nicest_sp->sct_che += che;
nicest_sp->sct_che_target = target; nicest_sp->sct_che_target = target;
che = 0; che = 0;

View file

@ -317,11 +317,11 @@ sail_ship(natid cn)
} }
/* Free up the memory, 'cause I want to. */ /* Free up the memory, 'cause I want to. */
for (fltp = head; fltp != 0;) { for (fltp = head; fltp;) {
struct fltelemstr *fe; struct fltelemstr *fe;
struct fltheadstr *saveh; struct fltheadstr *saveh;
saveh = fltp->next; saveh = fltp->next;
for (fe = fltp->head; fe != 0;) { for (fe = fltp->head; fe;) {
struct fltelemstr *saveel; struct fltelemstr *saveel;
saveel = fe->next; saveel = fe->next;
free(fe); free(fe);

View file

@ -422,7 +422,7 @@ shutdwn(int sig)
logerror("Shutdown commencing (cleaning up threads.)"); logerror("Shutdown commencing (cleaning up threads.)");
play_wrlock_wanted = 1; 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) if (p->state != PS_PLAYING)
continue; continue;
pr_flash(p, "Server shutting down...\n"); pr_flash(p, "Server shutting down...\n");

View file

@ -194,7 +194,7 @@ update_run(void)
struct player *p; struct player *p;
play_wrlock_wanted = 1; 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) if (p->state != PS_PLAYING)
continue; continue;
if (p->command) { if (p->command) {