c_load() initializes @ich only when @type is EF_SECTOR. It also uses
it only then. Clang is cool with this, but GCC gets confused and
warns "‘ich’ may be used uninitialized". Ron Koenderink reports
Visual Studio 2019 even flags it as an error. Same for c_lload() and
c_tend().
Time to clean this up. Rearrange the code to avoid the warning and
also improve readability a bit.
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
* David Sharnoff, 1987
* Ken Stevens, 1995 (rewritten)
* Steve McClure, 1998-2000
* David Sharnoff, 1987
* Ken Stevens, 1995 (rewritten)
* Steve McClure, 1998-2000
- * Markus Armbruster, 2004-2018
+ * Markus Armbruster, 2004-2021
"What commodity (or 'plane' or 'land')? ", buf);
if (!p || !*p)
return RET_SYN;
"What commodity (or 'plane' or 'land')? ", buf);
if (!p || !*p)
return RET_SYN;
if (!strncmp(p, "plane", 5))
type = EF_PLANE;
else if (!strncmp(p, "land", 4))
type = EF_LAND;
if (!strncmp(p, "plane", 5))
type = EF_PLANE;
else if (!strncmp(p, "land", 4))
type = EF_LAND;
- else if (NULL != (ich = item_by_name(p)))
type = EF_SECTOR;
else {
pr("Can't %sload '%s'\n", loading ? "" : "un", p);
type = EF_SECTOR;
else {
pr("Can't %sload '%s'\n", loading ? "" : "un", p);
"What commodity (or 'plane' or 'land')? ", buf);
if (!p || !*p)
return RET_SYN;
"What commodity (or 'plane' or 'land')? ", buf);
if (!p || !*p)
return RET_SYN;
if (!strncmp(p, "plane", 5))
type = EF_PLANE;
else if (!strncmp(p, "land", 4))
type = EF_LAND;
if (!strncmp(p, "plane", 5))
type = EF_PLANE;
else if (!strncmp(p, "land", 4))
type = EF_LAND;
- else if (NULL != (ich = item_by_name(p)))
type = EF_SECTOR;
else {
pr("Can't %sload '%s'\n", loading ? "" : "un", p);
type = EF_SECTOR;
else {
pr("Can't %sload '%s'\n", loading ? "" : "un", p);
* Dave Pare, 1986
* Thomas Ruschak, 1992
* Steve McClure, 2000
* Dave Pare, 1986
* Thomas Ruschak, 1992
* Steve McClure, 2000
- * Markus Armbruster, 2004-2017
+ * Markus Armbruster, 2004-2021
buf);
if (!p || !*p)
return RET_SYN;
buf);
if (!p || !*p)
return RET_SYN;
if (!strncmp(p, "land", 4))
type = EF_LAND;
if (!strncmp(p, "land", 4))
type = EF_LAND;
- else if (NULL != (ip = item_by_name(p)))
type = EF_SECTOR;
else {
pr("Can't tend '%s'\n", p);
type = EF_SECTOR;
else {
pr("Can't tend '%s'\n", p);