* [PATCH v2] hw/input/tsc2005: Fix -Wchar-subscripts warning in tsc2005_txrx()
@ 2024-05-08 14:35 Philippe Mathieu-Daudé
2024-05-20 12:49 ` Peter Maydell
0 siblings, 1 reply; 3+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-05-08 14:35 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-arm, Peter Maydell, Philippe Mathieu-Daudé
Check the function index is in range and use an unsigned
variable to avoid the following warning with GCC 13.2.0:
[666/5358] Compiling C object libcommon.fa.p/hw_input_tsc2005.c.o
hw/input/tsc2005.c: In function 'tsc2005_timer_tick':
hw/input/tsc2005.c:416:26: warning: array subscript has type 'char' [-Wchar-subscripts]
416 | s->dav |= mode_regs[s->function];
| ~^~~~~~~~~~
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
v2: Use Peter suggestion
---
hw/input/tsc2005.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/hw/input/tsc2005.c b/hw/input/tsc2005.c
index 941f163d36..8d35892c09 100644
--- a/hw/input/tsc2005.c
+++ b/hw/input/tsc2005.c
@@ -406,6 +406,9 @@ uint32_t tsc2005_txrx(void *opaque, uint32_t value, int len)
static void tsc2005_timer_tick(void *opaque)
{
TSC2005State *s = opaque;
+ unsigned int function = s->function;
+
+ assert(function < ARRAY_SIZE(mode_regs);
/* Timer ticked -- a set of conversions has been finished. */
@@ -413,7 +416,7 @@ static void tsc2005_timer_tick(void *opaque)
return;
s->busy = false;
- s->dav |= mode_regs[s->function];
+ s->dav |= mode_regs[function];
s->function = -1;
tsc2005_pin_update(s);
}
--
2.41.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2] hw/input/tsc2005: Fix -Wchar-subscripts warning in tsc2005_txrx()
2024-05-08 14:35 [PATCH v2] hw/input/tsc2005: Fix -Wchar-subscripts warning in tsc2005_txrx() Philippe Mathieu-Daudé
@ 2024-05-20 12:49 ` Peter Maydell
2024-05-29 4:52 ` Philippe Mathieu-Daudé
0 siblings, 1 reply; 3+ messages in thread
From: Peter Maydell @ 2024-05-20 12:49 UTC (permalink / raw)
To: Philippe Mathieu-Daudé; +Cc: qemu-devel, qemu-arm
On Wed, 8 May 2024 at 15:35, Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
>
> Check the function index is in range and use an unsigned
> variable to avoid the following warning with GCC 13.2.0:
>
> [666/5358] Compiling C object libcommon.fa.p/hw_input_tsc2005.c.o
> hw/input/tsc2005.c: In function 'tsc2005_timer_tick':
> hw/input/tsc2005.c:416:26: warning: array subscript has type 'char' [-Wchar-subscripts]
> 416 | s->dav |= mode_regs[s->function];
> | ~^~~~~~~~~~
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> v2: Use Peter suggestion
> ---
> hw/input/tsc2005.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/hw/input/tsc2005.c b/hw/input/tsc2005.c
> index 941f163d36..8d35892c09 100644
> --- a/hw/input/tsc2005.c
> +++ b/hw/input/tsc2005.c
> @@ -406,6 +406,9 @@ uint32_t tsc2005_txrx(void *opaque, uint32_t value, int len)
> static void tsc2005_timer_tick(void *opaque)
> {
> TSC2005State *s = opaque;
> + unsigned int function = s->function;
> +
> + assert(function < ARRAY_SIZE(mode_regs);
Missing ')' -- this doesn't compile ;-)
Applied to target-arm.next with the typo fixed, thanks.
-- PMM
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] hw/input/tsc2005: Fix -Wchar-subscripts warning in tsc2005_txrx()
2024-05-20 12:49 ` Peter Maydell
@ 2024-05-29 4:52 ` Philippe Mathieu-Daudé
0 siblings, 0 replies; 3+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-05-29 4:52 UTC (permalink / raw)
To: Peter Maydell; +Cc: qemu-devel, qemu-arm
On 20/5/24 14:49, Peter Maydell wrote:
> On Wed, 8 May 2024 at 15:35, Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
>>
>> Check the function index is in range and use an unsigned
>> variable to avoid the following warning with GCC 13.2.0:
>>
>> [666/5358] Compiling C object libcommon.fa.p/hw_input_tsc2005.c.o
>> hw/input/tsc2005.c: In function 'tsc2005_timer_tick':
>> hw/input/tsc2005.c:416:26: warning: array subscript has type 'char' [-Wchar-subscripts]
>> 416 | s->dav |= mode_regs[s->function];
>> | ~^~~~~~~~~~
>>
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>> ---
>> v2: Use Peter suggestion
>> ---
>> hw/input/tsc2005.c | 5 ++++-
>> 1 file changed, 4 insertions(+), 1 deletion(-)
>>
>> diff --git a/hw/input/tsc2005.c b/hw/input/tsc2005.c
>> index 941f163d36..8d35892c09 100644
>> --- a/hw/input/tsc2005.c
>> +++ b/hw/input/tsc2005.c
>> @@ -406,6 +406,9 @@ uint32_t tsc2005_txrx(void *opaque, uint32_t value, int len)
>> static void tsc2005_timer_tick(void *opaque)
>> {
>> TSC2005State *s = opaque;
>> + unsigned int function = s->function;
>> +
>> + assert(function < ARRAY_SIZE(mode_regs);
>
> Missing ')' -- this doesn't compile ;-)
Oops I apologize for not even build-testing :/
> Applied to target-arm.next with the typo fixed, thanks.
Thanks!
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-05-29 4:52 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-08 14:35 [PATCH v2] hw/input/tsc2005: Fix -Wchar-subscripts warning in tsc2005_txrx() Philippe Mathieu-Daudé
2024-05-20 12:49 ` Peter Maydell
2024-05-29 4:52 ` Philippe Mathieu-Daudé
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).