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:
Markus Armbruster 2009-03-21 09:24:45 +01:00
parent 7c6e56bd02
commit 57717b5bc1
15 changed files with 75 additions and 75 deletions

View file

@ -86,10 +86,10 @@ buil(void)
char buf[1024]; char buf[1024];
natp = getnatp(player->cnum); natp = getnatp(player->cnum);
if ((p = p = getstarg(player->argp[1],
getstarg(player->argp[1], "Build (ship, nuke, bridge, plane, land unit, tower)? ",
"Build (ship, nuke, bridge, plane, land unit, tower)? ", buf);
buf)) == 0) if (p == 0)
return RET_SYN; return RET_SYN;
what = *p; what = *p;

View file

@ -76,9 +76,9 @@ cede(void)
if (is_sector && is_ship) { if (is_sector && is_ship) {
int type; int type;
if ((p = p = getstarg(player->argp[3], "Cede sectors or ships (se, sh)? ",
getstarg(player->argp[3], "Cede sectors or ships (se, sh)? ", buf);
buf)) == 0) if (p == 0)
return RET_FAIL; return RET_FAIL;
if (strlen(p) > 4) if (strlen(p) > 4)
p[2] = 0; p[2] = 0;

View file

@ -46,9 +46,8 @@ chan(void)
char buf[1024]; char buf[1024];
struct natstr *us; struct natstr *us;
if ((p = p = getstarg(player->argp[1], "country name or representative? ", buf);
getstarg(player->argp[1], "country name or representative? ", if (p == 0)
buf)) == 0)
return RET_SYN; return RET_SYN;
us = getnatp(player->cnum); us = getnatp(player->cnum);
if (us->nat_stat == STAT_VIS) { if (us->nat_stat == STAT_VIS) {
@ -76,8 +75,8 @@ chan(void)
charge = us->nat_money / 10; charge = us->nat_money / 10;
} }
} }
if ((p = p = getstarg(player->argp[2], "New country name -- ", buf);
getstarg(player->argp[2], "New country name -- ", buf)) == 0) if (p == 0)
return RET_SYN; return RET_SYN;
if (!check_nat_name(p)) if (!check_nat_name(p))
return RET_FAIL; return RET_FAIL;
@ -90,8 +89,8 @@ chan(void)
case 'p': case 'p':
case 'r': case 'r':
pr("(note: these are stored in plain text.)\n"); pr("(note: these are stored in plain text.)\n");
if ((p = getstarg(player->argp[2], p = getstarg(player->argp[2], "New representative name -- ", buf);
"New representative name -- ", buf)) == 0) if (p == 0)
return RET_SYN; return RET_SYN;
p[sizeof(us->nat_pnam) - 1] = 0; p[sizeof(us->nat_pnam) - 1] = 0;
strcpy(us->nat_pnam, p); strcpy(us->nat_pnam, p);

View file

@ -78,8 +78,9 @@ coll(void)
} }
pr("You are owed $%.2f on that loan.\n", owed); pr("You are owed $%.2f on that loan.\n", owed);
if (!(p = getstarg(player->argp[2], p = getstarg(player->argp[2],
"What sector do you wish to confiscate? ", buf))) "What sector do you wish to confiscate? ", buf);
if (!p)
return RET_SYN; return RET_SYN;
if (!check_loan_ok(&loan)) if (!check_loan_ok(&loan))
return RET_FAIL; return RET_FAIL;

View file

