From: kernel test robot <lkp@intel.com>
To: Jaroslav Kysela <perex@perex.cz>
Cc: oe-kbuild-all@lists.linux.dev, alsa-devel@alsa-project.org,
Takashi Iwai <tiwai@suse.de>
Subject: [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
Date: Fri, 5 Jul 2024 06:12:03 +0800 [thread overview]
Message-ID: <202407050501.o5Z3bibi-lkp@intel.com> (raw)
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
reply other threads:[~2024-07-04 22:13 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=202407050501.o5Z3bibi-lkp@intel.com \
--to=lkp@intel.com \
--cc=alsa-devel@alsa-project.org \
--cc=oe-kbuild-all@lists.linux.dev \
--cc=perex@perex.cz \
--cc=tiwai@suse.de \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox