From patchwork Tue Feb 21 22:54:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 9585847 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C1A6C600CA for ; Tue, 21 Feb 2017 22:55:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A6DDB28609 for ; Tue, 21 Feb 2017 22:55:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 99A2C28637; Tue, 21 Feb 2017 22:55:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C8E6328610 for ; Tue, 21 Feb 2017 22:55:00 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id DF4C2266DC7; Tue, 21 Feb 2017 23:54:58 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 197C7266DCA; Tue, 21 Feb 2017 23:54:58 +0100 (CET) Received: from smtp-proxy001.phy.lolipop.jp (smtp-proxy001.phy.lolipop.jp [157.7.104.42]) by alsa0.perex.cz (Postfix) with ESMTP id 362FD266AA9 for ; Tue, 21 Feb 2017 23:54:52 +0100 (CET) Received: from smtp-proxy001.phy.lolipop.lan (HELO smtp-proxy001.phy.lolipop.jp) (172.19.44.42) (smtp-auth username m12129643-o-takashi, mechanism plain) by smtp-proxy001.phy.lolipop.jp (qpsmtpd/0.82) with ESMTPA; Wed, 22 Feb 2017 07:54:49 +0900 Received: from 127.0.0.1 (127.0.0.1) by smtp-proxy001.phy.lolipop.jp (LOLIPOP-Fsecure); Wed, 22 Feb 2017 07:54:47 +0900 (JST) X-Virus-Status: clean(LOLIPOP-Fsecure) From: Takashi Sakamoto To: onkel@paraair.de, tiwai@suse.de Date: Wed, 22 Feb 2017 07:54:47 +0900 Message-Id: <20170221225447.1224-1-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.9.3 Cc: alsa-devel@alsa-project.org Subject: [alsa-devel] [PATCH v2] ALSA: usb-audio: purge needless variable length array X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 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: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP Variable length array is used in 'snd_us16x08_meter_get()', while there is no need. It's better to purge it because variable length array has overhead for stack handling. This commit replaces the array with static length. Sparse generated below warning. sound/usb/mixer_us16x08.c:714:18: warning: Variable length array is used. Fixes: d2bb390a2081 ("ALSA: usb-audio: Tascam US-16x08 DSP mixer quirk") Signed-off-by: Takashi Sakamoto --- sound/usb/mixer_us16x08.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sound/usb/mixer_us16x08.c b/sound/usb/mixer_us16x08.c index 7ac45ec..73a0b9a 100644 --- a/sound/usb/mixer_us16x08.c +++ b/sound/usb/mixer_us16x08.c @@ -711,7 +711,7 @@ static int snd_us16x08_meter_get(struct snd_kcontrol *kcontrol, struct snd_usb_audio *chip = elem->head.mixer->chip; struct snd_us16x08_meter_store *store = elem->private_data; u8 meter_urb[64]; - char tmp[max(sizeof(mix_init_msg1), sizeof(mix_init_msg2))]; + char tmp[sizeof(mix_init_msg2)] = {0}; if (elem) { store = (struct snd_us16x08_meter_store *) elem->private_data; @@ -721,8 +721,8 @@ static int snd_us16x08_meter_get(struct snd_kcontrol *kcontrol, switch (kcontrol->private_value) { case 0: - memcpy(tmp, mix_init_msg1, sizeof(mix_init_msg1)); - snd_us16x08_send_urb(chip, tmp, 4); + snd_us16x08_send_urb(chip, (char *)mix_init_msg1, + sizeof(mix_init_msg1)); snd_us16x08_recv_urb(chip, meter_urb, sizeof(meter_urb)); kcontrol->private_value++; @@ -740,7 +740,7 @@ static int snd_us16x08_meter_get(struct snd_kcontrol *kcontrol, case 3: memcpy(tmp, mix_init_msg2, sizeof(mix_init_msg2)); tmp[2] = snd_get_meter_comp_index(store); - snd_us16x08_send_urb(chip, tmp, 10); + snd_us16x08_send_urb(chip, tmp, sizeof(mix_init_msg2)); snd_us16x08_recv_urb(chip, meter_urb, sizeof(meter_urb)); kcontrol->private_value = 0;