From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: Jani Nikula <jani.nikula@intel.com>
Cc: dri-devel@lists.freedesktop.org, imx@lists.linux.dev,
nouveau@lists.freedesktop.org, amd-gfx@lists.freedesktop.org,
Philipp Zabel <p.zabel@pengutronix.de>,
Shawn Guo <shawnguo@kernel.org>,
Sascha Hauer <s.hauer@pengutronix.de>,
Pengutronix Kernel Team <kernel@pengutronix.de>,
Fabio Estevam <festevam@gmail.com>
Subject: Re: [PATCH 3/4] drm/imx: fix -Wformat-truncation warning in imx_ldb_probe()
Date: Thu, 23 May 2024 20:32:11 +0300 [thread overview]
Message-ID: <Zk99m4i82XnQPeKQ@intel.com> (raw)
In-Reply-To: <c257c4174743f35bafee8492ec60e1d2734450cf.1716479340.git.jani.nikula@intel.com>
On Thu, May 23, 2024 at 06:51:08PM +0300, Jani Nikula wrote:
> Enabling -Wformat-truncation yields the following warning:
>
> ../drivers/gpu/drm/imx/ipuv3/imx-ldb.c: In function ‘imx_ldb_probe’:
> ../drivers/gpu/drm/imx/ipuv3/imx-ldb.c:658:57: error: ‘_sel’ directive output may be truncated writing 4 bytes into a region of size between 3 and 13 [-Werror=format-truncation=]
> 658 | snprintf(clkname, sizeof(clkname), "di%d_sel", i);
> | ^~~~
> ../drivers/gpu/drm/imx/ipuv3/imx-ldb.c:658:17: note: ‘snprintf’ output between 8 and 18 bytes into a destination of size 16
> 658 | snprintf(clkname, sizeof(clkname), "di%d_sel", i);
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If only the compiler could count to three...
>
> Silence the warning by checking the snprintf() return value.
>
> Signed-off-by: Jani Nikula <jani.nikula@intel.com>
>
> ---
>
> Cc: Philipp Zabel <p.zabel@pengutronix.de>
> Cc: Shawn Guo <shawnguo@kernel.org>
> Cc: Sascha Hauer <s.hauer@pengutronix.de>
> Cc: Pengutronix Kernel Team <kernel@pengutronix.de>
> Cc: Fabio Estevam <festevam@gmail.com>
> Cc: dri-devel@lists.freedesktop.org
> Cc: imx@lists.linux.dev
> ---
> drivers/gpu/drm/imx/ipuv3/imx-ldb.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/imx/ipuv3/imx-ldb.c b/drivers/gpu/drm/imx/ipuv3/imx-ldb.c
> index 71d70194fcbd..46f779fe60ee 100644
> --- a/drivers/gpu/drm/imx/ipuv3/imx-ldb.c
> +++ b/drivers/gpu/drm/imx/ipuv3/imx-ldb.c
> @@ -654,8 +654,12 @@ static int imx_ldb_probe(struct platform_device *pdev)
> */
> for (i = 0; i < 4; i++) {
> char clkname[16];
> + int len;
> +
> + len = snprintf(clkname, sizeof(clkname), "di%d_sel", i);
> + if (len >= sizeof(clkname))
> + dev_err(dev, "clkname truncated\n");
>
> - snprintf(clkname, sizeof(clkname), "di%d_sel", i);
> imx_ldb->clk_sel[i] = devm_clk_get(imx_ldb->dev, clkname);
> if (IS_ERR(imx_ldb->clk_sel[i])) {
> ret = PTR_ERR(imx_ldb->clk_sel[i]);
> --
> 2.39.2
--
Ville Syrjälä
Intel
next prev parent reply other threads:[~2024-05-23 17:32 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-23 15:51 [PATCH 0/4] drm: enable -Wformat-truncation Jani Nikula
2024-05-23 15:51 ` [PATCH 1/4] drm/amdgpu: fix -Wformat-truncation warning in amdgpu_gfx_kiq_init_ring() Jani Nikula
2024-05-23 18:07 ` Alex Deucher
2024-05-24 9:07 ` Jani Nikula
2024-05-23 15:51 ` [PATCH 2/4] drm/nouveau: fix -Wformat-truncation warning in nouveau_backlight_init() Jani Nikula
2024-05-23 15:51 ` [PATCH 3/4] drm/imx: fix -Wformat-truncation warning in imx_ldb_probe() Jani Nikula
2024-05-23 17:32 ` Ville Syrjälä [this message]
2024-05-24 9:04 ` Jani Nikula
2024-05-23 15:51 ` [PATCH 4/4] drm: enable -Wformat-truncation across the subsystem Jani Nikula
2024-05-23 18:41 ` Sam Ravnborg
2024-05-24 9:08 ` Jani Nikula
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=Zk99m4i82XnQPeKQ@intel.com \
--to=ville.syrjala@linux.intel.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=festevam@gmail.com \
--cc=imx@lists.linux.dev \
--cc=jani.nikula@intel.com \
--cc=kernel@pengutronix.de \
--cc=nouveau@lists.freedesktop.org \
--cc=p.zabel@pengutronix.de \
--cc=s.hauer@pengutronix.de \
--cc=shawnguo@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