]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
media: qcom: camss: avoid format string warning
authorArnd Bergmann <arnd@arndb.de>
Fri, 20 Mar 2026 15:18:24 +0000 (16:18 +0100)
committerHans Verkuil <hverkuil+cisco@kernel.org>
Mon, 27 Apr 2026 06:41:22 +0000 (08:41 +0200)
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.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Bryan O'Donoghue <bod@kernel.org>
Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
drivers/media/platform/qcom/camss/camss-csiphy.c

index 62623393f414494d7d0095aa0efe5673382ec962..78a1b568dbae6a9303ac88fad6c31ecba31b5c9f 100644 (file)
@@ -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);
 }