All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Laight <david.laight.linux@gmail.com>
To: Guenter Roeck <linux@roeck-us.net>
Cc: kernel test robot <lkp@intel.com>,
	Eddie James <eajames@linux.ibm.com>,
	oe-kbuild-all@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: drivers/hwmon/pmbus/ibm-cffps.c:184:60: warning: '%04X' directive output may be truncated writing between 4 and 8 bytes into a region of size 5
Date: Fri, 20 Dec 2024 16:30:56 +0000	[thread overview]
Message-ID: <20241220163056.7bad4962@dsl-u17-10> (raw)
In-Reply-To: <b8b9dc2c-cb70-41c5-8606-eb3aa6cdc257@roeck-us.net>

On Fri, 20 Dec 2024 07:21:18 -0800
Guenter Roeck <linux@roeck-us.net> wrote:

> On 12/20/24 05:54, kernel test robot wrote:
> > Hi Eddie,
> > 
> > FYI, the error/warning still remains.
> > 
> > tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> > head:   8faabc041a001140564f718dabe37753e88b37fa
> > commit: 2f8a855efe8a6faf962c53af406e5ea4791b3877 pmbus: (ibm-cffps) Add support for version 2 of the PSU
> > date:   5 years ago
> > config: x86_64-randconfig-077-20241209 (https://download.01.org/0day-ci/archive/20241220/202412202139.tZ2VJL2f-lkp@intel.com/config)
> > compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
> > reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241220/202412202139.tZ2VJL2f-lkp@intel.com/reproduce)
> > 
> > If you fix the issue in a separate patch/commit (i.e. not just a new version of
> > the same patch/commit), kindly add following tags
> > | Reported-by: kernel test robot <lkp@intel.com>
> > | Closes: https://lore.kernel.org/oe-kbuild-all/202412202139.tZ2VJL2f-lkp@intel.com/
> >   
> 
> We could use %2. 2X and %4.4X to make the compiler happy, but those are false positives.
> rc is known in all cases to not exceed the format size. I don't see the point of changing
> the code just to make the compiler happy.

I doubt they'd make any difference.

>
> >     drivers/hwmon/pmbus/ibm-cffps.c:171:60: warning: '%02X' directive output may be truncated writing between 2 and 8 bytes into a region of size 3 [-Wformat-truncation=]
> >       171 |                                 snprintf(&data[i * 2], 3, "%02X", rc);

The only ways I know are to bound check the value or to use
OPTIMISER_HIDE_VAR() on the length.

	David

  reply	other threads:[~2024-12-20 16:30 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-20 13:54 drivers/hwmon/pmbus/ibm-cffps.c:184:60: warning: '%04X' directive output may be truncated writing between 4 and 8 bytes into a region of size 5 kernel test robot
2024-12-20 15:21 ` Guenter Roeck
2024-12-20 16:30   ` David Laight [this message]
2024-12-20 17:03     ` Guenter Roeck
2024-12-20 17:29       ` David Laight
2024-12-20 17:56         ` Guenter Roeck
  -- strict thread matches above, loose matches on Subject: below --
2024-01-25  3:52 kernel test robot
2023-12-25 21:18 kernel test robot

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=20241220163056.7bad4962@dsl-u17-10 \
    --to=david.laight.linux@gmail.com \
    --cc=eajames@linux.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=lkp@intel.com \
    --cc=oe-kbuild-all@lists.linux.dev \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.