[morimoto:sound-cleanup-2026-07-16 311/311] include/linux/fortify-string.h:208:9: error: first argument to '__builtin_choose_expr' not a constant

kernel test robot <[email protected]>
Newsgroups dev.linux.lists.oe-kbuild-all
Message-ID <[email protected]>
tree:   https://github.com/morimoto/linux sound-cleanup-2026-07-16
head:   e51d2e02d8d4c974132f00eec9d2215a476084f0
commit: e5cb44e887fc27a5ca0bcbcc673b11edb01174f8 [311/311] ASoC: soc-component: capsuling Component
config: i386-allmodconfig (https://download.01.org/0day-ci/archive/20260717/[email protected]/config)
compiler: gcc-14 (Debian 14.2.0-19) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260717/[email protected]/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 <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

   In file included from include/trace/define_trace.h:132,
                    from include/trace/events/asoc.h:280,
                    from sound/soc/soc-core.c:43:
   include/trace/events/asoc.h: In function 'trace_event_get_offsets_snd_soc_dapm':
   include/trace/events/asoc.h:31:114: error: invalid use of undefined type 'struct snd_soc_component'
      31 |                 __string(       comp_name,      snd_soc_dapm_to_component(dapm) ? snd_soc_dapm_to_component(dapm)->name : "(none)")
         |                                                                                                                  ^~
   include/trace/trace_events.h:285:9: note: in definition of macro 'DECLARE_EVENT_CLASS'
     285 |         tstruct;                                                        \
         |         ^~~~~~~
   include/trace/events/asoc.h:29:9: note: in expansion of macro 'TP_STRUCT__entry'
      29 |         TP_STRUCT__entry(
         |         ^~~~~~~~~~~~~~~~
   include/trace/stages/stage5_get_offsets.h:59:29: note: in expansion of macro '__dynamic_array'
      59 | #define __string(item, src) __dynamic_array(char, item,                 \
         |                             ^~~~~~~~~~~~~~~
   include/linux/fortify-string.h:208:31: note: in expansion of macro '__is_constexpr'
     208 |         __builtin_choose_expr(__is_constexpr(__builtin_strlen(p)),      \
         |                               ^~~~~~~~~~~~~~
   include/trace/stages/stage5_get_offsets.h:60:21: note: in expansion of macro 'strlen'
      60 |                     strlen(__string_src(src)) + 1)                      \
         |                     ^~~~~~
   include/trace/events/asoc.h:31:17: note: in expansion of macro '__string'
      31 |                 __string(       comp_name,      snd_soc_dapm_to_component(dapm) ? snd_soc_dapm_to_component(dapm)->name : "(none)")
         |                 ^~~~~~~~
   include/trace/events/asoc.h:31:114: error: invalid use of undefined type 'struct snd_soc_component'
      31 |                 __string(       comp_name,      snd_soc_dapm_to_component(dapm) ? snd_soc_dapm_to_component(dapm)->name : "(none)")
         |                                                                                                                  ^~
   include/trace/trace_events.h:285:9: note: in definition of macro 'DECLARE_EVENT_CLASS'
     285 |         tstruct;                                                        \
         |         ^~~~~~~
   include/trace/events/asoc.h:29:9: note: in expansion of macro 'TP_STRUCT__entry'
      29 |         TP_STRUCT__entry(
         |         ^~~~~~~~~~~~~~~~
   include/trace/stages/stage5_get_offsets.h:59:29: note: in expansion of macro '__dynamic_array'
      59 | #define __string(item, src) __dynamic_array(char, item,                 \
         |                             ^~~~~~~~~~~~~~~
   include/trace/stages/stage5_get_offsets.h:60:21: note: in expansion of macro 'strlen'
      60 |                     strlen(__string_src(src)) + 1)                      \
         |                     ^~~~~~
   include/trace/events/asoc.h:31:17: note: in expansion of macro '__string'
      31 |                 __string(       comp_name,      snd_soc_dapm_to_component(dapm) ? snd_soc_dapm_to_component(dapm)->name : "(none)")
         |                 ^~~~~~~~
   include/trace/events/asoc.h:31:114: error: invalid use of undefined type 'struct snd_soc_component'
      31 |                 __string(       comp_name,      snd_soc_dapm_to_component(dapm) ? snd_soc_dapm_to_component(dapm)->name : "(none)")
         |                                                                                                                  ^~
   include/trace/trace_events.h:285:9: note: in definition of macro 'DECLARE_EVENT_CLASS'
     285 |         tstruct;                                                        \
         |         ^~~~~~~
   include/trace/events/asoc.h:29:9: note: in expansion of macro 'TP_STRUCT__entry'
      29 |         TP_STRUCT__entry(
         |         ^~~~~~~~~~~~~~~~
   include/trace/stages/stage5_get_offsets.h:59:29: note: in expansion of macro '__dynamic_array'
      59 | #define __string(item, src) __dynamic_array(char, item,                 \
         |                             ^~~~~~~~~~~~~~~
   include/trace/stages/stage5_get_offsets.h:60:21: note: in expansion of macro 'strlen'
      60 |                     strlen(__string_src(src)) + 1)                      \
         |                     ^~~~~~
   include/trace/events/asoc.h:31:17: note: in expansion of macro '__string'
      31 |                 __string(       comp_name,      snd_soc_dapm_to_component(dapm) ? snd_soc_dapm_to_component(dapm)->name : "(none)")
         |                 ^~~~~~~~
>> include/linux/fortify-string.h:208:9: error: first argument to '__builtin_choose_expr' not a constant
     208 |         __builtin_choose_expr(__is_constexpr(__builtin_strlen(p)),      \
         |         ^~~~~~~~~~~~~~~~~~~~~
   include/trace/trace_events.h:285:9: note: in definition of macro 'DECLARE_EVENT_CLASS'
     285 |         tstruct;                                                        \
         |         ^~~~~~~
   include/trace/events/asoc.h:29:9: note: in expansion of macro 'TP_STRUCT__entry'
      29 |         TP_STRUCT__entry(
         |         ^~~~~~~~~~~~~~~~
   include/trace/stages/stage5_get_offsets.h:59:29: note: in expansion of macro '__dynamic_array'
      59 | #define __string(item, src) __dynamic_array(char, item,                 \
         |                             ^~~~~~~~~~~~~~~
   include/trace/stages/stage5_get_offsets.h:60:21: note: in expansion of macro 'strlen'
      60 |                     strlen(__string_src(src)) + 1)                      \
         |                     ^~~~~~
   include/trace/events/asoc.h:31:17: note: in expansion of macro '__string'
      31 |                 __string(       comp_name,      snd_soc_dapm_to_component(dapm) ? snd_soc_dapm_to_component(dapm)->name : "(none)")
         |                 ^~~~~~~~
   include/trace/events/asoc.h:31:114: error: invalid use of undefined type 'struct snd_soc_component'
      31 |                 __string(       comp_name,      snd_soc_dapm_to_component(dapm) ? snd_soc_dapm_to_component(dapm)->name : "(none)")
         |                                                                                                                  ^~
   include/trace/trace_events.h:285:9: note: in definition of macro 'DECLARE_EVENT_CLASS'
     285 |         tstruct;                                                        \
         |         ^~~~~~~
   include/trace/events/asoc.h:29:9: note: in expansion of macro 'TP_STRUCT__entry'
      29 |         TP_STRUCT__entry(
         |         ^~~~~~~~~~~~~~~~
   include/trace/events/asoc.h:31:17: note: in expansion of macro '__string'
      31 |                 __string(       comp_name,      snd_soc_dapm_to_component(dapm) ? snd_soc_dapm_to_component(dapm)->name : "(none)")
         |                 ^~~~~~~~


vim +/__builtin_choose_expr +208 include/linux/fortify-string.h

369cd2165d7bea Kees Cook      2021-08-04  188  
67ebc3ab446230 Kees Cook      2022-02-08  189  /*
67ebc3ab446230 Kees Cook      2022-02-08  190   * Defined after fortified strnlen to reuse it. However, it must still be
67ebc3ab446230 Kees Cook      2022-02-08  191   * possible for strlen() to be used on compile-time strings for use in
67ebc3ab446230 Kees Cook      2022-02-08  192   * static initializers (i.e. as a constant expression).
67ebc3ab446230 Kees Cook      2022-02-08  193   */
03699f271de1f4 Kees Cook      2022-09-02  194  /**
03699f271de1f4 Kees Cook      2022-09-02  195   * strlen - Return count of characters in a NUL-terminated string
03699f271de1f4 Kees Cook      2022-09-02  196   *
03699f271de1f4 Kees Cook      2022-09-02  197   * @p: pointer to NUL-terminated string to count.
03699f271de1f4 Kees Cook      2022-09-02  198   *
03699f271de1f4 Kees Cook      2022-09-02  199   * Do not use this function unless the string length is known at
03699f271de1f4 Kees Cook      2022-09-02  200   * compile-time. When @p is unterminated, this function may crash
03699f271de1f4 Kees Cook      2022-09-02  201   * or return unexpected counts that could lead to memory content
03699f271de1f4 Kees Cook      2022-09-02  202   * exposures. Prefer strnlen().
03699f271de1f4 Kees Cook      2022-09-02  203   *
03699f271de1f4 Kees Cook      2022-09-02  204   * Returns number of characters in @p (NOT including the final NUL).
03699f271de1f4 Kees Cook      2022-09-02  205   *
03699f271de1f4 Kees Cook      2022-09-02  206   */
67ebc3ab446230 Kees Cook      2022-02-08  207  #define strlen(p)							\
67ebc3ab446230 Kees Cook      2022-02-08 @208  	__builtin_choose_expr(__is_constexpr(__builtin_strlen(p)),	\
67ebc3ab446230 Kees Cook      2022-02-08  209  		__builtin_strlen(p), __fortify_strlen(p))
92df138a8d663c Kees Cook      2022-02-08  210  __FORTIFY_INLINE __diagnose_as(__builtin_strlen, 1)
281d0c962752fb Kees Cook      2022-02-08  211  __kernel_size_t __fortify_strlen(const char * const POS p)
a28a6e860c6cf2 Francis Laniel 2021-02-25  212  {
21a2c74b0a2a78 Kees Cook      2023-04-07  213  	const size_t p_size = __member_size(p);
a28a6e860c6cf2 Francis Laniel 2021-02-25  214  	__kernel_size_t ret;
a28a6e860c6cf2 Francis Laniel 2021-02-25  215  
3009f891bb9f32 Kees Cook      2021-08-02  216  	/* Give up if we don't know how large p is. */
311fb40aa0569a Kees Cook      2022-09-02  217  	if (p_size == SIZE_MAX)
a28a6e860c6cf2 Francis Laniel 2021-02-25  218  		return __underlying_strlen(p);
a28a6e860c6cf2 Francis Laniel 2021-02-25  219  	ret = strnlen(p, p_size);
a28a6e860c6cf2 Francis Laniel 2021-02-25  220  	if (p_size <= ret)
3d965b33e40d97 Kees Cook      2023-04-07  221  		fortify_panic(FORTIFY_FUNC_strlen, FORTIFY_READ, p_size, ret + 1, ret);
a28a6e860c6cf2 Francis Laniel 2021-02-25  222  	return ret;
a28a6e860c6cf2 Francis Laniel 2021-02-25  223  }
a28a6e860c6cf2 Francis Laniel 2021-02-25  224  

:::::: The code at line 208 was first introduced by commit
:::::: 67ebc3ab446230c77fe3b545a9d8a11cac1cfb6e fortify: Make sure strlen() may still be used as a constant expression

:::::: TO: Kees Cook <[email protected]>
:::::: CC: Kees Cook <[email protected]>

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.