@ -46,9 +46,10 @@ decl(void)
char *p; char *p;
char buf[1024]; char buf[1024];
if (!(p = getstarg(player->argp[1], p = getstarg(player->argp[1],
"alliance, friendly, neutrality, hostility, or war? ", "alliance, friendly, neutrality, hostility, or war? ",
buf))) buf);
if (!p)
return RET_SYN; return RET_SYN;
switch (*p) { switch (*p) {
case 'a': case 'a':

View file

@ -61,8 +61,9 @@ demo(void)
if (!(p = getstarg(player->argp[2], "Number to de-mobilize : ", buf))) if (!(p = getstarg(player->argp[2], "Number to de-mobilize : ", buf)))
return RET_SYN; return RET_SYN;
number = atoi(p); number = atoi(p);
if (!(p = getstarg(player->argp[3], p = getstarg(player->argp[3],
"New civilians on active reserve? (y/n) ", buf))) "New civilians on active reserve? (y/n) ", buf);
if (!p)
return RET_SYN; return RET_SYN;
if (*p != 'y' && *p != 'n') if (*p != 'y' && *p != 'n')
return RET_SYN; return RET_SYN;

View file

@ -85,9 +85,10 @@ edit(void)
char buf[1024]; char buf[1024];
char ewhat; char ewhat;
if ((what = getstarg(player->argp[1], what = getstarg(player->argp[1],
"Edit What (country, land, ship, plane, nuke, unit)? ", "Edit What (country, land, ship, plane, nuke, unit)? ",
buf)) == 0) buf);
if (what == 0)
return RET_SYN; return RET_SYN;
ewhat = what[0]; ewhat = what[0];
switch (ewhat) { switch (ewhat) {

View file

@ -166,23 +166,21 @@ load(void)
switch (type) { switch (type) {
case EF_PLANE: case EF_PLANE:
if (0 != retval = load_plane_ship(&sect, &ship, noisy, load_unload,
(retval = &nships);
load_plane_ship(&sect, &ship, noisy, load_unload, if (retval != 0)
&nships)))
return retval; return retval;
break; break;
case EF_LAND: case EF_LAND:
if (0 != retval = load_land_ship(&sect, &ship, noisy, load_unload,
(retval = &nships);
load_land_ship(&sect, &ship, noisy, load_unload, if (retval != 0)
&nships)))
return retval; return retval;
break; break;
case EF_SECTOR: case EF_SECTOR:
if (0 != retval = load_comm_ship(&sect, &ship, ich, load_unload,
(retval = &nships);
load_comm_ship(&sect, &ship, ich, load_unload, &nships))) if (retval != 0)
return retval; return retval;
} }
/* load/unload plague */ /* load/unload plague */
@ -281,23 +279,21 @@ lload(void)
switch (type) { switch (type) {
case EF_LAND: case EF_LAND:
if (0 != retval = load_land_land(&sect, &land, noisy, load_unload,
(retval = &nunits);
load_land_land(&sect, &land, noisy, load_unload, if (retval != 0)
&nunits)))
return retval; return retval;
break; break;
case EF_PLANE: case EF_PLANE:
if (0 != retval = load_plane_land(&sect, &land, noisy, load_unload,
(retval = &nunits);
load_plane_land(&sect, &land, noisy, load_unload, if (retval != 0)
&nunits)))
return retval; return retval;
break; break;
case EF_SECTOR: case EF_SECTOR:
if (0 != retval = load_comm_land(&sect, &land, ich, load_unload,
(retval = &nunits);
load_comm_land(&sect, &land, ich, load_unload, &nunits))) if (retval != 0)
return retval; return retval;
} }
/* load/unload plague */ /* load/unload plague */

View file

@ -74,8 +74,7 @@ ltend(void)
while (nxtitem(&tenders, &tender)) { while (nxtitem(&tenders, &tender)) {
if (!player->owner) if (!player->owner)
continue; continue;
if ((p = if (!(p = getstarg(player->argp[3], "Amount to transfer? ", buf)))
getstarg(player->argp[3], "Amount to transfer? ", buf)) == 0)
return RET_FAIL; return RET_FAIL;
if (!check_ship_ok(&tender)) if (!check_ship_ok(&tender))
return RET_FAIL; return RET_FAIL;

View file

@ -98,9 +98,9 @@ multifire(void)
emp_initque(&fired); emp_initque(&fired);
emp_initque(&defended); emp_initque(&defended);
if (!(p = getstarg(player->argp[1], p = getstarg(player->argp[1],
"Firing from ship(s), sect(s), or land unit(s)? ", "Firing from ship(s), sect(s), or land unit(s)? ", buf);
buf))) if (!p)
return RET_SYN; return RET_SYN;
type = ef_byname_from(p, ef_with_guns); type = ef_byname_from(p, ef_with_guns);
if (opt_NO_FORT_FIRE && type == EF_SECTOR) { if (opt_NO_FORT_FIRE && type == EF_SECTOR) {

View file

@ -62,9 +62,9 @@ mission(void)
struct nstr_item ni; struct nstr_item ni;
char buf[1024]; char buf[1024];
if ((p = p = getstarg(player->argp[1], "Ship, plane or land unit (p,sh,la)? ",
getstarg(player->argp[1], "Ship, plane or land unit (p,sh,la)? ", buf);
buf)) == 0) if (p == 0)
return RET_SYN; return RET_SYN;
type = ef_byname_from(p, ef_with_missions); type = ef_byname_from(p, ef_with_missions);
if (type < 0) { if (type < 0) {
@ -74,10 +74,10 @@ mission(void)
if (!snxtitem(&ni, type, player->argp[2], NULL)) if (!snxtitem(&ni, type, player->argp[2], NULL))
return RET_SYN; return RET_SYN;
if ((p = p = getstarg(player->argp[3],
getstarg(player->argp[3], "Mission (int, sup, osup, dsup, esc, res, air, query, clear)? ",
"Mission (int, sup, osup, dsup, esc, res, air, query, clear)? ", buf);
buf)) == 0) if (p == 0)
return RET_SYN; return RET_SYN;
/* /*

View file

@ -59,9 +59,9 @@ reje(void)
pr("That's not one of the choices!\n"); pr("That's not one of the choices!\n");
return RET_SYN; return RET_SYN;
} }
if ((p = p = getstarg(player->argp[2],
getstarg(player->argp[2], "mail, treaties, loans, or announcements? ", buf);
"mail, treaties, loans, or announcements? ", buf)) == 0) if (p == 0)
return RET_SYN; return RET_SYN;
switch (*p) { switch (*p) {
case 'a': case 'a':

View file

@ -50,9 +50,10 @@ setres(void)
struct nstr_sect nstr; struct nstr_sect nstr;
char buf[1024]; char buf[1024];
if ((what = getstarg(player->argp[1], what = getstarg(player->argp[1],
"Set What (iron, gold, oil, uranium, fertility)? ", "Set What (iron, gold, oil, uranium, fertility)? ",
buf)) == 0) buf);
if (what == 0)
return RET_SYN; return RET_SYN;
switch (what[0]) { switch (what[0]) {
case 'i': case 'i':

View file

@ -54,9 +54,10 @@ setsector(void)
char buf[1024]; char buf[1024];
char char0, char1; char char0, char1;
if ((what = getstarg(player->argp[1], what = getstarg(player->argp[1],
"Give What (iron, gold, oil, uranium, fertility, owner, eff., mob., work, avail., oldown, mines)? ", "Give What (iron, gold, oil, uranium, fertility, owner, eff., mob., work, avail., oldown, mines)? ",
buf)) == 0) buf);
if (what == 0)
return RET_SYN; return RET_SYN;
char0 = what[0]; char0 = what[0];
char1 = what[1]; char1 = what[1];

View file

@ -709,29 +709,29 @@ att_ask_support(int offset, int *fortp, int *shipp, int *landp,
*fortp = *shipp = 0; *fortp = *shipp = 0;
*landp = *planep = 0; *landp = *planep = 0;
if (!(p = getstarg(player->argp[offset], "Use fort support? ", p = getstarg(player->argp[offset], "Use fort support? ", buf);
buf))) if (!p)
return RET_SYN; return RET_SYN;
if ((*p == 'y') || (*p == 'Y')) if ((*p == 'y') || (*p == 'Y'))
*fortp = 1; *fortp = 1;
if (!(p = getstarg(player->argp[offset + 1], "Use ship support? ", p = getstarg(player->argp[offset + 1], "Use ship support? ", buf);
buf))) if (!p)
return RET_SYN; return RET_SYN;
if ((*p == 'y') || (*p == 'Y')) if ((*p == 'y') || (*p == 'Y'))
*shipp = 1; *shipp = 1;
if (!(p = getstarg(player->argp[offset + 2], "Use land support? ", p = getstarg(player->argp[offset + 2], "Use land support? ", buf);
buf))) if (!p)
return RET_SYN; return RET_SYN;
if ((*p == 'y') || (*p == 'Y')) if ((*p == 'y') || (*p == 'Y'))
*landp = 1; *landp = 1;
if (!(p = getstarg(player->argp[offset + 3], "Use plane support? ", p = getstarg(player->argp[offset + 3], "Use plane support? ", buf);
buf))) if (!p)
return RET_SYN; return RET_SYN;
if ((*p == 'y') || (*p == 'Y')) if ((*p == 'y') || (*p == 'Y'))