From: Thierry Reding <thierry.reding@gmail.com>
To: Lee Jones <lee@kernel.org>
Cc: Jani Nikula <jani.nikula@linux.intel.com>,
linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org,
Jonathan Hunter <jonathanh@nvidia.com>,
linux-tegra@vger.kernel.org,
Mikko Perttunen <mperttunen@nvidia.com>
Subject: Re: [PATCH 15/20] drm/tegra/hub: Increase buffer size to ensure all possible values can be stored
Date: Thu, 24 Aug 2023 15:45:54 +0200 [thread overview]
Message-ID: <ZOdfEg9vF1umkEyO@orome> (raw)
In-Reply-To: <20230824120124.GR1380343@google.com>
[-- Attachment #1: Type: text/plain, Size: 1912 bytes --]
On Thu, Aug 24, 2023 at 01:01:24PM +0100, Lee Jones wrote:
> On Thu, 24 Aug 2023, Jani Nikula wrote:
>
> > On Thu, 24 Aug 2023, Thierry Reding <thierry.reding@gmail.com> wrote:
> > > On Thu, Aug 24, 2023 at 08:37:00AM +0100, Lee Jones wrote:
> > >> When converting from int to string, we must allow for up to 10-chars (2147483647).
> > >>
> > >> Fixes the following W=1 kernel build warning(s):
> > >>
> > >> drivers/gpu/drm/tegra/hub.c: In function ‘tegra_display_hub_probe’:
> > >> drivers/gpu/drm/tegra/hub.c:1106:47: warning: ‘%u’ directive output may be truncated writing between 1 and 10 bytes into a region of size 4 [-Wformat-truncation=]
> > >> drivers/gpu/drm/tegra/hub.c:1106:42: note: directive argument in the range [0, 4294967294]
> > >> drivers/gpu/drm/tegra/hub.c:1106:17: note: ‘snprintf’ output between 6 and 15 bytes into a destination of size 8
> > >
> > > I wish there was (perhaps there is?) a better way to annotate that i
> > > will always be within a given range. In practice this is always going to
> > > be smaller than 10 and even in future hardware I wouldn't expect this to
> > > ever exceed anything like 32 or 64, so 8 characters is already generous.
> >
> > I assume you could do
> >
> > snprintf(id, sizeof(id), "wgrp%u", (unsigned char)i);
> >
> > but it's perhaps less obvious than just increasing the size of the
> > buffer.
>
> I had the very same thought process.
It's not a big deal, this happens all on the stack, so adding a couple
of bytes isn't going to hurt very much. Still with all the tooling that
we have it'd be nice if something could be added. Perhaps an alternative
would be to reject values for num_wgrp that are bigger than 32. With
that the compiler might have enough information not to warn about this.
Anyway, no need to spend any more time on this, I'm fine with the patch
as-is.
Thierry
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2023-08-24 13:47 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-24 7:36 [PATCH (set 1) 00/20] Rid W=1 warnings from GPU Lee Jones
2023-08-24 7:37 ` [PATCH 15/20] drm/tegra/hub: Increase buffer size to ensure all possible values can be stored Lee Jones
2023-08-24 9:25 ` Thierry Reding
2023-08-24 9:33 ` Jani Nikula
2023-08-24 12:01 ` Lee Jones
2023-08-24 13:45 ` Thierry Reding [this message]
2023-08-24 8:59 ` [PATCH (set 1) 00/20] Rid W=1 warnings from GPU Maxime Ripard
2023-08-24 9:03 ` Maxime Ripard
2023-08-24 12:10 ` Lee Jones
2023-08-24 9:03 ` Jani Nikula
2023-08-24 9:16 ` Maxime Ripard
2023-08-24 12:07 ` Lee Jones
2023-08-24 12:08 ` Lee Jones
2023-08-24 12:14 ` Hamza Mahfooz
2023-08-24 12:24 ` Lee Jones
2023-08-28 16:11 ` Michel Dänzer
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=ZOdfEg9vF1umkEyO@orome \
--to=thierry.reding@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=jani.nikula@linux.intel.com \
--cc=jonathanh@nvidia.com \
--cc=lee@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tegra@vger.kernel.org \
--cc=mperttunen@nvidia.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