Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

comedi: ni_*: do not declare unused variable range_ni_E_ao_ext

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>
Link: https://lore.kernel.org/r/20240710173719.3559437-1-abbotti@mev.co.uk
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Ian Abbott and committed by
Greg Kroah-Hartman
4d41a49c 8400291e

+18 -11
+9
drivers/comedi/drivers/ni_atmio.c
··· 79 79 80 80 #include "ni_stc.h" 81 81 82 + static const struct comedi_lrange range_ni_E_ao_ext = { 83 + 4, { 84 + BIP_RANGE(10), 85 + UNI_RANGE(10), 86 + RANGE_ext(-1, 1), 87 + RANGE_ext(0, 1) 88 + } 89 + }; 90 + 82 91 /* AT specific setup */ 83 92 static const struct ni_board_struct ni_boards[] = { 84 93 {
-9
drivers/comedi/drivers/ni_mio_common.c
··· 166 166 } 167 167 }; 168 168 169 - static const struct comedi_lrange range_ni_E_ao_ext = { 170 - 4, { 171 - BIP_RANGE(10), 172 - UNI_RANGE(10), 173 - RANGE_ext(-1, 1), 174 - RANGE_ext(0, 1) 175 - } 176 - }; 177 - 178 169 static const struct comedi_lrange *const ni_range_lkup[] = { 179 170 [ai_gain_16] = &range_ni_E_ai, 180 171 [ai_gain_8] = &range_ni_E_ai_limited,
+9
drivers/comedi/drivers/ni_pcimio.c
··· 102 102 103 103 #define PCIDMA 104 104 105 + static const struct comedi_lrange range_ni_E_ao_ext = { 106 + 4, { 107 + BIP_RANGE(10), 108 + UNI_RANGE(10), 109 + RANGE_ext(-1, 1), 110 + RANGE_ext(0, 1) 111 + } 112 + }; 113 + 105 114 /* 106 115 * These are not all the possible ao ranges for 628x boards. 107 116 * They can do OFFSET +- REFERENCE where OFFSET can be
-2
drivers/comedi/drivers/ni_stc.h
··· 1137 1137 u8 rgout0_usage; 1138 1138 }; 1139 1139 1140 - static const struct comedi_lrange range_ni_E_ao_ext; 1141 - 1142 1140 #endif /* _COMEDI_NI_STC_H */