part2: remediate some nonnull-related compiler warnings
do.c:296:16: warning: nonnull parameter 'obj' will evaluate to 'true' on first encounter [-Wpointer-bool-conversion]
296 | while (obj && (otmp = obj_nexto_xy(obj, x, y, TRUE)) != 0) {
| ^~~ ~~
../include/extern.h:538:43: note: declared 'nonnull' here
538 | const char *) NONNULLPTRS;
| ^
../include/tradstdc.h:378:36: note: expanded from macro 'NONNULLPTRS'
378 | #define NONNULLPTRS __attribute__((nonnull))
| ^
1 warning generated.
invent.c:807:12: warning: nonnull parameter 'objlist' will evaluate to 'true' on first encounter [-Wpointer-bool-conversion]
807 | while (objlist) {
| ~~~~~ ^~~~~~~
../include/extern.h:1230:61: note: declared 'nonnull' here
1230 | extern struct obj *merge_choice(struct obj *, struct obj *) NONNULLPTRS;
| ^
../include/tradstdc.h:378:36: note: expanded from macro 'NONNULLPTRS'
378 | #define NONNULLPTRS __attribute__((nonnull))
| ^
1 warning generated.
monmove.c:2091:23: warning: nonnull parameter 'mtmp' will evaluate to 'true' on first encounter [-Wpointer-bool-conversion]
2091 | boolean is_pet = (mtmp && mtmp->mtame && !mtmp->isminion);
| ^~~~ ~~
../include/extern.h:1844:67: note: declared 'nonnull' here
1844 | extern boolean undesirable_disp(struct monst *, coordxy, coordxy) NONNULLARG1;
| ^
../include/tradstdc.h:379:36: note: expanded from macro 'NONNULLARG1'
379 | #define NONNULLARG1 __attribute__((nonnull (1)))
| ^
1 warning generated.
nhlua.c:2095:9: warning: nonnull parameter 'L' will evaluate to 'true' on first encounter [-Wpointer-bool-conversion]
2095 | if (L)
| ~~ ^
../include/extern.h:1985:35: note: declared 'nonnull' here
1985 | extern void nhl_done(lua_State *) NONNULLARG1;
| ^
../include/tradstdc.h:379:36: note: expanded from macro 'NONNULLARG1'
379 | #define NONNULLARG1 __attribute__((nonnull (1)))
| ^
1 warning generated.
steal.c:59:12: warning: nonnull parameter 'chain' will evaluate to 'true' on first encounter [-Wpointer-bool-conversion]
59 | while (chain && chain->otyp != GOLD_PIECE)
| ^~~~~ ~~
../include/extern.h:2910:43: note: declared 'nonnull' here
2910 | extern struct obj *findgold(struct obj *) NONNULLARG1;
| ^
../include/tradstdc.h:379:36: note: expanded from macro 'NONNULLARG1'
379 | #define NONNULLARG1 __attribute__((nonnull (1)))
| ^
1 warning generated.
utf8map.c:232:9: warning: nonnull parameter 'gmap' will evaluate to 'true' on first encounter [-Wpointer-bool-conversion]
232 | if (gmap) {
| ~~ ^~~~
../include/extern.h:3318:28: note: declared 'nonnull' here
3318 | long ucolor) NONNULLPTRS;
| ^
../include/tradstdc.h:378:36: note: expanded from macro 'NONNULLPTRS'
378 | #define NONNULLPTRS __attribute__((nonnull))
| ^
1 warning generated.
worn.c:895:15: warning: nonnull parameter 'objchain' will evaluate to 'true' on first encounter [-Wpointer-bool-conversion]
895 | if (on && objchain)
| ~~ ^~~~~~~~
../include/extern.h:3664:51: note: declared 'nonnull' here
3664 | extern void bypass_objlist(struct obj *, boolean) NONNULLARG1;
| ^
../include/tradstdc.h:379:36: note: expanded from macro 'NONNULLARG1'
379 | #define NONNULLARG1 __attribute__((nonnull (1)))
| ^
worn.c:897:12: warning: nonnull parameter 'objchain' will evaluate to 'true' on first encounter [-Wpointer-bool-conversion]
897 | while (objchain) {
| ~~~~~ ^~~~~~~~
../include/extern.h:3664:51: note: declared 'nonnull' here
3664 | extern void bypass_objlist(struct obj *, boolean) NONNULLARG1;
| ^
../include/tradstdc.h:379:36: note: expanded from macro 'NONNULLARG1'
379 | #define NONNULLARG1 __attribute__((nonnull (1)))
| ^
worn.c:908:12: warning: nonnull parameter 'objchain' will evaluate to 'true' on first encounter [-Wpointer-bool-conversion]
908 | while (objchain) {
| ~~~~~ ^~~~~~~~
../include/extern.h:3665:53: note: declared 'nonnull' here
3665 | extern struct obj *nxt_unbypassed_obj(struct obj *) NONNULLARG1;
| ^
../include/tradstdc.h:379:36: note: expanded from macro 'NONNULLARG1'
379 | #define NONNULLARG1 __attribute__((nonnull (1)))
| ^
3 warnings generated.
This commit is contained in:
@@ -228,26 +228,27 @@ set_map_u(glyph_map *gmap, uint32 utf32ch, const uint8 *utf8str, long ucolor)
|
||||
{
|
||||
static uint32_t closecolor = 0;
|
||||
static int clridx = 0;
|
||||
glyph_map *tmpgm = gmap;
|
||||
|
||||
if (gmap) {
|
||||
if (gmap->u == 0) {
|
||||
gmap->u = (struct unicode_representation *) alloc(sizeof *gmap->u);
|
||||
gmap->u->utf8str = 0;
|
||||
}
|
||||
if (gmap->u->utf8str != 0) {
|
||||
free(gmap->u->utf8str);
|
||||
gmap->u->utf8str = 0;
|
||||
}
|
||||
gmap->u->utf8str = (uint8 *) dupstr((const char *) utf8str);
|
||||
gmap->u->ucolor = ucolor;
|
||||
if (closest_color(ucolor, &closecolor, &clridx))
|
||||
gmap->u->u256coloridx = clridx;
|
||||
else
|
||||
gmap->u->u256coloridx = 0;
|
||||
gmap->u->utf32ch = utf32ch;
|
||||
return 1;
|
||||
if (!tmpgm)
|
||||
return 0;
|
||||
|
||||
if (gmap->u == 0) {
|
||||
gmap->u = (struct unicode_representation *) alloc(sizeof *gmap->u);
|
||||
gmap->u->utf8str = 0;
|
||||
}
|
||||
return 0;
|
||||
if (gmap->u->utf8str != 0) {
|
||||
free(gmap->u->utf8str);
|
||||
gmap->u->utf8str = 0;
|
||||
}
|
||||
gmap->u->utf8str = (uint8 *) dupstr((const char *) utf8str);
|
||||
gmap->u->ucolor = ucolor;
|
||||
if (closest_color(ucolor, &closecolor, &clridx))
|
||||
gmap->u->u256coloridx = clridx;
|
||||
else
|
||||
gmap->u->u256coloridx = 0;
|
||||
gmap->u->utf32ch = utf32ch;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user