From ea0a1240df671de221f469327899564ed74b5edd Mon Sep 17 00:00:00 2001 From: Stefano Brivio Date: Wed, 30 Apr 2025 16:48:34 +0200 Subject: passt-repair: Hide bogus gcc warning from -Og MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When building with gcc 13 and -Og, we get: passt-repair.c: In function ‘main’: passt-repair.c:161:23: warning: ‘ev’ may be used uninitialized [-Wmaybe-uninitialized] 161 | if (ev->len > NAME_MAX + 1 || ev->name[ev->len - 1] != '\0') { | ~~^~~~~ but that can't actually happen, because we only exit the preceding while loop if 'found' is true, and that only happens, in turn, as we assign 'ev'. Get rid of the warning by (redundantly) initialising ev to NULL. Signed-off-by: Stefano Brivio --- passt-repair.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/passt-repair.c b/passt-repair.c index 256a8c9..ff1c44f 100644 --- a/passt-repair.c +++ b/passt-repair.c @@ -113,7 +113,7 @@ int main(int argc, char **argv) if ((sb.st_mode & S_IFMT) == S_IFDIR) { char buf[sizeof(struct inotify_event) + NAME_MAX + 1] __attribute__ ((aligned(__alignof__(struct inotify_event)))); - const struct inotify_event *ev; + const struct inotify_event *ev = NULL; char path[PATH_MAX + 1]; bool found = false; ssize_t n; -- cgit v1.2.3