From patchwork Thu Jul 14 14:07:50 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 9229911 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 BE14F6075D for ; Thu, 14 Jul 2016 14:19:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AEF2B25D99 for ; Thu, 14 Jul 2016 14:19:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A386727FBE; Thu, 14 Jul 2016 14:19:25 +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 D0A5725D99 for ; Thu, 14 Jul 2016 14:19:24 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 2221E266CDA; Thu, 14 Jul 2016 16:19:24 +0200 (CEST) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id EDDE026683D; Thu, 14 Jul 2016 16:08:38 +0200 (CEST) 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 05F5626683B; Thu, 14 Jul 2016 16:08:37 +0200 (CEST) Received: from smtp-proxy003.phy.lolipop.jp (smtp-proxy003.phy.lolipop.jp [157.7.104.44]) by alsa0.perex.cz (Postfix) with ESMTP id 8911E265A1D for ; Thu, 14 Jul 2016 16:08:09 +0200 (CEST) Received: from smtp-proxy003.phy.lolipop.lan (HELO smtp-proxy003.phy.lolipop.jp) (172.19.44.44) (smtp-auth username m12129643-o-takashi, mechanism plain) by smtp-proxy003.phy.lolipop.jp (qpsmtpd/0.82) with ESMTPA; Thu, 14 Jul 2016 23:08:06 +0900 Received: from 127.0.0.1 (127.0.0.1) by smtp-proxy003.phy.lolipop.jp (LOLIPOP-Fsecure); Thu, 14 Jul 2016 23:07:52 +0900 (JST) X-Virus-Status: clean(LOLIPOP-Fsecure) From: Takashi Sakamoto To: tiwai@suse.de Date: Thu, 14 Jul 2016 23:07:50 +0900 Message-Id: <1468505271-5769-34-git-send-email-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1468505271-5769-1-git-send-email-o-takashi@sakamocchi.jp> References: <1468505271-5769-1-git-send-email-o-takashi@sakamocchi.jp> Cc: alsa-devel@alsa-project.org Subject: [alsa-devel] [PATCH 33/34] alisp: remove alloca() from FA_hctl_elem_write() 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 Both of alloca() and automatic variables keeps storages on stack, while the former generates more instructions than the latter. It's better to use the latter if the size of storage is computable at pre-compile or compile time; i.e. just for structures. This commit obsolete usages of alloca() with automatic variables. Signed-off-by: Takashi Sakamoto --- src/alisp/alisp_snd.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/src/alisp/alisp_snd.c b/src/alisp/alisp_snd.c index 6d5018a..72c6ab0 100644 --- a/src/alisp/alisp_snd.c +++ b/src/alisp/alisp_snd.c @@ -684,8 +684,8 @@ static struct alisp_object * FA_hctl_elem_write(struct alisp_instance * instance { snd_hctl_elem_t *handle; struct alisp_object * p1 = NULL, * obj; - snd_ctl_elem_info_t *info; - snd_ctl_elem_value_t *value; + snd_ctl_elem_info_t info = {0}; + snd_ctl_elem_value_t value = {0}; snd_ctl_elem_type_t type; unsigned int idx, count; int err; @@ -700,15 +700,13 @@ static struct alisp_object * FA_hctl_elem_write(struct alisp_instance * instance delete_tree(instance, p1); return &alsa_lisp_nil; } - snd_ctl_elem_info_alloca(&info); - snd_ctl_elem_value_alloca(&value); - err = snd_hctl_elem_info(handle, info); + err = snd_hctl_elem_info(handle, &info); if (err < 0) { delete_tree(instance, p1); return new_integer(instance, err); } - type = snd_ctl_elem_info_get_type(info); - count = snd_ctl_elem_info_get_count(info); + type = snd_ctl_elem_info_get_type(&info); + count = snd_ctl_elem_info_get_count(&info); if (type == SND_CTL_ELEM_TYPE_IEC958) { count = sizeof(snd_aes_iec958_t); type = SND_CTL_ELEM_TYPE_BYTES; @@ -722,19 +720,19 @@ static struct alisp_object * FA_hctl_elem_write(struct alisp_instance * instance obj = car(p1); switch (type) { case SND_CTL_ELEM_TYPE_BOOLEAN: - snd_ctl_elem_value_set_boolean(value, idx, get_integer(obj)); + snd_ctl_elem_value_set_boolean(&value, idx, get_integer(obj)); break; case SND_CTL_ELEM_TYPE_INTEGER: - snd_ctl_elem_value_set_integer(value, idx, get_integer(obj)); + snd_ctl_elem_value_set_integer(&value, idx, get_integer(obj)); break; case SND_CTL_ELEM_TYPE_INTEGER64: - snd_ctl_elem_value_set_integer64(value, idx, get_integer(obj)); + snd_ctl_elem_value_set_integer64(&value, idx, get_integer(obj)); break; case SND_CTL_ELEM_TYPE_ENUMERATED: - snd_ctl_elem_value_set_enumerated(value, idx, get_integer(obj)); + snd_ctl_elem_value_set_enumerated(&value, idx, get_integer(obj)); break; case SND_CTL_ELEM_TYPE_BYTES: - snd_ctl_elem_value_set_byte(value, idx, get_integer(obj)); + snd_ctl_elem_value_set_byte(&value, idx, get_integer(obj)); break; default: break; @@ -743,7 +741,7 @@ static struct alisp_object * FA_hctl_elem_write(struct alisp_instance * instance p1 = cdr(obj = p1); delete_object(instance, obj); } while (p1 != &alsa_lisp_nil); - err = snd_hctl_elem_write(handle, value); + err = snd_hctl_elem_write(handle, &value); return new_integer(instance, err); }