From e5c4b6f65a6da472a1c0188d1a1bce2fe60543b0 Mon Sep 17 00:00:00 2001 From: nhmall Date: Sun, 9 Oct 2022 09:11:56 -0400 Subject: [PATCH] potentially uninitialized variable warnings src/mkroom.c(1068) : warning C4701: potentially uninitialized local variable 'insidex' used src/mkroom.c(1070) : warning C4701: potentially uninitialized local variable 'insidey' used The warning is because the insidex and insidey variables only get assigned a value conditionally within a for-loop, but contain random values if that for-loop is not executed, and they are used unconditionaly later on in the code. Initializing them changes that from containing random values to containing zeros, whether that is appropriate or not. In this particular case, insidex and insidey look to be riding on the coat tails of insidect and there is a check for invalid insidect in the code, so that should catch the situation. --- src/mkroom.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mkroom.c b/src/mkroom.c index 5389e02d0..a02d816d0 100644 --- a/src/mkroom.c +++ b/src/mkroom.c @@ -1041,7 +1041,7 @@ invalid_shop_shape(struct mkroom *sroom) coordxy x, y; coordxy doorx = g.doors[sroom->fdoor].x; coordxy doory = g.doors[sroom->fdoor].y; - coordxy insidex, insidey, insidect = 0; + coordxy insidex = 0, insidey = 0, insidect = 0; /* First, identify squares inside the room and next to the door. */ for (x = max(doorx - 1, sroom->lx);