zdev: silence "maybe uninitialized" warning in lszdev.c

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 <dan@danny.cz>
Reviewed-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
Dan Horák
2023-07-11 13:02:53 +00:00
committed by Jan Höppner
parent ad544565fe
commit 85493a2581

View File

@@ -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) {