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

This part replaces E == 0 by !E, where E has pointer type.
This commit is contained in:
Markus Armbruster 2009-03-23 22:58:54 +01:00
parent 90f8f2b099
commit 6ae4eca045
79 changed files with 121 additions and 121 deletions

View file

@ -45,7 +45,7 @@ confirm(char *promptstring)
char y_or_n[1024];
char c;
if (getstring(promptstring, y_or_n) == 0)
if (!getstring(promptstring, y_or_n))
return 0;
c = *y_or_n;
if (c == 'y' || c == 'Y')

View file

@ -46,8 +46,8 @@ char *
getstarg(char *input, char *prompt, char *buf)
{
*buf = '\0';
if (input == 0 || *input == 0) {
if (getstring(prompt, buf) == 0)
if (!input || !*input) {
if (!getstring(prompt, buf))
return NULL;
} else {
strcpy(buf, input);

View file

@ -913,7 +913,7 @@ mission_pln_equip(struct plist *plp, struct ichrstr *ip, int flags,
break;
case 't': /* transport */
case 'd': /* drop */
if ((pcp->pl_flags & P_C) == 0 || ip == 0)
if (!(pcp->pl_flags & P_C) || !ip)
break;
itype = ip->i_uid;
needed = (load * 2) / ip->i_lbs;

View file

@ -49,7 +49,7 @@ comtch(char *command, struct cmndstr *coms, int comstat)
struct cmndstr *com;
int status;
if (command == 0 || *command == 0)
if (!command || !*command)
return M_IGNORE;
status = M_NOTFOUND;
for (com = coms; com->c_form; com++) {

View file

@ -59,7 +59,7 @@ natargp(char *arg, char *prompt)
struct natstr *np;
arg = getstarg(arg, prompt, buf);
if (arg == 0 || *arg == 0)
if (!arg || !*arg)
return NULL;
if (isdigit(*arg))
n = atoi(arg);

View file

@ -77,7 +77,7 @@ nreport(natid actor, int event, natid victim, int times)
return;
if (!chance((double)-nice * times / 20.0))
return;
if ((natp = getnatp(victim)) == 0)
if (!(natp = getnatp(victim)))
return;
if (getrel(natp, actor) < HOSTILE)
return;

View file

@ -41,8 +41,8 @@ onearg(char *arg, char *prompt)
int n;
char buf[1024];
if (arg == 0 || *arg == 0) {
if ((arg = getstring(prompt, buf)) == 0)
if (!arg || !*arg) {
if (!(arg = getstring(prompt, buf)))
return -1;
}
n = atoi(arg);

View file

@ -270,7 +270,7 @@ pln_dropoff(struct emp_qelem *list, struct ichrstr *ip, coord tx, coord ty,
int there;
int max;
if (ip == 0)
if (!ip)
return;
amt = 0;
for (qp = list->q_forw; qp != list; qp = qp->q_forw) {
@ -664,7 +664,7 @@ pln_equip(struct plist *plp, struct ichrstr *ip, int flags, char mission)
break;
case 't': /* transport */
case 'd': /* drop */
if ((pcp->pl_flags & P_C) == 0 || ip == 0)
if (!(pcp->pl_flags & P_C) || !ip)
break;
itype = ip->i_uid;
needed = (load * 2) / ip->i_lbs;

View file

@ -149,7 +149,7 @@ setcont(natid us, natid them, int contact)
{
struct natstr *np;
if ((np = getnatp(us)) == 0)
if (!(np = getnatp(us)))
return 0;
putcontact(np, them, contact);
putnat(np);
@ -161,7 +161,7 @@ setrej(natid us, natid them, int how, int what)
{
struct natstr *np;
if ((np = getnatp(us)) == 0)
if (!(np = getnatp(us)))
return 0;
putreject(np, them, how, what);
putnat(np);

View file

@ -66,13 +66,13 @@ snxtitem(struct nstr_item *np, int type, char *str, char *prompt)
np->type = EF_BAD;
np->sel = NS_UNDEF;
if (str == 0) {
if (!str) {
if (!prompt) {
sprintf(promptbuf, "%s(s)? ", ef_nameof(type));
prompt = promptbuf;
}
str = getstring(prompt, buf);
if (str == 0)
if (!str)
return 0;
}
if (*str == 0) {
@ -126,7 +126,7 @@ snxtitem(struct nstr_item *np, int type, char *str, char *prompt)
default:
return 0;
}
if (player->condarg == 0)
if (!player->condarg)
return 1;
n = nstr_comp(np->cond, sizeof(np->cond) / sizeof(*np->cond), type,
player->condarg);

View file

@ -61,8 +61,8 @@ snxtsct(struct nstr_sect *np, char *str)
int dist, n;
char buf[1024];
if (str == 0 || *str == 0) {
if ((str = getstring("(sects)? ", buf)) == 0)
if (!str || !*str) {
if (!(str = getstring("(sects)? ", buf)))
return 0;
}
switch (sarg_type(str)) {
@ -92,7 +92,7 @@ snxtsct(struct nstr_sect *np, char *str)
default:
return 0;
}
if (player->condarg == 0)
if (!player->condarg)
return 1;
n = nstr_comp(np->cond, sizeof(np->cond) / sizeof(*np->cond),
EF_SECTOR, player->condarg);

View file

@ -48,7 +48,7 @@ whatitem(char *input, char *prompt)
char buf[1024];
p = getstarg(input, prompt, buf);
if (p == 0 || *p == 0)
if (!p || !*p)
return NULL;
ip = item_by_name(p);
if (!ip)

View file

@ -131,7 +131,7 @@ typed_wu(natid from, natid to, char *message, int type)
mailbox(box, to);
if (type != TEL_ANNOUNCE)
if ((np = getnatp(to)) == 0 || np->nat_stat < STAT_SANCT)
if (!(np = getnatp(to)) || np->nat_stat < STAT_SANCT)
return -1;
#if !defined(_WIN32)
if ((fd = open(box, O_WRONLY | O_APPEND, 0)) < 0) {