https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115185
--- Comment #24 from Alejandro Colomar <alx at kernel dot org> --- (In reply to Wentao Zhang from comment #18) > This produces warnings in kernel defconfig builds and they become errors due > to > CONFIG_WERROR. > > Cases I've observed so far: > > 1. initialization > https://elixir.bootlin.com/linux/v6.10-rc7/source/drivers/pnp/quirks.c#L412 > related definition > https://elixir.bootlin.com/linux/v6.10-rc7/source/include/linux/pnp.h#L293 > 2. initialization > https://elixir.bootlin.com/linux/v6.10-rc7/source/drivers/acpi/nhlt.c#L23 > related definition > https://elixir.bootlin.com/linux/v6.10-rc7/source/include/acpi/actbl.h#L69 > 3. > https://elixir.bootlin.com/linux/v6.10-rc7/source/drivers/acpi/tables.c#L385 > 4. initialization > https://elixir.bootlin.com/linux/v6.10-rc7/source/drivers/acpi/acpica/ > acpredef.h#L187 > related definition > https://elixir.bootlin.com/linux/v6.10-rc7/source/drivers/acpi/acpica/ > aclocal.h#L296 > 5. initialization > https://elixir.bootlin.com/linux/v6.10-rc7/source/drivers/acpi/acpica/ > nsrepair.c#L66 > related definition > https://elixir.bootlin.com/linux/v6.10-rc7/source/drivers/acpi/acpica/ > aclocal.h#L373 > 6. initialization > https://elixir.bootlin.com/linux/v6.10-rc7/source/drivers/acpi/acpica/ > nsrepair2.c#L114 > related definition > https://elixir.bootlin.com/linux/v6.10-rc7/source/drivers/acpi/acpica/ > nsrepair2.c#L28 > 7. > https://elixir.bootlin.com/linux/v6.10-rc7/source/drivers/gpu/drm/display/ > drm_dp_dual_mode_helper.c#L163 > 8. initialization > https://elixir.bootlin.com/linux/v6.10-rc7/source/drivers/power/supply/ > power_supply_sysfs.c#L182 > related definition > https://elixir.bootlin.com/linux/v6.10-rc7/source/drivers/power/supply/ > power_supply_sysfs.c#L26 > 9. https://elixir.bootlin.com/linux/v6.10-rc7/source/fs/proc/task_mmu.c#L648 > > In the "drivers/power/supply/power_supply_sysfs.c" case, > > static struct power_supply_attr power_supply_attrs[] = { > ... > POWER_SUPPLY_ATTR(CHARGE_CONTROL_START_THRESHOLD), > ... > } > > will get expanded to > > [POWER_SUPPLY_PROP_CHARGE_CONTROL_START_THRESHOLD] = { > .prop_name = "CHARGE_CONTROL_START_THRESHOLD", > .attr_name = "j" "\0", > .text_values = ((void *)0), > .text_values_len = 0, > }, > > It still triggers the warning even if "\0" is explicitly specified and the > length is exactly MAX_PROP_NAME_LEN + 1 (31). (In reply to Alejandro Colomar from comment #23) > (In reply to Wentao Zhang from comment #18) > > This produces warnings in kernel defconfig builds and they become errors due > > to > > CONFIG_WERROR. > > > > Cases I've observed so far: > > > > 1. initialization > > https://elixir.bootlin.com/linux/v6.10-rc7/source/drivers/pnp/quirks.c#L412 > > related definition > > https://elixir.bootlin.com/linux/v6.10-rc7/source/include/linux/pnp.h#L293 > > 2. initialization > > https://elixir.bootlin.com/linux/v6.10-rc7/source/drivers/acpi/nhlt.c#L23 > > related definition > > https://elixir.bootlin.com/linux/v6.10-rc7/source/include/acpi/actbl.h#L69 > > 3. > > https://elixir.bootlin.com/linux/v6.10-rc7/source/drivers/acpi/tables.c#L385 > > 4. initialization > > https://elixir.bootlin.com/linux/v6.10-rc7/source/drivers/acpi/acpica/ > > acpredef.h#L187 > > related definition > > https://elixir.bootlin.com/linux/v6.10-rc7/source/drivers/acpi/acpica/ > > aclocal.h#L296 > > 5. initialization > > https://elixir.bootlin.com/linux/v6.10-rc7/source/drivers/acpi/acpica/ > > nsrepair.c#L66 > > related definition > > https://elixir.bootlin.com/linux/v6.10-rc7/source/drivers/acpi/acpica/ > > aclocal.h#L373 > > 6. initialization > > https://elixir.bootlin.com/linux/v6.10-rc7/source/drivers/acpi/acpica/ > > nsrepair2.c#L114 > > related definition > > https://elixir.bootlin.com/linux/v6.10-rc7/source/drivers/acpi/acpica/ > > nsrepair2.c#L28 > > 7. > > https://elixir.bootlin.com/linux/v6.10-rc7/source/drivers/gpu/drm/display/ > > drm_dp_dual_mode_helper.c#L163 > > 8. initialization > > https://elixir.bootlin.com/linux/v6.10-rc7/source/drivers/power/supply/ > > power_supply_sysfs.c#L182 > > related definition > > https://elixir.bootlin.com/linux/v6.10-rc7/source/drivers/power/supply/ > > power_supply_sysfs.c#L26 > > 9. https://elixir.bootlin.com/linux/v6.10-rc7/source/fs/proc/task_mmu.c#L648 > > > Would you mind writing here how those cases look like after macro expansion? > It's hard to read through all of those indirections. (Sorry, I started with the only link that had the macros. The other were easy to read.) Here's a summary. There's only a bug. (1) Bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115185#c21> (2) False positive. It only uses strncmp(3), AFAICS. Could use array notation. Also, memcmp(3) might be more appropriate. (3) False positive. It only uses memcmp(3). (4) False positive. It only uses strncmp(3), AFAICS. Could use array notation. Also, memcmp(3) might be more appropriate. (5) False positive. Seems similar to (4). (6) False positive. Seems similar to (5). (7) False positive. It only uses memcmp(3). Could use a pragma. (8) False positive. The explicit "\0" was a clever trick to get a diagnostic if it wasn't a string. We now have this warning flag, so that trick can be removed. (9) False positive. It uses the bytes separately. Could use array notation.