Alsa-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [tiwai-sound:for-next 5/6] sound/core/pcm_lib.c:547:9: warning: 'strncpy' output truncated before terminating nul copying 12 bytes from a string of the same length
@ 2024-07-04 22:12 kernel test robot
  0 siblings, 0 replies; only message in thread
From: kernel test robot @ 2024-07-04 22:12 UTC (permalink / raw)
  To: Jaroslav Kysela; +Cc: oe-kbuild-all, alsa-devel, Takashi Iwai

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git for-next
head:   5f9f982dd71b418aeba7a0b37f87312545c06df4
commit: d712c58c55d9a4b4cc88ec2e1f8cd2e3b82359b5 [5/6] ALSA: pcm: optimize and clarify stream synchronization ID API
config: x86_64-defconfig (https://download.01.org/0day-ci/archive/20240705/202407050501.o5Z3bibi-lkp@intel.com/config)
compiler: gcc-13 (Ubuntu 13.2.0-4ubuntu3) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240705/202407050501.o5Z3bibi-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/202407050501.o5Z3bibi-lkp@intel.com/

All warnings (new ones prefixed by >>):

   In function 'snd_pcm_set_sync_per_card',
       inlined from 'snd_pcm_lib_ioctl_sync_id' at sound/core/pcm_lib.c:1837:3,
       inlined from 'snd_pcm_lib_ioctl' at sound/core/pcm_lib.c:1863:10:
>> sound/core/pcm_lib.c:547:9: warning: 'strncpy' output truncated before terminating nul copying 12 bytes from a string of the same length [-Wstringop-truncation]
     547 |         strncpy(params->sync + 4, id, len);
         |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


vim +/strncpy +547 sound/core/pcm_lib.c

   517	
   518	/**
   519	 * snd_pcm_set_sync_per_card - set the PCM sync id with card number
   520	 * @substream: the pcm substream
   521	 * @params: modified hardware parameters
   522	 * @id: identifier (max 12 bytes)
   523	 * @len: identifier length (max 12 bytes)
   524	 *
   525	 * Sets the PCM sync identifier for the card with zero padding.
   526	 *
   527	 * User space or any user should use this 16-byte identifier for a comparison only
   528	 * to check if two IDs are similar or different. Special case is the identifier
   529	 * containing only zeros. Interpretation for this combination is - empty (not set).
   530	 * The contents of the identifier should not be interpreted in any other way.
   531	 *
   532	 * The synchronization ID must be unique per clock source (usually one sound card,
   533	 * but multiple soundcard may use one PCM word clock source which means that they
   534	 * are fully synchronized).
   535	 *
   536	 * This routine composes this ID using card number in first four bytes and
   537	 * 12-byte additional ID. When other ID composition is used (e.g. for multiple
   538	 * sound cards), make sure that the composition does not clash with this
   539	 * composition scheme.
   540	 */
   541	void snd_pcm_set_sync_per_card(struct snd_pcm_substream *substream,
   542				       struct snd_pcm_hw_params *params,
   543				       const unsigned char *id, unsigned int len)
   544	{
   545		*(__u32 *)params->sync = cpu_to_le32(substream->pcm->card->number);
   546		len = max(12, len);
 > 547		strncpy(params->sync + 4, id, len);
   548		memset(params->sync + 4 + len, 0, 12 - len);
   549	}
   550	

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-07-04 22:13 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-04 22:12 [tiwai-sound:for-next 5/6] sound/core/pcm_lib.c:547:9: warning: 'strncpy' output truncated before terminating nul copying 12 bytes from a string of the same length kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox