netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Simon Horman <horms@kernel.org>
To: Justin Lai <justinlai0215@realtek.com>
Cc: kuba@kernel.org, davem@davemloft.net, edumazet@google.com,
	pabeni@redhat.com, andrew+netdev@lunn.ch,
	linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
	pkshih@realtek.com, larry.chiu@realtek.com,
	kernel test robot <lkp@intel.com>
Subject: Re: [PATCH net v3 2/3] rtase: Increase the size of ivec->name
Date: Tue, 22 Apr 2025 13:55:46 +0100	[thread overview]
Message-ID: <20250422125546.GF2843373@horms.kernel.org> (raw)
In-Reply-To: <20250417085659.5740-3-justinlai0215@realtek.com>

On Thu, Apr 17, 2025 at 04:56:58PM +0800, Justin Lai wrote:
> Fix the following compile warning reported by the kernel test robot by
> increasing the size of ivec->name.
> 
> drivers/net/ethernet/realtek/rtase/rtase_main.c: In function 'rtase_open':
> >> drivers/net/ethernet/realtek/rtase/rtase_main.c:1117:52: warning:
> '%i' directive output may be truncated writing between 1 and 10 bytes
> into a region of size between 7 and 22 [-Wformat-truncation=]
>      snprintf(ivec->name, sizeof(ivec->name), "%s_int%i",
>                                                      ^~
>  drivers/net/ethernet/realtek/rtase/rtase_main.c:1117:45: note:
>  directive argument in the range [0, 2147483647]
>      snprintf(ivec->name, sizeof(ivec->name), "%s_int%i",
>                                               ^~~~~~~~~~
>  drivers/net/ethernet/realtek/rtase/rtase_main.c:1117:4: note:
>  'snprintf' output between 6 and 30 bytes into a destination of
>  size 26
>      snprintf(ivec->name, sizeof(ivec->name), "%s_int%i",
>      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>        tp->dev->name, i);
>        ~~~~~~~~~~~~~~~~~

Hi Justin,

Given that the type of i is u16, it's theoretical range of values is [0, 65536].
(I expect that in practice the range is significantly smaller.)

So the string representation of i should fit in the minumum of 7 bytes available
(only a maximum of 5 are needed).

And I do notice that newer compilers do not seem to warn about this.

So I don't really think this needs updating.
And if so, certainly not as a fix for 'net'.

Also, as an aside, as i is unsigned, the format specifier really ought
to be %u instead of %i. Not that it seems to make any difference here
given the range of values discussed above.

> Reported-by: kernel test robot <lkp@intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202503182158.nkAlbJWX-lkp@intel.com/
> Fixes: a36e9f5cfe9e ("rtase: Add support for a pci table in this module")
> Signed-off-by: Justin Lai <justinlai0215@realtek.com>

-- 
pw-bot: changes-requested

  reply	other threads:[~2025-04-22 12:55 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-17  8:56 [PATCH net v3 0/3] Modify overflow detection, expand ivec->name, and correct type in min_t Justin Lai
2025-04-17  8:56 ` [PATCH net v3 1/3] rtase: Modify the condition used to detect overflow in rtase_calc_time_mitigation Justin Lai
2025-04-22 13:20   ` Simon Horman
2025-04-23 11:32     ` Justin Lai
2025-04-17  8:56 ` [PATCH net v3 2/3] rtase: Increase the size of ivec->name Justin Lai
2025-04-22 12:55   ` Simon Horman [this message]
2025-04-23 11:53     ` Justin Lai
2025-04-23 16:16       ` Simon Horman
2025-04-17  8:56 ` [PATCH net v3 3/3] rtase: Fix a type error in min_t Justin Lai
2025-04-22 13:28   ` Simon Horman
2025-04-23 10:53     ` Justin Lai
2025-04-23 16:16       ` Simon Horman
2025-04-27  9:57     ` David Laight
2025-04-29  8:46       ` Justin Lai

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=20250422125546.GF2843373@horms.kernel.org \
    --to=horms@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=justinlai0215@realtek.com \
    --cc=kuba@kernel.org \
    --cc=larry.chiu@realtek.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lkp@intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=pkshih@realtek.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).