subs/wu: Avoid "may be used uninitialized" warnings
typed_wu() either sends a telegram to a single recipient @to, or an announcement. It initializes @np to getnatp(to) only when sending a telegram. It also uses it only then. Clang is cool with this, but GCC gets confused and warns "‘np’ may be used uninitialized". Ron Koenderink reports Visual Studio 2019 even flags it as an error. Time to clean this up. Initialize @np to NULL when sending an announcement. Fuse conditionals while there. Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This commit is contained in:
parent
4914daa587
commit
e23882161e
1 changed files with 8 additions and 6 deletions
|
@ -28,7 +28,7 @@
|
|||
*
|
||||
* Known contributors to this file:
|
||||
* Steve McClure, 2000
|
||||
* Markus Armbruster, 2005-2016
|
||||
* Markus Armbruster, 2005-2021
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
@ -110,14 +110,16 @@ typed_wu(natid from, natid to, char *message, int type)
|
|||
char box[1024];
|
||||
struct player *other;
|
||||
|
||||
if (type == TEL_ANNOUNCE)
|
||||
if (type == TEL_ANNOUNCE) {
|
||||
strcpy(box, annfil);
|
||||
else
|
||||
np = NULL;
|
||||
} else {
|
||||
mailbox(box, to);
|
||||
|
||||
if (type != TEL_ANNOUNCE)
|
||||
if (!(np = getnatp(to)) || np->nat_stat < STAT_SANCT)
|
||||
np = getnatp(to);
|
||||
if (!np || np->nat_stat < STAT_SANCT)
|
||||
return -1;
|
||||
}
|
||||
|
||||
#if !defined(_WIN32)
|
||||
if ((fd = open(box, O_WRONLY | O_APPEND, 0)) < 0) {
|
||||
#else
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue