Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 42AF6C5AE59 for ; Tue, 10 Sep 2019 14:47:04 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4374120872 for ; Tue, 10 Sep 2019 14:47:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="D9znGxAu" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4374120872 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 237E51693; Tue, 10 Sep 2019 16:46:11 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 237E51693 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1568126821; bh=AAhr7f4evPBnIXSjavU6uHwkeobxTK8ab+AtjwjAacU=; h=Date:From:To:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=D9znGxAuGcbQZCE6V3jkQnmmj3SPIxEEeiyXcgib0myiKATUcaDwTDtxPPPxzxi1M Jq5EjKQBQYddkuKDC+hjm+xKCshM5Tu2WddKxwpwIMnJ5MhhNmcEU4vlX93OoA4Rw/ Z7H00ER1ye0NNWjNFs/bfgQlOJ2zdkZ+RgtdTMiw= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id A6389F80321; Tue, 10 Sep 2019 16:46:10 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id F37F8F80368; Tue, 10 Sep 2019 16:46:08 +0200 (CEST) Received: from mx1.suse.de (mx2.suse.de [195.135.220.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id EF494F800E9 for ; Tue, 10 Sep 2019 16:46:05 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz EF494F800E9 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 93529AC2C; Tue, 10 Sep 2019 14:46:04 +0000 (UTC) Date: Tue, 10 Sep 2019 16:46:04 +0200 Message-ID: From: Takashi Iwai To: Peter Ujfalusi In-Reply-To: References: <20190906055524.7393-1-peter.ujfalusi@ti.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 Emacs/25.3 (x86_64-suse-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Cc: alsa-devel@alsa-project.org, broonie@kernel.org, lgirdwood@gmail.com, arthur.she@linaro.org Subject: Re: [alsa-devel] [PATCH] ASoC: dmaengine: Make the pcm->name equal to pcm->id if the name is not set X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" On Tue, 10 Sep 2019 16:23:59 +0200, Peter Ujfalusi wrote: > > > > On 10/09/2019 15.07, Takashi Iwai wrote: > > On Fri, 06 Sep 2019 07:55:24 +0200, > > Peter Ujfalusi wrote: > >> > >> Some tools use the snd_pcm_info_get_name() to try to identify PCMs or for > >> other purposes. > >> > >> Currently it is left empty with the dmaengine-pcm, in this case copy the > >> pcm->id string as pcm->name. > >> > >> For example IGT is using this to find the HDMI PCM for testing audio on it. > >> > >> Signed-off-by: Peter Ujfalusi > >> Reported-by: Arthur She > >> --- > >> Hi, > >> > >> this was actually reported for 4.14 kernel with omap-pcm (replaced by sdma-pcm > >> in v4.18), since then we only use the generic dmaengine PCM but the same issue > >> applies today. > >> > >> Regards, > >> Peter > >> > >> sound/soc/soc-generic-dmaengine-pcm.c | 6 ++++++ > >> 1 file changed, 6 insertions(+) > >> > >> diff --git a/sound/soc/soc-generic-dmaengine-pcm.c b/sound/soc/soc-generic-dmaengine-pcm.c > >> index 748f5f641002..d93db2c2b527 100644 > >> --- a/sound/soc/soc-generic-dmaengine-pcm.c > >> +++ b/sound/soc/soc-generic-dmaengine-pcm.c > >> @@ -306,6 +306,12 @@ static int dmaengine_pcm_new(struct snd_soc_pcm_runtime *rtd) > >> > >> if (!dmaengine_pcm_can_report_residue(dev, pcm->chan[i])) > >> pcm->flags |= SND_DMAENGINE_PCM_FLAG_NO_RESIDUE; > >> + > >> + if (rtd->pcm->streams[i].pcm->name[0] == '\0') { > >> + strncpy(rtd->pcm->streams[i].pcm->name, > >> + rtd->pcm->streams[i].pcm->id, > >> + sizeof(rtd->pcm->streams[i].pcm->name)); > >> + } > > > > Any reason to use strncpy() instead of strscpy()? > > After merging Mark's branch, I got a compile warning like: > > sound/soc/soc-generic-dmaengine-pcm.c:311:4: warning: 'strncpy' > > accessing 80 bytes at offsets 88 and 24 may overlap up to 0 bytes at > > offset [9223372036854775807, -9223372036854775808] [-Wrestrict] > > I have not seen such a warning. > 'may overlap up to 0 bytes' ? > snd_pcm_info { > ... > unsigned char id[64]; /* ID (user selectable) */ > unsigned char name[80]; /* name of this device */ > unsigned char subname[32]; /* subdevice name */ > ... > }; > > and strncpy() supposed to be something like this: > char * strncpy(char *dest, const char *src, size_t n) > { > size_t i; > > for (i = 0; i < n && src[i] != '\0'; i++) > dest[i] = src[i]; > for ( ; i < n; i++) > dest[i] = '\0'; > > return dest; > } > > I can see if I can get my compilers to show the warning and try > strscpy() if it helps on it. strncpy() doesn't guarantee the string termination if you pass the exact buffer size. Better to use strscpy() in such a case. thanks, Takashi _______________________________________________ Alsa-devel mailing list Alsa-devel@alsa-project.org https://mailman.alsa-project.org/mailman/listinfo/alsa-devel