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

Use NULL instead of 0, for clarity.  Except in pointer comparisons;
leave that to the next two commits.
This commit is contained in:
Markus Armbruster 2009-03-22 18:50:43 +01:00
parent a2ed975ec2
commit 615681ce16
51 changed files with 107 additions and 100 deletions

View file

@ -288,6 +288,10 @@ Do not use increment operators to set a variable to logical true! It
obfuscates the purpose, and narrow variables could even overflow. obfuscates the purpose, and narrow variables could even overflow.
Just assign 1. A lot of cleanup remains to be done there. Just assign 1. A lot of cleanup remains to be done there.
Null pointer constant
Please use NULL for clarity, not just 0.
Type casts Type casts
Casting pointers to and from `void *' clutters the code and serves no Casting pointers to and from `void *' clutters the code and serves no

View file

@ -42,8 +42,8 @@
#include <unistd.h> #include <unistd.h>
#include "misc.h" #include "misc.h"
static char *smso = 0; static char *smso;
static char *rmso = 0; static char *rmso;
void void
getsose(void) getsose(void)

View file

@ -74,7 +74,7 @@ assa(void)
return RET_SYN; return RET_SYN;
if (!sarg_xy(p, &def->x, &def->y)) if (!sarg_xy(p, &def->x, &def->y))
return RET_SYN; return RET_SYN;
if (att_abort(A_ASSAULT, 0, def)) if (att_abort(A_ASSAULT, NULL, def))
return RET_FAIL; return RET_FAIL;
/* /*
@ -110,7 +110,7 @@ assa(void)
if (att_abort(A_ASSAULT, off, def)) { if (att_abort(A_ASSAULT, off, def)) {
pr("Assault aborted\n"); pr("Assault aborted\n");
att_empty_attack(A_ASSAULT, 0, def); att_empty_attack(A_ASSAULT, 0, def);
return att_free_lists(&olist, 0); return att_free_lists(&olist, NULL);
} }
/* If we're assaulting our own sector, end here */ /* If we're assaulting our own sector, end here */
@ -127,7 +127,7 @@ assa(void)
if (att_abort(A_ASSAULT, off, def)) { if (att_abort(A_ASSAULT, off, def)) {
pr("Assault aborted\n"); pr("Assault aborted\n");
att_empty_attack(A_ASSAULT, 0, def); att_empty_attack(A_ASSAULT, 0, def);
return att_free_lists(&olist, 0); return att_free_lists(&olist, NULL);
} }
/* /*

View file

@ -73,7 +73,7 @@ atta(void)
return RET_SYN; return RET_SYN;
if (!sarg_xy(p, &def->x, &def->y)) if (!sarg_xy(p, &def->x, &def->y))
return RET_SYN; return RET_SYN;
if (att_abort(A_ATTACK, 0, def)) if (att_abort(A_ATTACK, NULL, def))
return RET_FAIL; return RET_FAIL;
/* Show what we're attacking, and check treaties */ /* Show what we're attacking, and check treaties */
@ -84,7 +84,7 @@ atta(void)
/* Ask about offensive support */ /* Ask about offensive support */
att_ask_support(2, &fort_sup, &ship_sup, &land_sup, &plane_sup); att_ask_support(2, &fort_sup, &ship_sup, &land_sup, &plane_sup);
if (att_abort(A_ATTACK, 0, def)) { if (att_abort(A_ATTACK, NULL, def)) {
att_empty_attack(A_ATTACK, 0, def); att_empty_attack(A_ATTACK, 0, def);
return RET_OK; return RET_OK;
} }
@ -110,14 +110,14 @@ atta(void)
if (att_abort(A_ATTACK, off, def)) { if (att_abort(A_ATTACK, off, def)) {
pr("Attack aborted\n"); pr("Attack aborted\n");
att_empty_attack(A_ATTACK, 0, def); att_empty_attack(A_ATTACK, 0, def);
return att_free_lists(&olist, 0); return att_free_lists(&olist, NULL);
} }
ototal = att_get_offense(A_ATTACK, off, &olist, def); ototal = att_get_offense(A_ATTACK, off, &olist, def);
if (att_abort(A_ATTACK, off, def)) { if (att_abort(A_ATTACK, off, def)) {
pr("Attack aborted\n"); pr("Attack aborted\n");
att_empty_attack(A_ATTACK, 0, def); att_empty_attack(A_ATTACK, 0, def);
return att_free_lists(&olist, 0); return att_free_lists(&olist, NULL);
} }
/* /*

View file

@ -136,14 +136,14 @@ boar(void)
if (att_abort(A_BOARD, off, def)) { if (att_abort(A_BOARD, off, def)) {
pr("Board aborted\n"); pr("Board aborted\n");
att_empty_attack(A_BOARD, 0, def); att_empty_attack(A_BOARD, 0, def);
return att_free_lists(&olist, 0); return att_free_lists(&olist, NULL);
} }
ototal = att_get_offense(A_BOARD, off, &olist, def); ototal = att_get_offense(A_BOARD, off, &olist, def);
if (att_abort(A_BOARD, off, def)) { if (att_abort(A_BOARD, off, def)) {
pr("Board aborted\n"); pr("Board aborted\n");
att_empty_attack(A_BOARD, 0, def); att_empty_attack(A_BOARD, 0, def);
return att_free_lists(&olist, 0); return att_free_lists(&olist, NULL);
} }
/* /*

View file

@ -122,7 +122,7 @@ bomb(void)
(void)pathtoxy(flightpath, &tx, &ty, fcost); (void)pathtoxy(flightpath, &tx, &ty, fcost);
pr("target sector is %s\n", xyas(tx, ty, player->cnum)); pr("target sector is %s\n", xyas(tx, ty, player->cnum));
getsect(tx, ty, &target); getsect(tx, ty, &target);
ip = 0; ip = NULL;
ap_to_target = strlen(flightpath); ap_to_target = strlen(flightpath);
if (flightpath[ap_to_target - 1] == 'h') if (flightpath[ap_to_target - 1] == 'h')
ap_to_target--; ap_to_target--;

View file

@ -540,7 +540,7 @@ build_bridge(struct sctstr *sp, short *vec)
if ((val = chkdir(*p, DIR_FIRST, DIR_LAST)) < 0) { if ((val = chkdir(*p, DIR_FIRST, DIR_LAST)) < 0) {
pr("'%c' is not a valid direction...\n", *p); pr("'%c' is not a valid direction...\n", *p);
direrr(0, 0, 0); direrr(NULL, NULL, NULL);
return 0; return 0;
} }
newx = sp->sct_x + diroff[val][0]; newx = sp->sct_x + diroff[val][0];
@ -816,7 +816,7 @@ build_tower(struct sctstr *sp, short *vec)
if ((val = chkdir(*p, DIR_FIRST, DIR_LAST)) < 0) { if ((val = chkdir(*p, DIR_FIRST, DIR_LAST)) < 0) {
pr("'%c' is not a valid direction...\n", *p); pr("'%c' is not a valid direction...\n", *p);
direrr(0, 0, 0); direrr(NULL, NULL, NULL);
return 0; return 0;
} }
newx = sp->sct_x + diroff[val][0]; newx = sp->sct_x + diroff[val][0];

View file

@ -70,7 +70,7 @@ coas(void)
if (!snxtsct(&nstr, player->argp[1])) if (!snxtsct(&nstr, player->argp[1]))
return RET_SYN; return RET_SYN;
for (i = 0; i < TSIZE; i++) for (i = 0; i < TSIZE; i++)
list[i] = 0; list[i] = NULL;
cp = malloc(sizeof(*cp)); cp = malloc(sizeof(*cp));
snxtitem_all(&ni, EF_SHIP); snxtitem_all(&ni, EF_SHIP);
while (nxtitem(&ni, &cp->c_shp)) { while (nxtitem(&ni, &cp->c_shp)) {
@ -139,18 +139,18 @@ static int
showship(struct coast **cpp, int x, int y) showship(struct coast **cpp, int x, int y)
{ {
struct coast *cp; struct coast *cp;
struct coast *todelete = 0; struct coast *todelete = NULL;
struct coast **prev; struct coast **prev;
int nship = 0; int nship = 0;
prev = 0; prev = NULL;
cp = *cpp; cp = *cpp;
prev = cpp; prev = cpp;
do { do {
/* we delete it, we free it. */ /* we delete it, we free it. */
if (todelete) { if (todelete) {
free(todelete); free(todelete);
todelete = 0; todelete = NULL;
} }
if (cp->c_shp.shp_x != x || cp->c_shp.shp_y != y) { if (cp->c_shp.shp_x != x || cp->c_shp.shp_y != y) {
prev = &(*prev)->c_next; prev = &(*prev)->c_next;

View file

@ -119,7 +119,7 @@ explore(void)
pr("Only exploring with %d.\n", amount); pr("Only exploring with %d.\n", amount);
} }
if (!want_to_abandon(&sect, vtype, amount, 0)) { if (!want_to_abandon(&sect, vtype, amount, NULL)) {
pr("Explore cancelled.\n"); pr("Explore cancelled.\n");
return RET_FAIL; return RET_FAIL;
} }

