Skip to content

Commit b2fce81

Browse files
mdrustadMatt Fleming
authored andcommitted
efi: Resolve some shadow warnings
It is a really bad idea to declare variables or parameters that have the same name as common types. It is valid C, but it gets surprising if a macro expansion attempts to declare an inner local with that type. Change the local names to eliminate the hazard. Change s16 => str16, s8 => str8. This resolves warnings seen when using W=2 during make, for instance: drivers/firmware/efi/vars.c: In function ‘dup_variable_bug’: drivers/firmware/efi/vars.c:324:44: warning: declaration of ‘s16’ shadows a global declaration [-Wshadow] static void dup_variable_bug(efi_char16_t *s16, efi_guid_t *vendor_guid, drivers/firmware/efi/vars.c:328:8: warning: declaration of ‘s8’ shadows a global declaration [-Wshadow] char *s8; Signed-off-by: Mark Rustad <mark.d.rustad@intel.com> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com> Signed-off-by: Matt Fleming <matt.fleming@intel.com>
1 parent 65ba758 commit b2fce81

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

‎drivers/firmware/efi/vars.c‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -321,11 +321,11 @@ static unsigned long var_name_strnsize(efi_char16_t *variable_name,
321321
* Print a warning when duplicate EFI variables are encountered and
322322
* disable the sysfs workqueue since the firmware is buggy.
323323
*/
324-
static void dup_variable_bug(efi_char16_t *s16, efi_guid_t *vendor_guid,
324+
static void dup_variable_bug(efi_char16_t *str16, efi_guid_t *vendor_guid,
325325
unsigned long len16)
326326
{
327327
size_t i, len8 = len16 / sizeof(efi_char16_t);
328-
char *s8;
328+
char *str8;
329329

330330
/*
331331
* Disable the workqueue since the algorithm it uses for
@@ -334,16 +334,16 @@ static void dup_variable_bug(efi_char16_t *s16, efi_guid_t *vendor_guid,
334334
*/
335335
efivar_wq_enabled = false;
336336

337-
s8 = kzalloc(len8, GFP_KERNEL);
338-
if (!s8)
337+
str8 = kzalloc(len8, GFP_KERNEL);
338+
if (!str8)
339339
return;
340340

341341
for (i = 0; i < len8; i++)
342-
s8[i] = s16[i];
342+
str8[i] = str16[i];
343343

344344
printk(KERN_WARNING "efivars: duplicate variable: %s-%pUl\n",
345-
s8, vendor_guid);
346-
kfree(s8);
345+
str8, vendor_guid);
346+
kfree(str8);
347347
}
348348

349349
/**

0 commit comments

Comments
 (0)