From patchwork Thu Jul 14 14:07:49 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 9229913 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 3DD256075D for ; Thu, 14 Jul 2016 14:19:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2D1742808C for ; Thu, 14 Jul 2016 14:19:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 21B1D281A7; Thu, 14 Jul 2016 14:19:52 +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 4264B2808C for ; Thu, 14 Jul 2016 14:19:51 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 855AC266CFF; Thu, 14 Jul 2016 16:19:50 +0200 (CEST) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 60013266846; Thu, 14 Jul 2016 16:08:39 +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 087C5266835; 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 6F6D3265A10 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:49 +0900 Message-Id: <1468505271-5769-33-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 32/34] alisp: remove alloca() from FA_hctl_elem_read() 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 c63806b..6d5018a 100644 --- a/src/alisp/alisp_snd.c +++ b/src/alisp/alisp_snd.c @@ -622,8 +622,8 @@ static struct alisp_object * FA_hctl_elem_read(struct alisp_instance * instance, { snd_hctl_elem_t *handle; struct alisp_object * lexpr, * 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; @@ -634,16 +634,14 @@ static struct alisp_object * FA_hctl_elem_read(struct alisp_instance * instance, handle = (snd_hctl_elem_t *)get_ptr(instance, p1, item->prefix); if (handle == NULL) 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) - err = snd_hctl_elem_read(handle, value); + err = snd_hctl_elem_read(handle, &value); lexpr = new_lexpr(instance, err); if (err < 0) return lexpr; - 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; @@ -651,19 +649,19 @@ static struct alisp_object * FA_hctl_elem_read(struct alisp_instance * instance, for (idx = 0; idx < count; idx++) { switch (type) { case SND_CTL_ELEM_TYPE_BOOLEAN: - obj = new_integer(instance, snd_ctl_elem_value_get_boolean(value, idx)); + obj = new_integer(instance, snd_ctl_elem_value_get_boolean(&value, idx)); break; case SND_CTL_ELEM_TYPE_INTEGER: - obj = new_integer(instance, snd_ctl_elem_value_get_integer(value, idx)); + obj = new_integer(instance, snd_ctl_elem_value_get_integer(&value, idx)); break; case SND_CTL_ELEM_TYPE_INTEGER64: - obj = new_integer(instance, snd_ctl_elem_value_get_integer64(value, idx)); + obj = new_integer(instance, snd_ctl_elem_value_get_integer64(&value, idx)); break; case SND_CTL_ELEM_TYPE_ENUMERATED: - obj = new_integer(instance, snd_ctl_elem_value_get_enumerated(value, idx)); + obj = new_integer(instance, snd_ctl_elem_value_get_enumerated(&value, idx)); break; case SND_CTL_ELEM_TYPE_BYTES: - obj = new_integer(instance, snd_ctl_elem_value_get_byte(value, idx)); + obj = new_integer(instance, snd_ctl_elem_value_get_byte(&value, idx)); break; default: obj = NULL;