From 85493a2581d8bb2eeea1345c9a2ee550f7c974be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dan=20Hor=C3=A1k?= Date: Tue, 11 Jul 2023 13:02:53 +0000 Subject: [PATCH] zdev: silence "maybe uninitialized" warning in lszdev.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The compiler doesn't fully understand the code block that precedes the usage of `site` in the condition and thus it thinks it could be uninitialized. Silence the warning with an explicit initialization. In function 'get_site_from_pers', inlined from 'dev_table_get_value' at lszdev.c:1079:10: lszdev.c:258:20: warning: 'site' may be used uninitialized [-Wmaybe-uninitialized] 258 | if (site == SITE_FALLBACK) | ^ lszdev.c: In function 'dev_table_get_value': lszdev.c:234:13: note: 'site' was declared here 234 | int site, i, num = 0; | ^~~~ Closes: https://github.com/ibm-s390-linux/s390-tools/pull/152 Signed-off-by: Dan Horák Reviewed-by: Marc Hartmayer Signed-off-by: Jan Höppner --- zdev/src/lszdev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zdev/src/lszdev.c b/zdev/src/lszdev.c index 7bcd0e38..8d3754b3 100644 --- a/zdev/src/lszdev.c +++ b/zdev/src/lszdev.c @@ -231,7 +231,7 @@ static action_t get_action(struct options *opts) /* Determine the site information from the device */ static char *get_site_from_pers(struct device *dev) { - int site, i, num = 0; + int site = 0, i, num = 0; for (i = 0; i < NUM_SITES; i++) { if (dev->site_specific[i].exists) {