View file

@ -124,7 +124,7 @@ sendmessage(struct natstr *us, struct natstr *to, char *message, int verbose)
time(&now); time(&now);
tm = localtime(&now); tm = localtime(&now);
for (other = player_next(0); other != 0; other = player_next(other)) { for (other = player_next(NULL); other; other = player_next(other)) {
if (other->state != PS_PLAYING) if (other->state != PS_PLAYING)
continue; continue;
if (to && other->cnum != to->nat_cnum) if (to && other->cnum != to->nat_cnum)

View file

@ -107,14 +107,14 @@ lboa(void)
if (att_abort(A_LBOARD, off, def)) { if (att_abort(A_LBOARD, off, def)) {
pr("Land unit boarding aborted\n"); pr("Land unit boarding aborted\n");
att_empty_attack(A_LBOARD, 0, def); att_empty_attack(A_LBOARD, 0, def);
return att_free_lists(&olist, 0); return att_free_lists(&olist, NULL);
} }
ototal = att_get_offense(A_LBOARD, off, &olist, def); ototal = att_get_offense(A_LBOARD, off, &olist, def);
if (att_abort(A_LBOARD, off, def)) { if (att_abort(A_LBOARD, off, def)) {
pr("Land unit boarding aborted\n"); pr("Land unit boarding aborted\n");
att_empty_attack(A_LBOARD, 0, def); att_empty_attack(A_LBOARD, 0, def);
return att_free_lists(&olist, 0); return att_free_lists(&olist, NULL);
} }
/* /*

View file

@ -706,7 +706,7 @@ load_comm_ship(struct sctstr *sectp, struct shpstr *sp,
load_unload, atoi(p)); load_unload, atoi(p));
if (!load_comm_ok(sectp, sp->shp_own, item, move_amt)) if (!load_comm_ok(sectp, sp->shp_own, item, move_amt))
return RET_OK; return RET_OK;
if (!want_to_abandon(sectp, item, move_amt, 0)) if (!want_to_abandon(sectp, item, move_amt, NULL))
return RET_FAIL; return RET_FAIL;
if (!still_ok_ship(sectp, sp)) if (!still_ok_ship(sectp, sp))
return RET_SYN; return RET_SYN;

View file

@ -140,7 +140,7 @@ move(void)
} }
} }
if (!istest && !want_to_abandon(&sect, vtype, amount, 0)) { if (!istest && !want_to_abandon(&sect, vtype, amount, NULL)) {
pr("Move cancelled.\n"); pr("Move cancelled.\n");
return RET_FAIL; return RET_FAIL;
} }

View file

@ -128,7 +128,7 @@ paradrop(struct emp_qelem *list, coord x, coord y)
att_combat_init(def, EF_SECTOR); att_combat_init(def, EF_SECTOR);
def->x = x; def->x = x;
def->y = y; def->y = y;
if (att_abort(A_PARA, 0, def)) if (att_abort(A_PARA, NULL, def))
return RET_FAIL; return RET_FAIL;
/* Show what we're air-assaulting, and check treaties */ /* Show what we're air-assaulting, and check treaties */

View file

@ -47,7 +47,7 @@ play(void)
int saw = 0; int saw = 0;
play_header(); play_header();
for (joe = player_prev(0); joe; joe = player_prev(joe)) { for (joe = player_prev(NULL); joe; joe = player_prev(joe)) {
saw += play_list(joe); saw += play_list(joe);
} }
if (player->god || opt_BLITZ) if (player->god || opt_BLITZ)

View file

@ -97,12 +97,12 @@ reco(void)
/* /*
* now arm and equip the bombers, transports, whatever. * now arm and equip the bombers, transports, whatever.
*/ */
pln_arm(&bomb_list, ap_to_target, 'r', 0, P_S | P_I); pln_arm(&bomb_list, ap_to_target, 'r', NULL, P_S | P_I);
if (QEMPTY(&bomb_list)) { if (QEMPTY(&bomb_list)) {
pr("No planes could be equipped for the mission.\n"); pr("No planes could be equipped for the mission.\n");
return RET_FAIL; return RET_FAIL;
} }
pln_arm(&esc_list, ap_to_target, 'r', 0, P_F | P_ESC); pln_arm(&esc_list, ap_to_target, 'r', NULL, P_F | P_ESC);
ac_encounter(&bomb_list, &esc_list, ax, ay, flightpath, ac_encounter(&bomb_list, &esc_list, ax, ay, flightpath,
*player->argp[0] == 's' ? PM_R | PM_S : PM_R); *player->argp[0] == 's' ? PM_R | PM_S : PM_R);
if (QEMPTY(&bomb_list)) { if (QEMPTY(&bomb_list)) {

View file

@ -68,7 +68,7 @@ skyw(void)
if (!snxtsct(&nstr, player->argp[1])) if (!snxtsct(&nstr, player->argp[1]))
return RET_SYN; return RET_SYN;
for (i = 0; i < TSIZE; i++) for (i = 0; i < TSIZE; i++)
list[i] = 0; list[i] = NULL;
skyp = malloc(sizeof(*skyp)); skyp = malloc(sizeof(*skyp));
snxtitem_all(&ni, EF_PLANE); snxtitem_all(&ni, EF_PLANE);
while (nxtitem(&ni, &skyp->s_sat)) { while (nxtitem(&ni, &skyp->s_sat)) {
@ -131,20 +131,20 @@ static int
showsat(struct sky **skypp, int x, int y) showsat(struct sky **skypp, int x, int y)
{ {
struct sky *skyp; struct sky *skyp;
struct sky *todelete = 0; struct sky *todelete = NULL;
struct sky **prev; struct sky **prev;
struct plchrstr *pcp; struct plchrstr *pcp;
char *name; char *name;
int nsat = 0; int nsat = 0;
prev = 0; prev = NULL;
skyp = *skypp; skyp = *skypp;
prev = skypp; prev = skypp;
do { do {
/* we delete it, we free it. */ /* we delete it, we free it. */
if (todelete) { if (todelete) {
free(todelete); free(todelete);
todelete = 0; todelete = NULL;
} }
if (skyp->s_sat.pln_x != x || skyp->s_sat.pln_y != y) { if (skyp->s_sat.pln_x != x || skyp->s_sat.pln_y != y) {
prev = &(*prev)->s_next; prev = &(*prev)->s_next;

View file

@ -82,7 +82,7 @@ stre(void)
pr("%7s", ""); pr("%7s", "");
if (def->sct_type != SCT_MOUNT) if (def->sct_type != SCT_MOUNT)
r_total = att_reacting_units(def, 0, 0, &dummy, 9999999); r_total = att_reacting_units(def, NULL, 0, &dummy, 9999999);
else else
r_total = 0.0; r_total = 0.0;
def->own = 0; def->own = 0;

View file

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

View file

@ -50,7 +50,7 @@ cname(natid n)
struct natstr *np; struct natstr *np;
if ((np = getnatp(n)) == 0) if ((np = getnatp(n)) == 0)
return 0; return NULL;
return np->nat_cnam; return np->nat_cnam;
} }

View file

@ -185,7 +185,7 @@ bp_neighbors(struct as_coord c, struct as_coord *cp, void *pp)
int n = 0, q; int n = 0, q;
struct sctstr *sp, *from, **ssp; struct sctstr *sp, *from, **ssp;
/* Six pointers, just in case our cache isn't there */ /* Six pointers, just in case our cache isn't there */
struct sctstr *tsp[] = { 0, 0, 0, 0, 0, 0 }; struct sctstr *tsp[] = { NULL, NULL, NULL, NULL, NULL, NULL };
int sx, sy, offset; int sx, sy, offset;
x = c.x; x = c.x;

View file

@ -82,8 +82,8 @@ io_open(int fd, int flags, int bufsize, struct timeval timeout)
if (!iop) if (!iop)
return NULL; return NULL;
iop->fd = fd; iop->fd = fd;
iop->input = 0; iop->input = NULL;
iop->output = 0; iop->output = NULL;
iop->flags = 0; iop->flags = 0;
iop->input_timeout = timeout; iop->input_timeout = timeout;
iop->bufsize = bufsize; iop->bufsize = bufsize;

View file

@ -65,7 +65,7 @@ empth_create(void (*entry)(void *), int size, int flags,
{ {
if (!flags) if (!flags)
flags = empth_flags; flags = empth_flags;
return lwpCreate(1, entry, size, flags, name, 0, 0, ud); return lwpCreate(1, entry, size, flags, name, 0, NULL, ud);
} }
empth_t * empth_t *

View file

@ -62,7 +62,7 @@ ioq_create(int size)
ioq->list.nbytes = 0; ioq->list.nbytes = 0;
ioq->list.offset = 0; ioq->list.offset = 0;
ioq->list.size = 0; ioq->list.size = 0;
ioq->list.data = 0; ioq->list.data = NULL;
ioq->bufsize = size; ioq->bufsize = size;
ioq->cc = 0; ioq->cc = 0;
return ioq; return ioq;

View file

@ -98,7 +98,7 @@ lwpReschedule(void)
} else { } else {
lwpDestroy(nextp); lwpDestroy(nextp);
} }
nextp = 0; nextp = NULL;
} }
if (nextp) if (nextp)
break; break;
@ -315,18 +315,19 @@ lwpInitSystem(int pri, void **ctxptr, int flags, sigset_t *waitset)
pri = LWP_MAX_PRIO - 1; pri = LWP_MAX_PRIO - 1;
if (LwpMaxpri < pri) if (LwpMaxpri < pri)
LwpMaxpri = pri; LwpMaxpri = pri;
LwpCurrent->next = 0; LwpCurrent->next = NULL;
LwpCurrent->sbtm = stack; /* dummy stack for "main" */ LwpCurrent->sbtm = stack; /* dummy stack for "main" */
LwpCurrent->pri = pri; LwpCurrent->pri = pri;
LwpCurrent->dead = 0; LwpCurrent->dead = 0;
LwpCurrent->flags = flags & ~LWP_STACKCHECK; LwpCurrent->flags = flags & ~LWP_STACKCHECK;
LwpCurrent->name = "Main"; LwpCurrent->name = "Main";
for (i = LWP_MAX_PRIO, q = LwpSchedQ; i--; q++) for (i = LWP_MAX_PRIO, q = LwpSchedQ; i--; q++)
q->head = q->tail = 0; q->head = q->tail = NULL;
LwpDeadQ.head = LwpDeadQ.tail = 0; LwpDeadQ.head = LwpDeadQ.tail = NULL;
lwpInitSigWait(waitset); lwpInitSigWait(waitset);
/* must be lower in priority than us for this to work right */ /* must be lower in priority than us for this to work right */
sel = lwpCreate(0, lwpSelect, 16384, flags, "EventHandler", 0, 0, 0); sel = lwpCreate(0, lwpSelect, 16384, flags, "EventHandler", 0,
NULL, NULL);
lwpInitSelect(sel); lwpInitSelect(sel);
return LwpCurrent; return LwpCurrent;
} }

View file

@ -34,6 +34,7 @@
#include <config.h> #include <config.h>
#include <stddef.h>
#include "lwp.h" #include "lwp.h"
#include "lwpint.h" #include "lwpint.h"
@ -43,7 +44,7 @@ lwpGetFirst(struct lwpQueue *q)
struct lwpProc *head; struct lwpProc *head;
if ((head = q->head) && !(q->head = head->next)) if ((head = q->head) && !(q->head = head->next))
q->tail = 0; q->tail = NULL;
return head; return head;
} }
@ -55,5 +56,5 @@ lwpAddTail(struct lwpQueue *q, struct lwpProc *p)
else else
q->tail->next = p; q->tail->next = p;
q->tail = p; q->tail = p;
p->next = 0; p->next = NULL;
} }

View file

@ -73,8 +73,8 @@ lwpInitSelect(struct lwpProc *proc)
FD_ZERO(&LwpReadfds); FD_ZERO(&LwpReadfds);
FD_ZERO(&LwpWritefds); FD_ZERO(&LwpWritefds);
LwpFdwait = calloc(FD_SETSIZE, sizeof(struct lwpProc *)); LwpFdwait = calloc(FD_SETSIZE, sizeof(struct lwpProc *));
LwpDelayq.head = 0; LwpDelayq.head = NULL;
LwpDelayq.tail = 0; LwpDelayq.tail = NULL;
LwpSelProc = proc; LwpSelProc = proc;
} }
@ -141,7 +141,7 @@ lwpWakeupFd(struct lwpProc *proc)
FD_CLR(proc->fd, &LwpReadfds); FD_CLR(proc->fd, &LwpReadfds);
FD_CLR(proc->fd, &LwpWritefds); FD_CLR(proc->fd, &LwpWritefds);
LwpNfds--; LwpNfds--;
LwpFdwait[proc->fd] = 0; LwpFdwait[proc->fd] = NULL;
proc->fd = -1; proc->fd = -1;
lwpReady(proc); lwpReady(proc);
} }
@ -158,7 +158,7 @@ lwpWakeupSleep(void)
if (LwpDelayq.head) { if (LwpDelayq.head) {
now = time(NULL); now = time(NULL);
save.tail = save.head = 0; save.tail = save.head = NULL;
while (NULL != (proc = lwpGetFirst(&LwpDelayq))) { while (NULL != (proc = lwpGetFirst(&LwpDelayq))) {
if (now >= proc->runtime) { if (now >= proc->runtime) {
lwpStatus(proc, "sleep done"); lwpStatus(proc, "sleep done");

View file

@ -51,8 +51,8 @@ lwpStatus(struct lwpProc *proc, char *format, ...)
va_start(ap, format); va_start(ap, format);
if (proc->flags & LWP_PRINT) { if (proc->flags & LWP_PRINT) {
if (startTime.tv_sec == 0) if (startTime.tv_sec == 0)
gettimeofday(&startTime, 0); gettimeofday(&startTime, NULL);
gettimeofday(&tv, 0); gettimeofday(&tv, NULL);
sec = tv.tv_sec - startTime.tv_sec; sec = tv.tv_sec - startTime.tv_sec;
msec = (tv.tv_usec - startTime.tv_usec) / 1000; msec = (tv.tv_usec - startTime.tv_usec) / 1000;
if (msec < 0) { if (msec < 0) {

View file

@ -107,7 +107,7 @@ player_delete(struct player *lp)
if (lp->iop) { if (lp->iop) {
/* it's a real player */ /* it's a real player */
io_close(lp->iop); io_close(lp->iop);
lp->iop = 0; lp->iop = NULL;
} }
free(lp); free(lp);
/* XXX may need to free bigmap here */ /* XXX may need to free bigmap here */
@ -122,7 +122,7 @@ player_next(struct player *lp)
else else
lp = (struct player *)lp->queue.q_forw; lp = (struct player *)lp->queue.q_forw;
if (&lp->queue == &Players) if (&lp->queue == &Players)
return 0; return NULL;
return lp; return lp;
} }
@ -134,7 +134,7 @@ player_prev(struct player *lp)
else else
lp = (struct player *)lp->queue.q_back; lp = (struct player *)lp->queue.q_back;
if (&lp->queue == &Players) if (&lp->queue == &Players)
return 0; return NULL;
return lp; return lp;
} }

View file

@ -279,5 +279,5 @@ struct cmndstr player_coms[] = {
{"work <LAND UNITS> <AMOUNT>", 1, work, C_MOD, NORM + MONEY + CAP}, {"work <LAND UNITS> <AMOUNT>", 1, work, C_MOD, NORM + MONEY + CAP},
{"xdump [\"meta\"] <TYPE> [<RECORDS>]", 0, xdump, 0, VIS}, {"xdump [\"meta\"] <TYPE> [<RECORDS>]", 0, xdump, 0, VIS},
{"zdone <y|n|c>", 0, zdon, C_MOD, NORM}, {"zdone <y|n|c>", 0, zdon, C_MOD, NORM},
{0, 0, 0, 0, 0} {NULL, 0, NULL, 0, 0}
}; };

View file

@ -69,7 +69,7 @@ static struct cmndstr login_coms[] = {
{"quit", 0, quit_cmd, 0, 0}, {"quit", 0, quit_cmd, 0, 0},
{"sanc", 0, sanc_cmd, 0, 0}, {"sanc", 0, sanc_cmd, 0, 0},
{"user name", 0, user_cmd, 0, 0}, {"user name", 0, user_cmd, 0, 0},
{0, 0, 0, 0, 0} {NULL, 0, NULL, 0, 0}
}; };
/*ARGSUSED*/ /*ARGSUSED*/

View file

@ -295,7 +295,7 @@ sam_intercept(struct emp_qelem *att_list, struct emp_qelem *def_list,
&& pp->pln_radius < mapdist(x, y, pp->pln_opx, pp->pln_opy)) && pp->pln_radius < mapdist(x, y, pp->pln_opx, pp->pln_opy))
continue; continue;
if (CANT_HAPPEN(pp->pln_flags & PLN_LAUNCHED) if (CANT_HAPPEN(pp->pln_flags & PLN_LAUNCHED)
|| mission_pln_equip(dplp, 0, P_F, 0) < 0) { || mission_pln_equip(dplp, NULL, P_F, 0) < 0) {
emp_remque(dqp); emp_remque(dqp);
free(dqp); free(dqp);
continue; continue;
@ -369,7 +369,7 @@ ac_intercept(struct emp_qelem *bomb_list, struct emp_qelem *esc_list,
&& pp->pln_radius < mapdist(x, y, pp->pln_opx, pp->pln_opy)) && pp->pln_radius < mapdist(x, y, pp->pln_opx, pp->pln_opy))
continue; continue;
if (CANT_HAPPEN(pp->pln_flags & PLN_LAUNCHED) if (CANT_HAPPEN(pp->pln_flags & PLN_LAUNCHED)
|| mission_pln_equip(plp, 0, P_F, 0) < 0) { || mission_pln_equip(plp, NULL, P_F, 0) < 0) {
emp_remque(qp); emp_remque(qp);
free(qp); free(qp);
continue; continue;

View file

@ -912,7 +912,7 @@ ask_off(int combat_mode, struct combat *off, struct combat *def)
sprintf(prompt, "Number of mil from %s (max %d) : ", sprintf(prompt, "Number of mil from %s (max %d) : ",
prcom(0, off), mob_support); prcom(0, off), mob_support);
} }
if ((attacking_mil = onearg(0, prompt)) < 0) if ((attacking_mil = onearg(NULL, prompt)) < 0)
abort_attack(); abort_attack();
if (att_abort(combat_mode, off, def)) if (att_abort(combat_mode, off, def))
return 0; return 0;
@ -1271,7 +1271,8 @@ get_ototal(int combat_mode, struct combat *off, struct emp_qelem *olist,
for (qp = olist->q_forw; qp != olist; qp = next) { for (qp = olist->q_forw; qp != olist; qp = next) {
next = qp->q_forw; next = qp->q_forw;
llp = (struct ulist *)qp; llp = (struct ulist *)qp;
if (check && !get_land(combat_mode, 0, llp->unit.land.lnd_uid, llp, 0)) if (check &&
!get_land(combat_mode, NULL, llp->unit.land.lnd_uid, llp, 0))
continue; continue;
if (combat_mode == A_ATTACK) { if (combat_mode == A_ATTACK) {
w = -1; w = -1;
@ -1448,7 +1449,7 @@ put_land(struct emp_qelem *list)
emp_remque((struct emp_qelem *)llp); emp_remque((struct emp_qelem *)llp);
free(llp); free(llp);
} else } else
get_land(A_ATTACK, 0, llp->unit.land.lnd_uid, llp, 0); get_land(A_ATTACK, NULL, llp->unit.land.lnd_uid, llp, 0);
} }
} }
@ -2181,7 +2182,7 @@ take_def(int combat_mode, struct emp_qelem *list, struct combat *off,
{ {
int n; int n;
int occuppied = 0; int occuppied = 0;
struct ulist *llp, *delete_me = 0; struct ulist *llp, *delete_me = NULL;
char buf[1024]; char buf[1024];
struct sctstr sect; struct sctstr sect;
struct shpstr ship; struct shpstr ship;

View file

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

View file

@ -254,7 +254,7 @@ adj_units(coord x, coord y, natid own)
for (i = DIR_FIRST; i <= DIR_LAST; i++) { for (i = DIR_FIRST; i <= DIR_LAST; i++) {
getsect(x + diroff[i][0], y + diroff[i][1], &sect); getsect(x + diroff[i][0], y + diroff[i][1], &sect);
if (has_units(sect.sct_x, sect.sct_y, own, 0)) if (has_units(sect.sct_x, sect.sct_y, own, NULL))
return 1; return 1;
} }
return 0; return 0;

View file

@ -989,7 +989,7 @@ lnd_mar_one_sector(struct emp_qelem *list, int dir, natid actor,
pr("%s was shot and killed.\n", prland(&llp->unit.land)); pr("%s was shot and killed.\n", prland(&llp->unit.land));
llp->unit.land.lnd_effic = 0; llp->unit.land.lnd_effic = 0;
putland(llp->unit.land.lnd_uid, &llp->unit.land); putland(llp->unit.land.lnd_uid, &llp->unit.land);
lnd_delete(llp, 0); lnd_delete(llp, NULL);
} }
} }
} }

View file

@ -610,12 +610,12 @@ perform_mission(coord x, coord y, natid victim, struct emp_qelem *list,
/* Split off the escorts at this base into e */ /* Split off the escorts at this base into e */
divide(&escorts, &e, air->x, air->y); divide(&escorts, &e, air->x, air->y);
mission_pln_arm(&b, air->x, air->y, 2 * md, 'p', 0, 0); mission_pln_arm(&b, air->x, air->y, 2 * md, 'p', NULL, 0);
if (QEMPTY(&b)) if (QEMPTY(&b))
continue; continue;
mission_pln_arm(&e, air->x, air->y, 2 * md, 'p', 0, P_F | P_ESC); mission_pln_arm(&e, air->x, air->y, 2 * md, 'p', NULL, P_F | P_ESC);
pp = BestAirPath(buf, air->x, air->y, x, y); pp = BestAirPath(buf, air->x, air->y, x, y);
if (CANT_HAPPEN(!pp)) if (CANT_HAPPEN(!pp))

View file

@ -61,7 +61,7 @@ msl_equip(struct plnstr *pp, char mission)
memset(&pl, 0, sizeof(struct plist)); memset(&pl, 0, sizeof(struct plist));
pl.pcp = plchr + pp->pln_type; pl.pcp = plchr + pp->pln_type;
pl.plane = *pp; pl.plane = *pp;
return mission_pln_equip(&pl, 0, 0, mission); return mission_pln_equip(&pl, NULL, 0, mission);
} }
int int
@ -271,7 +271,7 @@ msl_intercept(coord x, coord y, natid bombown, int hardtarget,
if (pp->pln_own != sect.sct_own) if (pp->pln_own != sect.sct_own)
continue; continue;
pcp = ip->pcp; pcp = ip->pcp;
if (mission_pln_equip(ip, 0, 0, 'i') < 0) { if (mission_pln_equip(ip, NULL, 0, 'i') < 0) {
emp_remque(qp); emp_remque(qp);
free(qp); free(qp);
continue; continue;
@ -290,7 +290,7 @@ msl_intercept(coord x, coord y, natid bombown, int hardtarget,
ip = (struct plist *)qp; ip = (struct plist *)qp;
pp = &ip->plane; pp = &ip->plane;
pcp = ip->pcp; pcp = ip->pcp;
if (mission_pln_equip(ip, 0, 0, 'i') < 0) { if (mission_pln_equip(ip, NULL, 0, 'i') < 0) {
emp_remque(qp); emp_remque(qp);
free(qp); free(qp);
continue; continue;
@ -401,7 +401,7 @@ msl_launch_mindam(struct emp_qelem *list, coord x, coord y, int hardtarget,
next = qp->q_back; next = qp->q_back;
plp = (struct plist *)qp; plp = (struct plist *)qp;
if (mission_pln_equip(plp, 0, 0, 'p') >= 0) { if (mission_pln_equip(plp, NULL, 0, 'p') >= 0) {
if (msl_hit(&plp->plane, if (msl_hit(&plp->plane,
hardtarget, type, news_item, snews_item, hardtarget, type, news_item, snews_item,
whatp, x, y, victim)) { whatp, x, y, victim)) {

View file

@ -201,7 +201,7 @@ pr_wall(char *format, ...)
va_start(ap, format); va_start(ap, format);
(void)vsprintf(buf + n, format, ap); (void)vsprintf(buf + n, format, ap);
va_end(ap); va_end(ap);
for (p = player_next(0); p; 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_player(p, C_FLASH, buf); pr_player(p, C_FLASH, buf);

View file

@ -52,7 +52,7 @@ setrel(natid us, natid them, int rel)
char *whichway; char *whichway;
int n_up = 0; int n_up = 0;
int n_down = 0; int n_down = 0;
char *addendum = 0; char *addendum = NULL;
int theirrel; int theirrel;
if (rel < AT_WAR) if (rel < AT_WAR)

View file

@ -423,7 +423,7 @@ most_valuable_ship(struct emp_qelem *list)
struct emp_qelem *qp; struct emp_qelem *qp;
struct emp_qelem *next; struct emp_qelem *next;
struct ulist *mlp; struct ulist *mlp;
struct ulist *mvs = 0; struct ulist *mvs = NULL;
for (qp = list->q_back; qp != list; qp = next) { for (qp = list->q_back; qp != list; qp = next) {
next = qp->q_back; next = qp->q_back;

View file

@ -147,14 +147,14 @@ unit_path(int together, struct empobj *unit, char *buf)
return NULL; return NULL;
if (!sarg_xy(buf, &destx, &desty)) if (!sarg_xy(buf, &destx, &desty))
return 0; return NULL;
if (!together) { if (!together) {
pr("Cannot go to a destination sector if not all starting in the same sector\n"); pr("Cannot go to a destination sector if not all starting in the same sector\n");
return 0; return NULL;
} }
if (!getsect(destx, desty, &d_sect)) { if (!getsect(destx, desty, &d_sect)) {
pr("%d,%d is not a sector\n", destx, desty); pr("%d,%d is not a sector\n", destx, desty);
return 0; return NULL;
} }
if (unit->ef_type == EF_SHIP) { if (unit->ef_type == EF_SHIP) {
cp = BestShipPath(buf, unit->x, unit->y, cp = BestShipPath(buf, unit->x, unit->y,
@ -162,7 +162,7 @@ unit_path(int together, struct empobj *unit, char *buf)
if (!cp || unit->mobil <= 0) { if (!cp || unit->mobil <= 0) {
pr("Can't get to '%s' right now.\n", pr("Can't get to '%s' right now.\n",
xyas(d_sect.sct_x, d_sect.sct_y, player->cnum)); xyas(d_sect.sct_x, d_sect.sct_y, player->cnum));
return 0; return NULL;
} }
} else { } else {
getsect(unit->x, unit->y, &sect); getsect(unit->x, unit->y, &sect);
@ -173,7 +173,7 @@ unit_path(int together, struct empobj *unit, char *buf)
mtype == MOB_RAIL ? "railway" : "path", mtype == MOB_RAIL ? "railway" : "path",
xyas(unit->x, unit->y, player->cnum), xyas(unit->x, unit->y, player->cnum),
xyas(d_sect.sct_x, d_sect.sct_y, player->cnum)); xyas(d_sect.sct_x, d_sect.sct_y, player->cnum));
return 0; return NULL;
} }
pr("Using path '%s'\n", cp); pr("Using path '%s'\n", cp);
} }

View file

@ -49,7 +49,7 @@ whatitem(char *input, char *prompt)
p = getstarg(input, prompt, buf); p = getstarg(input, prompt, buf);
if (p == 0 || *p == 0) if (p == 0 || *p == 0)
return 0; return NULL;
ip = item_by_name(p); ip = item_by_name(p);
if (!ip) if (!ip)
pr("Unrecognized item \"%c\"\n", *p); pr("Unrecognized item \"%c\"\n", *p);
@ -69,5 +69,5 @@ item_by_name(char *str)
if (*str == ip->i_mnem) if (*str == ip->i_mnem)
return ip; return ip;
} }
return 0; return NULL;
} }

View file

@ -47,16 +47,16 @@ nxtitemp(struct nstr_item *np)
int selected; int selected;
if (np->sel == NS_UNDEF) if (np->sel == NS_UNDEF)
return 0; return NULL;
do { do {
if (np->sel == NS_LIST) { if (np->sel == NS_LIST) {
np->index++; np->index++;
if (np->index >= np->size) if (np->index >= np->size)
return 0; return NULL;
np->cur = np->list[np->index]; np->cur = np->list[np->index];
} else if (np->sel == NS_CARGO) { } else if (np->sel == NS_CARGO) {
if (np->next < 0) if (np->next < 0)
return 0; return NULL;
np->cur = np->next; np->cur = np->next;
np->next = unit_cargo_next(np->type, np->next); np->next = unit_cargo_next(np->type, np->next);
} else { } else {
@ -64,7 +64,7 @@ nxtitemp(struct nstr_item *np)
} }
gp = ef_ptr(np->type, np->cur); gp = ef_ptr(np->type, np->cur);
if (!gp) if (!gp)
return 0; return NULL;
selected = 1; selected = 1;
switch (np->sel) { switch (np->sel) {
@ -74,7 +74,7 @@ nxtitemp(struct nstr_item *np)
break; break;
case NS_DIST: case NS_DIST:
if (CANT_HAPPEN(!(ef_flags(np->type) & EFF_XY))) if (CANT_HAPPEN(!(ef_flags(np->type) & EFF_XY)))
return 0; return NULL;
if (!xyinrange(gp->x, gp->y, &np->range)) { if (!xyinrange(gp->x, gp->y, &np->range)) {
selected = 0; selected = 0;
break; break;
@ -85,25 +85,25 @@ nxtitemp(struct nstr_item *np)
break; break;
case NS_AREA: case NS_AREA:
if (CANT_HAPPEN(!(ef_flags(np->type) & EFF_XY))) if (CANT_HAPPEN(!(ef_flags(np->type) & EFF_XY)))
return 0; return NULL;
if (!xyinrange(gp->x, gp->y, &np->range)) if (!xyinrange(gp->x, gp->y, &np->range))
selected = 0; selected = 0;
break; break;
case NS_XY: case NS_XY:
if (CANT_HAPPEN(!(ef_flags(np->type) & EFF_XY))) if (CANT_HAPPEN(!(ef_flags(np->type) & EFF_XY)))
return 0; return NULL;
if (xnorm(gp->x) != np->cx || ynorm(gp->y) != np->cy) if (xnorm(gp->x) != np->cx || ynorm(gp->y) != np->cy)
selected = 0; selected = 0;
break; break;
case NS_GROUP: case NS_GROUP:
if (CANT_HAPPEN(!(ef_flags(np->type) & EFF_GROUP))) if (CANT_HAPPEN(!(ef_flags(np->type) & EFF_GROUP)))
return 0; return NULL;
if (np->group != gp->group) if (np->group != gp->group)
selected = 0; selected = 0;
break; break;
default: default:
CANT_REACH(); CANT_REACH();
return 0; return NULL;
} }
if (selected && np->ncond) { if (selected && np->ncond) {
/* nstr_exec is expensive, so we do it last */ /* nstr_exec is expensive, so we do it last */

View file

@ -99,7 +99,7 @@ do_plague(struct sctstr *sp, struct natstr *np, int etu)
} }
} }
if (sp->sct_item[I_CIVIL] == 0 && sp->sct_item[I_MILIT] == 0 if (sp->sct_item[I_CIVIL] == 0 && sp->sct_item[I_MILIT] == 0
&& !has_units(sp->sct_x, sp->sct_y, sp->sct_own, 0)) { && !has_units(sp->sct_x, sp->sct_y, sp->sct_own, NULL)) {
makelost(EF_SECTOR, sp->sct_own, 0, sp->sct_x, sp->sct_y); makelost(EF_SECTOR, sp->sct_own, 0, sp->sct_x, sp->sct_y);
sp->sct_own = 0; sp->sct_own = 0;
sp->sct_oldown = 0; sp->sct_oldown = 0;

View file

@ -52,7 +52,7 @@ populace(struct natstr *np, struct sctstr *sp, int etu)
sp->sct_oldown = sp->sct_own; sp->sct_oldown = sp->sct_own;
} }
if (!civ && !mil && !sp->sct_item[I_UW] if (!civ && !mil && !sp->sct_item[I_UW]
&& !has_units(sp->sct_x, sp->sct_y, sp->sct_own, 0)) { && !has_units(sp->sct_x, sp->sct_y, sp->sct_own, NULL)) {
makelost(EF_SECTOR, sp->sct_own, 0, sp->sct_x, sp->sct_y); makelost(EF_SECTOR, sp->sct_own, 0, sp->sct_x, sp->sct_y);
sp->sct_own = 0; sp->sct_own = 0;
sp->sct_oldown = 0; sp->sct_oldown = 0;

View file

@ -352,7 +352,7 @@ guerrilla(struct sctstr *sp)
} }
domove: domove:
if (move && che > 0) { if (move && che > 0) {
struct sctstr *nicest_sp = 0; struct sctstr *nicest_sp = NULL;
if (convert) if (convert)
min_mil = 999; min_mil = 999;
else else

View file

@ -299,7 +299,7 @@ void
sail_ship(natid cn) sail_ship(natid cn)
{ {
struct shpstr *sp; struct shpstr *sp;
struct fltheadstr *head = 0; struct fltheadstr *head = NULL;
struct fltheadstr *fltp; struct fltheadstr *fltp;
int n; int n;

View file

@ -297,7 +297,7 @@ produce_sect(int natnum, int etu, struct bp *bp, long p_sect[][2])
* they all starved or were plagued off. * they all starved or were plagued off.
*/ */
if (vec[I_CIVIL] == 0 && vec[I_MILIT] == 0 && if (vec[I_CIVIL] == 0 && vec[I_MILIT] == 0 &&
!has_units(sp->sct_x, sp->sct_y, sp->sct_own, 0)) { !has_units(sp->sct_x, sp->sct_y, sp->sct_own, NULL)) {
if (!player->simulation) { if (!player->simulation) {
makelost(EF_SECTOR, sp->sct_own, 0, sp->sct_x, sp->sct_y); makelost(EF_SECTOR, sp->sct_own, 0, sp->sct_x, sp->sct_y);
sp->sct_own = 0; sp->sct_own = 0;

View file

@ -382,7 +382,7 @@ start_server(int flags)
if (journal_startup() < 0) if (journal_startup() < 0)
exit(1); exit(1);
empth_create(player_accept, 50 * 1024, flags, "AcceptPlayers", 0); empth_create(player_accept, 50 * 1024, flags, "AcceptPlayers", NULL);
market_init(); market_init();
update_init(); update_init();
@ -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(0); p != 0; p = player_next(p)) { for (p = player_next(NULL); p != 0; 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(0); p != 0; p = player_next(p)) { for (p = player_next(NULL); p != 0; p = player_next(p)) {
if (p->state != PS_PLAYING) if (p->state != PS_PLAYING)
continue; continue;
if (p->command) { if (p->command) {