Clean up unreadable assignments within if conditionals
Pinpointed assignments within if conditionals with spatch -sp_file tests/bad_assign.cocci (from coccinelle-0.1.4). Cherry-picked diff hunks affecting conditionals split over multiple lines, and cleaned them up.
This commit is contained in:
parent
7c6e56bd02
commit
57717b5bc1
15 changed files with 75 additions and 75 deletions
|
@ -86,10 +86,10 @@ buil(void)
|
|||
char buf[1024];
|
||||
|
||||
natp = getnatp(player->cnum);
|
||||
if ((p =
|
||||
getstarg(player->argp[1],
|
||||
"Build (ship, nuke, bridge, plane, land unit, tower)? ",
|
||||
buf)) == 0)
|
||||
p = getstarg(player->argp[1],
|
||||
"Build (ship, nuke, bridge, plane, land unit, tower)? ",
|
||||
buf);
|
||||
if (p == 0)
|
||||
return RET_SYN;
|
||||
what = *p;
|
||||
|
||||
|
|
|
@ -76,9 +76,9 @@ cede(void)
|
|||
if (is_sector && is_ship) {
|
||||
int type;
|
||||
|
||||
if ((p =
|
||||
getstarg(player->argp[3], "Cede sectors or ships (se, sh)? ",
|
||||
buf)) == 0)
|
||||
p = getstarg(player->argp[3], "Cede sectors or ships (se, sh)? ",
|
||||
buf);
|
||||
if (p == 0)
|
||||
return RET_FAIL;
|
||||
if (strlen(p) > 4)
|
||||
p[2] = 0;
|
||||
|
|
|
@ -46,9 +46,8 @@ chan(void)
|
|||
char buf[1024];
|
||||
struct natstr *us;
|
||||
|
||||
if ((p =
|
||||
getstarg(player->argp[1], "country name or representative? ",
|
||||
buf)) == 0)
|
||||
p = getstarg(player->argp[1], "country name or representative? ", buf);
|
||||
if (p == 0)
|
||||
return RET_SYN;
|
||||
us = getnatp(player->cnum);
|
||||
if (us->nat_stat == STAT_VIS) {
|
||||
|
@ -76,8 +75,8 @@ chan(void)
|
|||
charge = us->nat_money / 10;
|
||||
}
|
||||
}
|
||||
if ((p =
|
||||
getstarg(player->argp[2], "New country name -- ", buf)) == 0)
|
||||
p = getstarg(player->argp[2], "New country name -- ", buf);
|
||||
if (p == 0)
|
||||
return RET_SYN;
|
||||
if (!check_nat_name(p))
|
||||
return RET_FAIL;
|
||||
|
@ -90,8 +89,8 @@ chan(void)
|
|||
case 'p':
|
||||
case 'r':
|
||||
pr("(note: these are stored in plain text.)\n");
|
||||
if ((p = getstarg(player->argp[2],
|
||||
"New representative name -- ", buf)) == 0)
|
||||
p = getstarg(player->argp[2], "New representative name -- ", buf);
|
||||
if (p == 0)
|
||||
return RET_SYN;
|
||||
p[sizeof(us->nat_pnam) - 1] = 0;
|
||||
strcpy(us->nat_pnam, p);
|
||||
|
|
|
@ -78,8 +78,9 @@ coll(void)
|
|||
}
|
||||
|
||||
pr("You are owed $%.2f on that loan.\n", owed);
|
||||
if (!(p = getstarg(player->argp[2],
|
||||
"What sector do you wish to confiscate? ", buf)))
|
||||
p = getstarg(player->argp[2],
|
||||
"What sector do you wish to confiscate? ", buf);
|
||||
if (!p)
|
||||
return RET_SYN;
|
||||
if (!check_loan_ok(&loan))
|
||||
return RET_FAIL;
|
||||
|
|
|
@ -46,9 +46,10 @@ decl(void)
|
|||
char *p;
|
||||
char buf[1024];
|
||||
|
||||
if (!(p = getstarg(player->argp[1],
|
||||
"alliance, friendly, neutrality, hostility, or war? ",
|
||||
buf)))
|
||||
p = getstarg(player->argp[1],
|
||||
"alliance, friendly, neutrality, hostility, or war? ",
|
||||
buf);
|
||||
if (!p)
|
||||
return RET_SYN;
|
||||
switch (*p) {
|
||||
case 'a':
|
||||
|
|
|
@ -61,8 +61,9 @@ demo(void)
|
|||
if (!(p = getstarg(player->argp[2], "Number to de-mobilize : ", buf)))
|
||||
return RET_SYN;
|
||||
number = atoi(p);
|
||||
if (!(p = getstarg(player->argp[3],
|
||||
"New civilians on active reserve? (y/n) ", buf)))
|
||||
p = getstarg(player->argp[3],
|
||||
"New civilians on active reserve? (y/n) ", buf);
|
||||
if (!p)
|
||||
return RET_SYN;
|
||||
if (*p != 'y' && *p != 'n')
|
||||
return RET_SYN;
|
||||
|
|
|
@ -85,9 +85,10 @@ edit(void)
|
|||
char buf[1024];
|
||||
char ewhat;
|
||||
|
||||
if ((what = getstarg(player->argp[1],
|
||||
"Edit What (country, land, ship, plane, nuke, unit)? ",
|
||||
buf)) == 0)
|
||||
what = getstarg(player->argp[1],
|
||||
"Edit What (country, land, ship, plane, nuke, unit)? ",
|
||||
buf);
|
||||
if (what == 0)
|
||||
return RET_SYN;
|
||||
ewhat = what[0];
|
||||
switch (ewhat) {
|
||||
|
|
|
@ -166,23 +166,21 @@ load(void)
|
|||
|
||||
switch (type) {
|
||||
case EF_PLANE:
|
||||
if (0 !=
|
||||
(retval =
|
||||
load_plane_ship(§, &ship, noisy, load_unload,
|
||||
&nships)))
|
||||
retval = load_plane_ship(§, &ship, noisy, load_unload,
|
||||
&nships);
|
||||
if (retval != 0)
|
||||
return retval;
|
||||
break;
|
||||
case EF_LAND:
|
||||
if (0 !=
|
||||
(retval =
|
||||
load_land_ship(§, &ship, noisy, load_unload,
|
||||
&nships)))
|
||||
retval = load_land_ship(§, &ship, noisy, load_unload,
|
||||
&nships);
|
||||
if (retval != 0)
|
||||
return retval;
|
||||
break;
|
||||
case EF_SECTOR:
|
||||
if (0 !=
|
||||
(retval =
|
||||
load_comm_ship(§, &ship, ich, load_unload, &nships)))
|
||||
retval = load_comm_ship(§, &ship, ich, load_unload,
|
||||
&nships);
|
||||
if (retval != 0)
|
||||
return retval;
|
||||
}
|
||||
/* load/unload plague */
|
||||
|
@ -281,23 +279,21 @@ lload(void)
|
|||
|
||||
switch (type) {
|
||||
case EF_LAND:
|
||||
if (0 !=
|
||||
(retval =
|
||||
load_land_land(§, &land, noisy, load_unload,
|
||||
&nunits)))
|
||||
retval = load_land_land(§, &land, noisy, load_unload,
|
||||
&nunits);
|
||||
if (retval != 0)
|
||||
return retval;
|
||||
break;
|
||||
case EF_PLANE:
|
||||
if (0 !=
|
||||
(retval =
|
||||
load_plane_land(§, &land, noisy, load_unload,
|
||||
&nunits)))
|
||||
retval = load_plane_land(§, &land, noisy, load_unload,
|
||||
&nunits);
|
||||
if (retval != 0)
|
||||
return retval;
|
||||
break;
|
||||
case EF_SECTOR:
|
||||
if (0 !=
|
||||
(retval =
|
||||
load_comm_land(§, &land, ich, load_unload, &nunits)))
|
||||
retval = load_comm_land(§, &land, ich, load_unload,
|
||||
&nunits);
|
||||
if (retval != 0)
|
||||
return retval;
|
||||
}
|
||||
/* load/unload plague */
|
||||
|
|
|
@ -74,8 +74,7 @@ ltend(void)
|
|||
while (nxtitem(&tenders, &tender)) {
|
||||
if (!player->owner)
|
||||
continue;
|
||||
if ((p =
|
||||
getstarg(player->argp[3], "Amount to transfer? ", buf)) == 0)
|
||||
if (!(p = getstarg(player->argp[3], "Amount to transfer? ", buf)))
|
||||
return RET_FAIL;
|
||||
if (!check_ship_ok(&tender))
|
||||
return RET_FAIL;
|
||||
|
|
|
@ -98,9 +98,9 @@ multifire(void)
|
|||
|
||||
emp_initque(&fired);
|
||||
emp_initque(&defended);
|
||||
if (!(p = getstarg(player->argp[1],
|
||||
"Firing from ship(s), sect(s), or land unit(s)? ",
|
||||
buf)))
|
||||
p = getstarg(player->argp[1],
|
||||
"Firing from ship(s), sect(s), or land unit(s)? ", buf);
|
||||
if (!p)
|
||||
return RET_SYN;
|
||||
type = ef_byname_from(p, ef_with_guns);
|
||||
if (opt_NO_FORT_FIRE && type == EF_SECTOR) {
|
||||
|
|
|
@ -62,9 +62,9 @@ mission(void)
|
|||
struct nstr_item ni;
|
||||
char buf[1024];
|
||||
|
||||
if ((p =
|
||||
getstarg(player->argp[1], "Ship, plane or land unit (p,sh,la)? ",
|
||||
buf)) == 0)
|
||||
p = getstarg(player->argp[1], "Ship, plane or land unit (p,sh,la)? ",
|
||||
buf);
|
||||
if (p == 0)
|
||||
return RET_SYN;
|
||||
type = ef_byname_from(p, ef_with_missions);
|
||||
if (type < 0) {
|
||||
|
@ -74,10 +74,10 @@ mission(void)
|
|||
if (!snxtitem(&ni, type, player->argp[2], NULL))
|
||||
return RET_SYN;
|
||||
|
||||
if ((p =
|
||||
getstarg(player->argp[3],
|
||||
"Mission (int, sup, osup, dsup, esc, res, air, query, clear)? ",
|
||||
buf)) == 0)
|
||||
p = getstarg(player->argp[3],
|
||||
"Mission (int, sup, osup, dsup, esc, res, air, query, clear)? ",
|
||||
buf);
|
||||
if (p == 0)
|
||||
return RET_SYN;
|
||||
|
||||
/*
|
||||
|
|
|
@ -59,9 +59,9 @@ reje(void)
|
|||
pr("That's not one of the choices!\n");
|
||||
return RET_SYN;
|
||||
}
|
||||
if ((p =
|
||||
getstarg(player->argp[2],
|
||||
"mail, treaties, loans, or announcements? ", buf)) == 0)
|
||||
p = getstarg(player->argp[2],
|
||||
"mail, treaties, loans, or announcements? ", buf);
|
||||
if (p == 0)
|
||||
return RET_SYN;
|
||||
switch (*p) {
|
||||
case 'a':
|
||||
|
|
|
@ -50,9 +50,10 @@ setres(void)
|
|||
struct nstr_sect nstr;
|
||||
char buf[1024];
|
||||
|
||||
if ((what = getstarg(player->argp[1],
|
||||
"Set What (iron, gold, oil, uranium, fertility)? ",
|
||||
buf)) == 0)
|
||||
what = getstarg(player->argp[1],
|
||||
"Set What (iron, gold, oil, uranium, fertility)? ",
|
||||
buf);
|
||||
if (what == 0)
|
||||
return RET_SYN;
|
||||
switch (what[0]) {
|
||||
case 'i':
|
||||
|
|
|
@ -54,9 +54,10 @@ setsector(void)
|
|||
char buf[1024];
|
||||
char char0, char1;
|
||||
|
||||
if ((what = getstarg(player->argp[1],
|
||||
"Give What (iron, gold, oil, uranium, fertility, owner, eff., mob., work, avail., oldown, mines)? ",
|
||||
buf)) == 0)
|
||||
what = getstarg(player->argp[1],
|
||||
"Give What (iron, gold, oil, uranium, fertility, owner, eff., mob., work, avail., oldown, mines)? ",
|
||||
buf);
|
||||
if (what == 0)
|
||||
return RET_SYN;
|
||||
char0 = what[0];
|
||||
char1 = what[1];
|
||||
|
|
|
@ -709,29 +709,29 @@ att_ask_support(int offset, int *fortp, int *shipp, int *landp,
|
|||
*fortp = *shipp = 0;
|
||||
*landp = *planep = 0;
|
||||
|
||||
if (!(p = getstarg(player->argp[offset], "Use fort support? ",
|
||||
buf)))
|
||||
p = getstarg(player->argp[offset], "Use fort support? ", buf);
|
||||
if (!p)
|
||||
return RET_SYN;
|
||||
|
||||
if ((*p == 'y') || (*p == 'Y'))
|
||||
*fortp = 1;
|
||||
|
||||
if (!(p = getstarg(player->argp[offset + 1], "Use ship support? ",
|
||||
buf)))
|
||||
p = getstarg(player->argp[offset + 1], "Use ship support? ", buf);
|
||||
if (!p)
|
||||
return RET_SYN;
|
||||
|
||||
if ((*p == 'y') || (*p == 'Y'))
|
||||
*shipp = 1;
|
||||
|
||||
if (!(p = getstarg(player->argp[offset + 2], "Use land support? ",
|
||||
buf)))
|
||||
p = getstarg(player->argp[offset + 2], "Use land support? ", buf);
|
||||
if (!p)
|
||||
return RET_SYN;
|
||||
|
||||
if ((*p == 'y') || (*p == 'Y'))
|
||||
*landp = 1;
|
||||
|
||||
if (!(p = getstarg(player->argp[offset + 3], "Use plane support? ",
|
||||
buf)))
|
||||
p = getstarg(player->argp[offset + 3], "Use plane support? ", buf);
|
||||
if (!p)
|
||||
return RET_SYN;
|
||||
|
||||
if ((*p == 'y') || (*p == 'Y'))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue