linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Johan Hovold <johan@kernel.org>
Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] Input: usbtouchscreen - suppress empty array warnings
Date: Wed, 22 Jun 2022 16:22:08 -0700	[thread overview]
Message-ID: <YrOkIMJK3G3VkhLk@google.com> (raw)
In-Reply-To: <20220620084628.20894-2-johan@kernel.org>

Hi Johan,

On Mon, Jun 20, 2022 at 10:46:27AM +0200, Johan Hovold wrote:
> When compile-testing the USB touchscreen driver without enabling any of
> the device type options the usbtouch_dev_info array ends up being empty,
> something which triggers compiler warning with -Warray-bounds
> (gcc-11.3.0).
> 
> drivers/input/touchscreen/usbtouchscreen.c: In function 'usbtouch_probe':
> drivers/input/touchscreen/usbtouchscreen.c:1668:16:warning: array subscript <unknown> is outside array bounds of 'struct usbtouch_device_info[0]' [-Warray-bounds]
>  1668 |         type = &usbtouch_dev_info[id->driver_info];
> 
> Suppress the warnings by making sure that the array is always non-empty.

Does it still warn if you add a check for type, something like

	if (type >= ARRAY_SIZE(usbtouch_device_info))
		return -ENODEV;

?

Thanks.

-- 
Dmitry

  reply	other threads:[~2022-06-22 23:22 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-20  8:46 [PATCH 0/2] Input: usbtouchscreen - suppress empty array warnings Johan Hovold
2022-06-20  8:46 ` [PATCH 1/2] " Johan Hovold
2022-06-22 23:22   ` Dmitry Torokhov [this message]
2022-06-23  5:53     ` Johan Hovold
2022-06-20  8:46 ` [PATCH 2/2] Input: usbtouchscreen - add driver_info sanity check Johan Hovold

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YrOkIMJK3G3VkhLk@google.com \
    --to=dmitry.torokhov@gmail.com \
    --cc=johan@kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).