]> git.pond.sub.org Git - empserver/commitdiff
Clean up unreadable assignments within if conditionals
authorMarkus Armbruster <armbru@pond.sub.org>
Sat, 21 Mar 2009 08:24:45 +0000 (09:24 +0100)
committerMarkus Armbruster <armbru@pond.sub.org>
Sat, 21 Mar 2009 08:24:45 +0000 (09:24 +0100)
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.

15 files changed:
src/lib/commands/buil.c
src/lib/commands/cede.c
src/lib/commands/chan.c
src/lib/commands/coll.c
src/lib/commands/decl.c
src/lib/commands/demo.c
src/lib/commands/edit.c
src/lib/commands/load.c
src/lib/commands/lten.c
src/lib/commands/mfir.c
src/lib/commands/miss.c
src/lib/commands/reje.c
src/lib/commands/setres.c
src/lib/commands/setsect.c
src/lib/subs/attsub.c

index fadcb56cc2e47e45f21bd693108546643f89730d..a7a1cee23fb8beae8cf0ca624677835718b9a569 100644 (file)
@@ -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;
 
index bb35322fb896eb1ee7cfea470b15b847d0b8ccbe..656a2eb6ffaed95583869bd1b9451270c84b2783 100644 (file)
@@ -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;
index 9009568901ee2145baf4f1d2e256089b42261e0f..21903f2918f241cbe147790abd175d157c0c3730 100644 (file)
@@ -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);
index 6d002744ca6719761d3c787ec4eb477f8fc11eb0..667c2e1f4c9046ce70972527c8818f071fdb81de 100644 (file)
@@ -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;
index 62a1ee93019b4d45936fba650c8688761d5caa79..3401efc0525842ac1c4bbfdc51a0cbb49da82bdd 100644 (file)
@@ -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':
index 9922109540b386066fd78098b3726d08b80089dc..9daddc539476e10ef4be40ead4261503faffab31 100644 (file)
@@ -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;
index 3a8656f7f8146061c360cd5d307800ad8782da01..6b370b3f6a30e37477915e67b719db1feebf2258 100644 (file)
@@ -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) {
index 96af9887de1bafb3224ae01c5c4df48266e79fcb..c5e84cd9bc630f1f925891489ad4220ffc1982ba 100644 (file)
@@ -166,23 +166,21 @@ load(void)
 
        switch (type) {
        case EF_PLANE:
-           if (0 !=
-               (retval =
-                load_plane_ship(&sect, &ship, noisy, load_unload,
-                                &nships)))
+           retval = load_plane_ship(&sect, &ship, noisy, load_unload,
+                                    &nships);
+           if (retval != 0)
                return retval;
            break;
        case EF_LAND:
-           if (0 !=
-               (retval =
-                load_land_ship(&sect, &ship, noisy, load_unload,
-                               &nships)))
+           retval = load_land_ship(&sect, &ship, noisy, load_unload,
+                                   &nships);
+           if (retval != 0)
                return retval;
            break;
        case EF_SECTOR:
-           if (0 !=
-               (retval =
-                load_comm_ship(&sect, &ship, ich, load_unload, &nships)))
+           retval = load_comm_ship(&sect, &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(&sect, &land, noisy, load_unload,
-                               &nunits)))
+           retval = load_land_land(&sect, &land, noisy, load_unload,
+                                   &nunits);
+           if (retval != 0)
                return retval;
            break;
        case EF_PLANE:
-           if (0 !=
-               (retval =
-                load_plane_land(&sect, &land, noisy, load_unload,
-                                &nunits)))
+           retval = load_plane_land(&sect, &land, noisy, load_unload,
+                                    &nunits);
+           if (retval != 0)
                return retval;
            break;
        case EF_SECTOR:
-           if (0 !=
-               (retval =
-                load_comm_land(&sect, &land, ich, load_unload, &nunits)))
+           retval = load_comm_land(&sect, &land, ich, load_unload,
+                                   &nunits);
+           if (retval != 0)
                return retval;
        }
        /* load/unload plague */
index 7341eb79854fca6f535edd024628c690873d90e2..60b7008a099a725325e2ba52720422df6907e9d4 100644 (file)
@@ -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;
index e2f973c695801053a219436658dd0eddfbfa71ad..c4b89c4ea555de7f253d326d7121476410d57b61 100644 (file)
@@ -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) {
index 7170de859513173ad317e3d193474836226bfb2f..a1243860d487005337064531bdb43b58f8faa2f6 100644 (file)
@@ -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;
 
 /*
index 8452079fc09902d3d40e7bd31a3e92cb9351b814..4c165ca8c736f9543ec8caf4073bd5c6ee2269b4 100644 (file)
@@ -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':
index 383068da40f0e8365d8bfb1ecb3c08cbcadd5ab7..0a3c106775ea1a78bd12b785b3d29e79c637a91e 100644 (file)
@@ -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':
index 9157636e337517ad0e4ab80a19d7dbbd5f69b2a4..117e7315537991dbdacab7abfd263ed826e232be 100644 (file)
@@ -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];
index 64b462bdca1d0e289dcce613eaa8ef661f51204d..1e958a90889e18930775c69d4957e96d0a793989 100644 (file)
@@ -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'))