Message ID | tencent_7F01F2D14BF724692ECBF5346283DB9BCA05@qq.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | ALSA: kunit: fix build warning in test_card_set_id | expand |
On Mon, 07 Apr 2025 11:21:36 +0200, xiaopeitux@foxmail.com wrote: > > From: Pei Xiao <xiaopei01@kylinos.cn> > > build W=1 warning: > sound/core/sound_kunit.c: In function 'test_card_set_id': > include/linux/printk.h:455:44: warning: '%s' directive argument is null [-Wformat-overflow=] > > Fix -Wformat-overflow warning when card->id could be NULL. > The kunit_info() call with "%s" format specifier may receive a NULL > pointer from card->id. Add a ternary conditional to safely handle > potential NULL values by substituting "(null)" when card->id is NULL. > > Reported-by: kernel test robot <lkp@intel.com> > Closes: https://lore.kernel.org/oe-kbuild-all/202504050922.ZzbkiojG-lkp@intel.com/ > Signed-off-by: Pei Xiao <xiaopei01@kylinos.cn> Thanks, applied now. I added Fixes tag manually (Fixes: 3e39acf56ede ("ALSA: core: Add sound core KUnit test")) But at the next time, please try to put the proper Fixes tag. Takashi
diff --git a/sound/core/sound_kunit.c b/sound/core/sound_kunit.c index 84e337ecbddd..56c463f43592 100644 --- a/sound/core/sound_kunit.c +++ b/sound/core/sound_kunit.c @@ -268,7 +268,7 @@ static void test_card_set_id(struct kunit *test) card->id[0] = '\0'; snd_card_set_id(card, NAME_W_SPACE); - kunit_info(test, "%s", card->id); + kunit_info(test, "%s", card->id ? card->id : "(null)"); KUNIT_EXPECT_STREQ(test, card->id, NAME_W_SPACE_REMOVED); }