linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nathan Chancellor <nathan@kernel.org>
To: Arnd Bergmann <arnd@kernel.org>, Jiri Kosina <jikos@kernel.org>,
	Benjamin Tissoires <benjamin.tissoires@redhat.com>,
	Nick Desaulniers <ndesaulniers@google.com>,
	Julian Sax <jsbc@gmx.de>
Cc: Arnd Bergmann <arnd@arndb.de>,
	Hans de Goede <hdegoede@redhat.com>,
	Douglas Anderson <dianders@chromium.org>,
	Kai-Heng Feng <kai.heng.feng@canonical.com>,
	Xiaofei Tan <tanxiaofei@huawei.com>,
	Coiby Xu <coiby.xu@gmail.com>,
	linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
	clang-built-linux@googlegroups.com
Subject: Re: [PATCH] HID: i2c-hid: fix format string mismatch
Date: Fri, 14 May 2021 10:40:56 -0700	[thread overview]
Message-ID: <84b20dcb-b063-b2b0-b2dc-1a1befbc334c@kernel.org> (raw)
In-Reply-To: <20210514135901.2924982-1-arnd@kernel.org>

On 5/14/2021 6:58 AM, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> clang doesn't like printing a 32-bit integer using %hX format string:
> 
> drivers/hid/i2c-hid/i2c-hid-core.c:994:18: error: format specifies type 'unsigned short' but the argument has type '__u32' (aka 'unsigned int') [-Werror,-Wformat]
>                   client->name, hid->vendor, hid->product);
>                                 ^~~~~~~~~~~
> drivers/hid/i2c-hid/i2c-hid-core.c:994:31: error: format specifies type 'unsigned short' but the argument has type '__u32' (aka 'unsigned int') [-Werror,-Wformat]
>                   client->name, hid->vendor, hid->product);
>                                              ^~~~~~~~~~~~
> 
> Use an explicit cast to truncate it to the low 16 bits instead.
> 
> Fixes: 9ee3e06610fd ("HID: i2c-hid: override HID descriptors for certain devices")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Reviewed-by: Nathan Chancellor <nathan@kernel.org>

> ---
>   drivers/hid/i2c-hid/i2c-hid-core.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/hid/i2c-hid/i2c-hid-core.c b/drivers/hid/i2c-hid/i2c-hid-core.c
> index 9993133989a5..f9d28ad17d9c 100644
> --- a/drivers/hid/i2c-hid/i2c-hid-core.c
> +++ b/drivers/hid/i2c-hid/i2c-hid-core.c
> @@ -990,8 +990,8 @@ int i2c_hid_core_probe(struct i2c_client *client, struct i2chid_ops *ops,
>   	hid->vendor = le16_to_cpu(ihid->hdesc.wVendorID);
>   	hid->product = le16_to_cpu(ihid->hdesc.wProductID);
>   
> -	snprintf(hid->name, sizeof(hid->name), "%s %04hX:%04hX",
> -		 client->name, hid->vendor, hid->product);
> +	snprintf(hid->name, sizeof(hid->name), "%s %04X:%04X",
> +		 client->name, (u16)hid->vendor, (u16)hid->product);
>   	strlcpy(hid->phys, dev_name(&client->dev), sizeof(hid->phys));
>   
>   	ihid->quirks = i2c_hid_lookup_quirk(hid->vendor, hid->product);
> 


  reply	other threads:[~2021-05-14 17:41 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-14 13:58 [PATCH] HID: i2c-hid: fix format string mismatch Arnd Bergmann
2021-05-14 17:40 ` Nathan Chancellor [this message]
2021-05-26 10:49 ` Jiri Kosina

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=84b20dcb-b063-b2b0-b2dc-1a1befbc334c@kernel.org \
    --to=nathan@kernel.org \
    --cc=arnd@arndb.de \
    --cc=arnd@kernel.org \
    --cc=benjamin.tissoires@redhat.com \
    --cc=clang-built-linux@googlegroups.com \
    --cc=coiby.xu@gmail.com \
    --cc=dianders@chromium.org \
    --cc=hdegoede@redhat.com \
    --cc=jikos@kernel.org \
    --cc=jsbc@gmx.de \
    --cc=kai.heng.feng@canonical.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=tanxiaofei@huawei.com \
    /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).