public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
From: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
To: Arnd Bergmann <arnd@kernel.org>, Robert Foss <rfoss@kernel.org>,
	Todor Tomov <todor.too@gmail.com>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Nathan Chancellor <nathan@kernel.org>,
	Hans Verkuil <hverkuil@kernel.org>
Cc: Arnd Bergmann <arnd@arndb.de>,
	Vladimir Zapolskiy <vladimir.zapolskiy@linaro.org>,
	Nick Desaulniers <nick.desaulniers+lkml@gmail.com>,
	Bill Wendling <morbo@google.com>,
	Justin Stitt <justinstitt@google.com>,
	Hans Verkuil <hverkuil+cisco@kernel.org>,
	Vincent Knecht <vincent.knecht@mailoo.org>,
	Wenmeng Liu <wenmeng.liu@oss.qualcomm.com>,
	linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org,
	linux-kernel@vger.kernel.org, llvm@lists.linux.dev
Subject: Re: [PATCH] media: qcom: camss: avoid format string warning
Date: Fri, 20 Mar 2026 15:24:35 +0000	[thread overview]
Message-ID: <e5e9cc38-9d8c-4a79-ab4f-8c5ed98f6eee@linaro.org> (raw)
In-Reply-To: <20260320151828.3456863-1-arnd@kernel.org>

On 20/03/2026 15:18, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> clang-22 warns about csiphy_match_clock_name() taking a variable format
> string that is not checked against the 'int index' argument:
> 
> drivers/media/platform/qcom/camss/camss-csiphy.c:566:44: error: diagnostic behavior may be improved by
>        adding the 'format(printf, 2, 3)' attribute to the declaration of 'csiphy_match_clock_name'
>        [-Werror,-Wmissing-format-attribute]
>    561 | static bool csiphy_match_clock_name(const char *clock_name, const char *format,
>        | __attribute__((format(printf, 2, 3)))
>    562 |                                     int index)
>    563 | {
>    564 |         char name[16]; /* csiphyXXX_timer\0 */
>    565 |
>    566 |         snprintf(name, sizeof(name), format, index);
>        |                                                   ^
> drivers/media/platform/qcom/camss/camss-csiphy.c:561:13: note: 'csiphy_match_clock_name' declared here
>    561 | static bool csiphy_match_clock_name(const char *clock_name, const char *format,
>        |             ^
> 
> Change the function to use a snprintf() style format string that allows this
> to be checked at the call site.
> 
> Fixes: 0727615fb975 ("media: qcom: camss: Functionally decompose CSIPHY clock lookups")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>   drivers/media/platform/qcom/camss/camss-csiphy.c | 10 +++++++---
>   1 file changed, 7 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/media/platform/qcom/camss/camss-csiphy.c b/drivers/media/platform/qcom/camss/camss-csiphy.c
> index 62623393f414..78a1b568dbae 100644
> --- a/drivers/media/platform/qcom/camss/camss-csiphy.c
> +++ b/drivers/media/platform/qcom/camss/camss-csiphy.c
> @@ -558,12 +558,16 @@ static int csiphy_init_formats(struct v4l2_subdev *sd,
>   	return csiphy_set_format(sd, fh ? fh->state : NULL, &format);
>   }
>   
> -static bool csiphy_match_clock_name(const char *clock_name, const char *format,
> -				    int index)
> +static bool __printf(2, 3)
> +csiphy_match_clock_name(const char *clock_name, const char *format, ...)
>   {
>   	char name[16]; /* csiphyXXX_timer\0 */
> +	va_list args;
> +
> +	va_start(args, format);
> +	vsnprintf(name, sizeof(name), format, args);
> +	va_end(args);
>   
> -	snprintf(name, sizeof(name), format, index);
>   	return !strcmp(clock_name, name);
>   }
>   
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>

      reply	other threads:[~2026-03-20 15:24 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-20 15:18 [PATCH] media: qcom: camss: avoid format string warning Arnd Bergmann
2026-03-20 15:24 ` Bryan O'Donoghue [this message]

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=e5e9cc38-9d8c-4a79-ab4f-8c5ed98f6eee@linaro.org \
    --to=bryan.odonoghue@linaro.org \
    --cc=arnd@arndb.de \
    --cc=arnd@kernel.org \
    --cc=hverkuil+cisco@kernel.org \
    --cc=hverkuil@kernel.org \
    --cc=justinstitt@google.com \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=mchehab@kernel.org \
    --cc=morbo@google.com \
    --cc=nathan@kernel.org \
    --cc=nick.desaulniers+lkml@gmail.com \
    --cc=rfoss@kernel.org \
    --cc=todor.too@gmail.com \
    --cc=vincent.knecht@mailoo.org \
    --cc=vladimir.zapolskiy@linaro.org \
    --cc=wenmeng.liu@oss.qualcomm.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