mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] staging: comedi: ni_*: do not declare unused variable range_ni_E_ao_ext
@ 2024-07-10 17:37 Ian Abbott
  2024-07-10 17:51 ` Greg Kroah-Hartman
  0 siblings, 1 reply; 2+ messages in thread
From: Ian Abbott @ 2024-07-10 17:37 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, Ian Abbott, H Hartley Sweeten, Mirsad Todorovac

Mirsad Todorovac reported a compiler warning in "ni_stc.h" due to the
variable `range_ni_E_ao_ext` being defined but unused when building the
"ni_routes_test" module.

The `range_ni_E_ao_ext` variable is tentatively defined in "ni_stc.h"
(with internal linkage) and fully defined in "ni_mio_common.c".
"ni_stc.h" and/or "ni_mio_common.c" are included by the "ni_atmio",
"ni_pcimio", "ni_mio_cs", and "ni_routes_test" modules, which will each
get their own local `range_ni_E_ao_ext` variable defined.  However, it
is not used by the "ni_mio_cs" or "ni_routes_test" modules.  They should
get optimized out, but there are compiler warnings about the unused
variable when built with the `W=1` option.

Move the full definition of the variable from "ni_mio_common.c" into the
places where it is used, namely "ni_atmio.c" and "ni_pcimio.c", and
remove the tentative definition of the variable from "ni_stc.h".  This
fixes the compiler warnings.

Reported-by: Mirsad Todorovac <mtodorovac69@gmail.com>
Link: https://lore.kernel.org/lkml/3bab8580-c01a-4183-94af-ba3193c94c0e@gmail.com/
Cc: Mirsad Todorovac <mtodorovac69@gmail.com>
Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
---
Note: The linked report also covers similar warnings elsewhere in the
kernel, so is not closed by this patch.
---
 drivers/comedi/drivers/ni_atmio.c      | 9 +++++++++
 drivers/comedi/drivers/ni_mio_common.c | 9 ---------
 drivers/comedi/drivers/ni_pcimio.c     | 9 +++++++++
 drivers/comedi/drivers/ni_stc.h        | 2 --
 4 files changed, 18 insertions(+), 11 deletions(-)

diff --git a/drivers/comedi/drivers/ni_atmio.c b/drivers/comedi/drivers/ni_atmio.c
index 8876a1d24c56..330ae1c58800 100644
--- a/drivers/comedi/drivers/ni_atmio.c
+++ b/drivers/comedi/drivers/ni_atmio.c
@@ -79,6 +79,15 @@
 
 #include "ni_stc.h"
 
+static const struct comedi_lrange range_ni_E_ao_ext = {
+	4, {
+		BIP_RANGE(10),
+		UNI_RANGE(10),
+		RANGE_ext(-1, 1),
+		RANGE_ext(0, 1)
+	}
+};
+
 /* AT specific setup */
 static const struct ni_board_struct ni_boards[] = {
 	{
diff --git a/drivers/comedi/drivers/ni_mio_common.c b/drivers/comedi/drivers/ni_mio_common.c
index 980f309d6de7..3acb449d293c 100644
--- a/drivers/comedi/drivers/ni_mio_common.c
+++ b/drivers/comedi/drivers/ni_mio_common.c
@@ -166,15 +166,6 @@ static const struct comedi_lrange range_ni_M_ai_628x = {
 	}
 };
 
-static const struct comedi_lrange range_ni_E_ao_ext = {
-	4, {
-		BIP_RANGE(10),
-		UNI_RANGE(10),
-		RANGE_ext(-1, 1),
-		RANGE_ext(0, 1)
-	}
-};
-
 static const struct comedi_lrange *const ni_range_lkup[] = {
 	[ai_gain_16] = &range_ni_E_ai,
 	[ai_gain_8] = &range_ni_E_ai_limited,
diff --git a/drivers/comedi/drivers/ni_pcimio.c b/drivers/comedi/drivers/ni_pcimio.c
index 0b055321023d..f63c390314e1 100644
--- a/drivers/comedi/drivers/ni_pcimio.c
+++ b/drivers/comedi/drivers/ni_pcimio.c
@@ -102,6 +102,15 @@
 
 #define PCIDMA
 
+static const struct comedi_lrange range_ni_E_ao_ext = {
+	4, {
+		BIP_RANGE(10),
+		UNI_RANGE(10),
+		RANGE_ext(-1, 1),
+		RANGE_ext(0, 1)
+	}
+};
+
 /*
  * These are not all the possible ao ranges for 628x boards.
  * They can do OFFSET +- REFERENCE where OFFSET can be
diff --git a/drivers/comedi/drivers/ni_stc.h b/drivers/comedi/drivers/ni_stc.h
index fbc0b753a0f5..7837e4683c6d 100644
--- a/drivers/comedi/drivers/ni_stc.h
+++ b/drivers/comedi/drivers/ni_stc.h
@@ -1137,6 +1137,4 @@ struct ni_private {
 	u8 rgout0_usage;
 };
 
-static const struct comedi_lrange range_ni_E_ao_ext;
-
 #endif /* _COMEDI_NI_STC_H */
-- 
2.43.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] staging: comedi: ni_*: do not declare unused variable range_ni_E_ao_ext
  2024-07-10 17:37 [PATCH] staging: comedi: ni_*: do not declare unused variable range_ni_E_ao_ext Ian Abbott
@ 2024-07-10 17:51 ` Greg Kroah-Hartman
  0 siblings, 0 replies; 2+ messages in thread
From: Greg Kroah-Hartman @ 2024-07-10 17:51 UTC (permalink / raw)
  To: Ian Abbott; +Cc: linux-kernel, H Hartley Sweeten, Mirsad Todorovac

On Wed, Jul 10, 2024 at 06:37:19PM +0100, Ian Abbott wrote:
> Mirsad Todorovac reported a compiler warning in "ni_stc.h" due to the
> variable `range_ni_E_ao_ext` being defined but unused when building the
> "ni_routes_test" module.
> 
> The `range_ni_E_ao_ext` variable is tentatively defined in "ni_stc.h"
> (with internal linkage) and fully defined in "ni_mio_common.c".
> "ni_stc.h" and/or "ni_mio_common.c" are included by the "ni_atmio",
> "ni_pcimio", "ni_mio_cs", and "ni_routes_test" modules, which will each
> get their own local `range_ni_E_ao_ext` variable defined.  However, it
> is not used by the "ni_mio_cs" or "ni_routes_test" modules.  They should
> get optimized out, but there are compiler warnings about the unused
> variable when built with the `W=1` option.
> 
> Move the full definition of the variable from "ni_mio_common.c" into the
> places where it is used, namely "ni_atmio.c" and "ni_pcimio.c", and
> remove the tentative definition of the variable from "ni_stc.h".  This
> fixes the compiler warnings.
> 
> Reported-by: Mirsad Todorovac <mtodorovac69@gmail.com>
> Link: https://lore.kernel.org/lkml/3bab8580-c01a-4183-94af-ba3193c94c0e@gmail.com/
> Cc: Mirsad Todorovac <mtodorovac69@gmail.com>
> Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
> ---
> Note: The linked report also covers similar warnings elsewhere in the
> kernel, so is not closed by this patch.

Nit, no need for "staging:" in the subject line anymore :)

I'll fix that up when applying it, no need to resend.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-07-10 17:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-07-10 17:37 [PATCH] staging: comedi: ni_*: do not declare unused variable range_ni_E_ao_ext Ian Abbott
2024-07-10 17:51 ` Greg Kroah-Hartman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®