From: PatR Date: Tue, 17 Aug 2021 23:31:14 +0000 (-0700) Subject: Oselect() for monster's weapon X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c99895ad2057dbcbf8455bd72cdb81913cf00d6a;p=nethack Oselect() for monster's weapon Make the Oselect() macro less likely to accidentally interfere with caller's if-then-else usage. --- diff --git a/src/weapon.c b/src/weapon.c index 62539aafa..0be11a51c 100644 --- a/src/weapon.c +++ b/src/weapon.c @@ -1,4 +1,4 @@ -/* NetHack 3.7 weapon.c $NHDT-Date: 1607811730 2020/12/12 22:22:10 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.89 $ */ +/* NetHack 3.7 weapon.c $NHDT-Date: 1629243070 2021/08/17 23:31:10 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.95 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Robert Patrick Rankin, 2011. */ /* NetHack may be freely redistributed. See license for details. */ @@ -465,9 +465,11 @@ silver_sears(struct monst *magr UNUSED, struct monst *mdef, } static struct obj *oselect(struct monst *, int); -#define Oselect(x) \ - if ((otmp = oselect(mtmp, x)) != 0) \ - return otmp; +#define Oselect(x) \ + do { \ + if ((otmp = oselect(mtmp, x)) != 0) \ + return otmp; \ + } while (0) static struct obj * oselect(struct monst *mtmp, int x)