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=-6.8 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 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 C81AEC432C0 for ; Wed, 20 Nov 2019 06:27:01 +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 B573F2245D for ; Wed, 20 Nov 2019 06:27:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="MQsGlA5F" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B573F2245D 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 94AA81669; Wed, 20 Nov 2019 07:26:08 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 94AA81669 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1574231218; bh=JGbk5GyT7gBvVAceRQI+dQRmh+p4dKWt0YZ3QSRSf3U=; h=Date:From:To:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=MQsGlA5FGc6jpctq4tGIUg3N7H7f6k196OeNS6Ktu1mMSiytZ9iwAZsxam4kUClRH U9iLeppoO64CNN0PkCGYHjfOy9tOKQHp31sTSWhXUJTArCbyfym5mIcBcYH21SJEKd +V6zyktqm6f4naW9t2yr4aIkEkbfjVJL04184tKk= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 19857F8013C; Wed, 20 Nov 2019 07:26:08 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 29667F8013D; Wed, 20 Nov 2019 07:26:07 +0100 (CET) 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 8BF12F800FF for ; Wed, 20 Nov 2019 07:26:03 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 8BF12F800FF 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 C0039B160; Wed, 20 Nov 2019 06:26:02 +0000 (UTC) Date: Wed, 20 Nov 2019 07:26:02 +0100 Message-ID: From: Takashi Iwai To: Rosen Penev In-Reply-To: <20191120042856.415854-4-rosenp@gmail.com> References: <20191120042856.415854-1-rosenp@gmail.com> <20191120042856.415854-4-rosenp@gmail.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 Subject: Re: [alsa-devel] [PATCH 4/4] aplay: Limit VUMeter progress bar to 100 for negative as well 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 Wed, 20 Nov 2019 05:28:56 +0100, Rosen Penev wrote: > > If the progress bar somehow becomes negative, it ends up overwritting > tmp. Fixes this GCC warning: > > aplay.c:1747:18: warning: '%02d' directive writing between 2 and 11 bytes > into a region of size 4 [-Wformat-overflow=] > 1747 | sprintf(tmp, "%02d%%", maxperc[c]); This is false-positive. The value passed there is guaranteed to be a positive integer at the calculation time. thanks, Takashi > > Signed-off-by: Rosen Penev > --- > aplay/aplay.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/aplay/aplay.c b/aplay/aplay.c > index 72fa567..9c5a11b 100644 > --- a/aplay/aplay.c > +++ b/aplay/aplay.c > @@ -54,6 +54,8 @@ > #include "formats.h" > #include "version.h" > > +#define ABS(a) (a) < 0 ? -(a) : (a) > + > #ifdef SND_CHMAP_API_VERSION > #define CONFIG_SUPPORT_CHMAP 1 > #endif > @@ -1741,7 +1743,7 @@ static void print_vu_meter_stereo(int *perc, int *maxperc) > line[bar_length + 6 + 1 + p] = '+'; > else > line[bar_length - p - 1] = '+'; > - if (maxperc[c] > 99) > + if (ABS(maxperc[c]) > 99) > sprintf(tmp, "MAX"); > else > sprintf(tmp, "%02d%%", maxperc[c]); > -- > 2.23.0 > > _______________________________________________ > Alsa-devel mailing list > Alsa-devel@alsa-project.org > https://mailman.alsa-project.org/mailman/listinfo/alsa-devel > _______________________________________________ Alsa-devel mailing list Alsa-devel@alsa-project.org https://mailman.alsa-project.org/mailman/listinfo/alsa-devel