Skip to contentSkip to conversation

staging: rtl8723bs: Mark ACPI table declaration as used

PATCH In review Nathan Chancellor 3 participants 7 messages Sep 26, 2018 – Jan 10, 2019 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: rtl8723bs: Mark ACPI table declaration as used

Clang emits the following warning:

drivers/staging/rtl8723bs/os_dep/sdio_intf.c:25:36: warning: variable 'acpi_ids' is not needed and will not be emitted [-Wunneeded-internal-declaration]

static const struct acpi_device_id acpi_ids[] = {
                                   ^

1 warning generated.

Mark acpi_ids with the attribute __used, which makes it clear to Clang that we don't want this warning while not inhibiting Clang's dead code elimination from removing the unreferenced internal symbol when moving the data to the globally available symbol with MODULE_DEVICE_TABLE.

$ nm -S drivers/staging/rtl8723bs/os_dep/sdio_intf.o | grep acpi
0000000000000000 0000000000000040 R __mod_acpi__acpi_ids_device_table
---
 drivers/staging/rtl8723bs/os_dep/sdio_intf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/rtl8723bs/os_dep/sdio_intf.c +1 -1
index 6d02904de63f..7c03b69b8ed3 100644
@@ -22,7 +22,7 @@ static const struct sdio_device_id sdio_ids[] =
 	{ SDIO_DEVICE(0x024c, 0xb723), },
 	{ /* end: all zeroes */				},
 };
