All of lore.kernel.org
 help / color / mirror / Atom feed
From: kernel test robot <lkp@intel.com>
To: Gabriele Monaco <gmonaco@redhat.com>
Cc: oe-kbuild-all@lists.linux.dev
Subject: [glemco:staging_rv_tests 10/14] include/kunit/static_stub.h:68:8: warning: argument 2 of 'kunit_hooks.get_static_stub_address' might be a candidate for a format attribute
Date: Tue, 12 May 2026 20:03:26 +0800	[thread overview]
Message-ID: <202605122042.SNwJW47p-lkp@intel.com> (raw)

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/gmonaco/linux.git staging_rv_tests
head:   2c56034debf1af6ff1539eaf2f3eb6eaf7316944
commit: 226b3ca43ff52df1f35062cc290735bd59cea1cd [10/14] rv: Add KUnit stub to rv_react() and rv_*_task_monitor_slot()
config: parisc-randconfig-002-20260512 (https://download.01.org/0day-ci/archive/20260512/202605122042.SNwJW47p-lkp@intel.com/config)
compiler: hppa-linux-gcc (GCC) 9.5.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260512/202605122042.SNwJW47p-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/202605122042.SNwJW47p-lkp@intel.com/

All warnings (new ones prefixed by >>):

   In file included from kernel/trace/rv/rv_reactors.c:66:
   kernel/trace/rv/rv_reactors.c: In function 'rv_react':
>> include/kunit/static_stub.h:68:8: warning: argument 2 of 'kunit_hooks.get_static_stub_address' might be a candidate for a format attribute [-Wsuggest-attribute=format]
      68 |        &real_fn_name); \
   kernel/trace/rv/rv_reactors.c:472:2: note: in expansion of macro 'KUNIT_STATIC_STUB_REDIRECT'
     472 |  KUNIT_STATIC_STUB_REDIRECT(rv_react, monitor, msg);
         |  ^~~~~~~~~~~~~~~~~~~~~~~~~~


vim +68 include/kunit/static_stub.h

e047c5eaa763245 David Gow  2023-01-31  23  
e047c5eaa763245 David Gow  2023-01-31  24  
e047c5eaa763245 David Gow  2023-01-31  25  /**
e047c5eaa763245 David Gow  2023-01-31  26   * KUNIT_STATIC_STUB_REDIRECT() - call a replacement 'static stub' if one exists
e047c5eaa763245 David Gow  2023-01-31  27   * @real_fn_name: The name of this function (as an identifier, not a string)
e047c5eaa763245 David Gow  2023-01-31  28   * @args: All of the arguments passed to this function
e047c5eaa763245 David Gow  2023-01-31  29   *
e047c5eaa763245 David Gow  2023-01-31  30   * This is a function prologue which is used to allow calls to the current
e047c5eaa763245 David Gow  2023-01-31  31   * function to be redirected by a KUnit test. KUnit tests can call
e047c5eaa763245 David Gow  2023-01-31  32   * kunit_activate_static_stub() to pass a replacement function in. The
582eb3aeed2d06b Kemeng Shi 2023-07-26  33   * replacement function will be called by KUNIT_STATIC_STUB_REDIRECT(), which
e047c5eaa763245 David Gow  2023-01-31  34   * will then return from the function. If the caller is not in a KUnit context,
e047c5eaa763245 David Gow  2023-01-31  35   * the function will continue execution as normal.
e047c5eaa763245 David Gow  2023-01-31  36   *
e047c5eaa763245 David Gow  2023-01-31  37   * Example:
e047c5eaa763245 David Gow  2023-01-31  38   *
e047c5eaa763245 David Gow  2023-01-31  39   * .. code-block:: c
e047c5eaa763245 David Gow  2023-01-31  40   *
e047c5eaa763245 David Gow  2023-01-31  41   *	int real_func(int n)
e047c5eaa763245 David Gow  2023-01-31  42   *	{
e047c5eaa763245 David Gow  2023-01-31  43   *		KUNIT_STATIC_STUB_REDIRECT(real_func, n);
e047c5eaa763245 David Gow  2023-01-31  44   *		return 0;
e047c5eaa763245 David Gow  2023-01-31  45   *	}
e047c5eaa763245 David Gow  2023-01-31  46   *
e047c5eaa763245 David Gow  2023-01-31  47   *	int replacement_func(int n)
e047c5eaa763245 David Gow  2023-01-31  48   *	{
e047c5eaa763245 David Gow  2023-01-31  49   *		return 42;
e047c5eaa763245 David Gow  2023-01-31  50   *	}
e047c5eaa763245 David Gow  2023-01-31  51   *
e047c5eaa763245 David Gow  2023-01-31  52   *	void example_test(struct kunit *test)
e047c5eaa763245 David Gow  2023-01-31  53   *	{
e047c5eaa763245 David Gow  2023-01-31  54   *		kunit_activate_static_stub(test, real_func, replacement_func);
e047c5eaa763245 David Gow  2023-01-31  55   *		KUNIT_EXPECT_EQ(test, real_func(1), 42);
e047c5eaa763245 David Gow  2023-01-31  56   *	}
e047c5eaa763245 David Gow  2023-01-31  57   *
e047c5eaa763245 David Gow  2023-01-31  58   */
e047c5eaa763245 David Gow  2023-01-31  59  #define KUNIT_STATIC_STUB_REDIRECT(real_fn_name, args...)		\
e047c5eaa763245 David Gow  2023-01-31  60  do {									\
e047c5eaa763245 David Gow  2023-01-31  61  	typeof(&real_fn_name) replacement;				\
e047c5eaa763245 David Gow  2023-01-31  62  	struct kunit *current_test = kunit_get_current_test();		\
e047c5eaa763245 David Gow  2023-01-31  63  									\
e047c5eaa763245 David Gow  2023-01-31  64  	if (likely(!current_test))					\
e047c5eaa763245 David Gow  2023-01-31  65  		break;							\
e047c5eaa763245 David Gow  2023-01-31  66  									\
e047c5eaa763245 David Gow  2023-01-31  67  	replacement = kunit_hooks.get_static_stub_address(current_test,	\
e047c5eaa763245 David Gow  2023-01-31 @68  							&real_fn_name);	\
e047c5eaa763245 David Gow  2023-01-31  69  									\
e047c5eaa763245 David Gow  2023-01-31  70  	if (unlikely(replacement))					\
e047c5eaa763245 David Gow  2023-01-31  71  		return replacement(args);				\
e047c5eaa763245 David Gow  2023-01-31  72  } while (0)
e047c5eaa763245 David Gow  2023-01-31  73  

:::::: The code at line 68 was first introduced by commit
:::::: e047c5eaa76324575e1f95664be4c74ce0e2571b kunit: Expose 'static stub' API to redirect functions

:::::: TO: David Gow <davidgow@google.com>
:::::: CC: Shuah Khan <skhan@linuxfoundation.org>

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

                 reply	other threads:[~2026-05-12 12:04 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=202605122042.SNwJW47p-lkp@intel.com \
    --to=lkp@intel.com \
    --cc=gmonaco@redhat.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.