-static const struct acpi_device_id acpi_ids[] = {
+static const struct acpi_device_id acpi_ids[] __used = {
 	{"OBDA8723", 0x0000},
 	{}
 };
Signature · 1 line
2.19.0
#1 lore raw
Quoted 29 lines · Nathan Chancellor

Clang emits the following warning:

drivers/staging/rtl8723bs/os_dep/sdio_intf.c:25:36: warning: variable 'acpi_ids' is not needed and will not be emitted [-Wunneeded-internal-declaration]

static const struct acpi_device_id acpi_ids[] = {
                                   ^

1 warning generated.

Mark acpi_ids with the attribute __used, which makes it clear to Clang that we don't want this warning while not inhibiting Clang's dead code elimination from removing the unreferenced internal symbol when moving the data to the globally available symbol with MODULE_DEVICE_TABLE.

$ nm -S drivers/staging/rtl8723bs/os_dep/sdio_intf.o | grep acpi
0000000000000000 0000000000000040 R __mod_acpi__acpi_ids_device_table
---
 drivers/staging/rtl8723bs/os_dep/sdio_intf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/rtl8723bs/os_dep/sdio_intf.c +0 -0
index 6d02904de63f..7c03b69b8ed3 100644

drivers/staging/rtl8723bs/os_dep/sdio_intf.c static const struct sdio_device_id sdio_ids[] = · line 25

Quoted 5 lines
drivers/staging/rtl8723bs/os_dep/sdio_intf.c +1 -1
@@ -22,7 +22,7 @@ static const struct sdio_device_id sdio_ids[] =
 	{ SDIO_DEVICE(0x024c, 0xb723), },
 	{ /* end: all zeroes */				},
 };
-static const struct acpi_device_id acpi_ids[] = {
+static const struct acpi_device_id acpi_ids[] __used = {

Can't we put __used somewhere in the MODULE_DEVICE_TABLE() macro so we don't have to go adding it to all individual entries?

thanks,

greg k-h

Reviewed-by
#2 lore raw
Quoted 26 lines · Greg Kroah-Hartman
Quoted 24 lines · Nathan Chancellor

Clang emits the following warning:

drivers/staging/rtl8723bs/os_dep/sdio_intf.c:25:36: warning: variable 'acpi_ids' is not needed and will not be emitted [-Wunneeded-internal-declaration]

static const struct acpi_device_id acpi_ids[] = {
                                   ^

1 warning generated.

Mark acpi_ids with the attribute __used, which makes it clear to Clang that we don't want this warning while not inhibiting Clang's dead code elimination from removing the unreferenced internal symbol when moving the data to the globally available symbol with MODULE_DEVICE_TABLE.

$ nm -S drivers/staging/rtl8723bs/os_dep/sdio_intf.o | grep acpi
0000000000000000 0000000000000040 R __mod_acpi__acpi_ids_device_table
---
 drivers/staging/rtl8723bs/os_dep/sdio_intf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 13 lines

drivers/staging/rtl8723bs/os_dep/sdio_intf.c static const struct sdio_device_id sdio_ids[] = · line 25

Quoted 10 lines
drivers/staging/rtl8723bs/os_dep/sdio_intf.c +1 -1
index 6d02904de63f..7c03b69b8ed3 100644
@@ -22,7 +22,7 @@ static const struct sdio_device_id sdio_ids[] =
      { SDIO_DEVICE(0x024c, 0xb723), },
      { /* end: all zeroes */                         },
 };
-static const struct acpi_device_id acpi_ids[] = {
+static const struct acpi_device_id acpi_ids[] __used = {

Can't we put __used somewhere in the MODULE_DEVICE_TABLE() macro so we don't have to go adding it to all individual entries?

Maybe; I'm still trying to think of what we could do in that macro to make its arg appear to be used while still being no functional change.

This is not a million-little-commits problem; more like 2 drivers in the whole tree have this problem.

Note that this change that Nathan has DOES NOT need to applied to every driver that uses MODULE_DEVICE_TABLE. Only when the struct has no other references other than JUST being passed to MODULE_DEVICE_TABLE() is this a problem. For an allyesconfig, I only see 2 instances of this case in the whole tree:

https://github.com/ClangBuiltLinux/linux/issues/169 <- this patch is addressing
https://github.com/ClangBuiltLinux/linux/issues/178 <- waiting on the results of this patch

If you're ok with this change to two drivers, then:

Signature · 2 lines
Thanks,
~Nick Desaulniers
#3 lore raw
Quoted 43 lines · Nick Desaulniers
Quoted 26 lines · Greg Kroah-Hartman
Quoted 24 lines · Nathan Chancellor

Clang emits the following warning:

drivers/staging/rtl8723bs/os_dep/sdio_intf.c:25:36: warning: variable 'acpi_ids' is not needed and will not be emitted [-Wunneeded-internal-declaration]

static const struct acpi_device_id acpi_ids[] = {
                                   ^

1 warning generated.

Mark acpi_ids with the attribute __used, which makes it clear to Clang that we don't want this warning while not inhibiting Clang's dead code elimination from removing the unreferenced internal symbol when moving the data to the globally available symbol with MODULE_DEVICE_TABLE.

$ nm -S drivers/staging/rtl8723bs/os_dep/sdio_intf.o | grep acpi
0000000000000000 0000000000000040 R __mod_acpi__acpi_ids_device_table
---
 drivers/staging/rtl8723bs/os_dep/sdio_intf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 13 lines

drivers/staging/rtl8723bs/os_dep/sdio_intf.c static const struct sdio_device_id sdio_ids[] = · line 25

Quoted 10 lines
drivers/staging/rtl8723bs/os_dep/sdio_intf.c +1 -1
index 6d02904de63f..7c03b69b8ed3 100644
@@ -22,7 +22,7 @@ static const struct sdio_device_id sdio_ids[] =
      { SDIO_DEVICE(0x024c, 0xb723), },
      { /* end: all zeroes */                         },
 };
-static const struct acpi_device_id acpi_ids[] = {
+static const struct acpi_device_id acpi_ids[] __used = {

Can't we put __used somewhere in the MODULE_DEVICE_TABLE() macro so we don't have to go adding it to all individual entries?

Quoted 2 lines

Maybe; I'm still trying to think of what we could do in that macro to make its arg appear to be used while still being no functional change.

Sorry, I meant to say:
No, the __used needs to go on the declaration of the struct array, not the alias being created within MODULE_DEVICE_TABLE(). I'm still trying to think of what we can do *in* MODULE_DEVICE_TABLE() to prevent this problem tree-wide, without having to modify any call sites.

Quoted 19 lines

This is not a million-little-commits problem; more like 2 drivers in the whole tree have this problem.

Note that this change that Nathan has DOES NOT need to applied to every driver that uses MODULE_DEVICE_TABLE. Only when the struct has no other references other than JUST being passed to MODULE_DEVICE_TABLE() is this a problem. For an allyesconfig, I only see 2 instances of this case in the whole tree:

https://github.com/ClangBuiltLinux/linux/issues/169 <- this patch is addressing
https://github.com/ClangBuiltLinux/linux/issues/178 <- waiting on the results of this patch

If you're ok with this change to two drivers, then:

--
Thanks,
~Nick Desaulniers

Signature · 2 lines
Thanks,
~Nick Desaulniers
#4 lore raw

Digging up an old thread to point out I was wrong:

Quoted 9 lines · Nick Desaulniers
Quoted 9 lines

This is not a million-little-commits problem; more like 2 drivers in the whole tree have this problem.

Note that this change that Nathan has DOES NOT need to applied to every driver that uses MODULE_DEVICE_TABLE. Only when the struct has no other references other than JUST being passed to MODULE_DEVICE_TABLE() is this a problem. For an allyesconfig, I only see 2 instances of this case in the whole tree:

Quoted 6 lines
Quoted 6 lines

https://github.com/ClangBuiltLinux/linux/issues/169 <- this patch is addressing
https://github.com/ClangBuiltLinux/linux/issues/178 <- waiting on the results of this patch

If you're ok with this change to two drivers, then:

I just landed a fix for this in Clang
(https://reviews.llvm.org/rL350776) which will ship soon in Clang 8. Sedat helped test this patch and reported that it removed 41 false-negative warnings
https://github.com/ClangBuiltLinux/linux/issues/232#issuecomment-440006399

Signature · 2 lines
Thanks,
~Nick Desaulniers
maintainer
#5 lore raw
Quoted 17 lines · Nick Desaulniers

Digging up an old thread to point out I was wrong:

Quoted 13 lines · Nick Desaulniers
Quoted 13 lines

This is not a million-little-commits problem; more like 2 drivers in the whole tree have this problem.

Note that this change that Nathan has DOES NOT need to applied to every driver that uses MODULE_DEVICE_TABLE. Only when the struct has no other references other than JUST being passed to MODULE_DEVICE_TABLE() is this a problem. For an allyesconfig, I only see 2 instances of this case in the whole tree:

https://github.com/ClangBuiltLinux/linux/issues/169 <- this patch is addressing
https://github.com/ClangBuiltLinux/linux/issues/178 <- waiting on the results of this patch

Quoted 8 lines
Quoted 2 lines
Quoted 2 lines

If you're ok with this change to two drivers, then:

I just landed a fix for this in Clang
(https://reviews.llvm.org/rL350776) which will ship soon in Clang 8. Sedat helped test this patch and reported that it removed 41 false-negative warnings
https://github.com/ClangBuiltLinux/linux/issues/232#issuecomment-440006399

Great, thanks for letting me know. Can I revert this patch?

thanks,

greg k-h

#6 lore raw
Quoted 22 lines · Greg KH
Quoted 20 lines · Nick Desaulniers

Digging up an old thread to point out I was wrong:

Quoted 15 lines · Nick Desaulniers
Quoted 15 lines

This is not a million-little-commits problem; more like 2 drivers in the whole tree have this problem.

Note that this change that Nathan has DOES NOT need to applied to every driver that uses MODULE_DEVICE_TABLE. Only when the struct has no other references other than JUST being passed to MODULE_DEVICE_TABLE() is this a problem. For an allyesconfig, I only see 2 instances of this case in the whole tree:

https://github.com/ClangBuiltLinux/linux/issues/169 <- this patch is addressing
https://github.com/ClangBuiltLinux/linux/issues/178 <- waiting on the results of this patch

If you're ok with this change to two drivers, then:

Quoted 7 lines
Quoted 5 lines

I just landed a fix for this in Clang
(https://reviews.llvm.org/rL350776) which will ship soon in Clang 8. Sedat helped test this patch and reported that it removed 41 false-negative warnings
https://github.com/ClangBuiltLinux/linux/issues/232#issuecomment-440006399

Great, thanks for letting me know. Can I revert this patch?

Go for it. I think my mistake was that we had 2 instances of this listed in our bug tracker, but an allyesconfig had many many more instances than I was aware of.

Signature · 2 lines
Thanks,
~Nick Desaulniers