All of lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Sakamoto <o-takashi@sakamocchi.jp>
To: tiwai@suse.de
Cc: alsa-devel@alsa-project.org
Subject: [PATCH 23/34] conf: remove alloca() from snd_determine_driver()
Date: Thu, 14 Jul 2016 23:07:40 +0900	[thread overview]
Message-ID: <1468505271-5769-24-git-send-email-o-takashi@sakamocchi.jp> (raw)
In-Reply-To: <1468505271-5769-1-git-send-email-o-takashi@sakamocchi.jp>

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 <o-takashi@sakamocchi.jp>
---
 src/confmisc.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/src/confmisc.c b/src/confmisc.c
index ae0275f..3f12e34 100644
--- a/src/confmisc.c
+++ b/src/confmisc.c
@@ -664,7 +664,7 @@ SND_DLSYM_BUILD_VERSION(snd_func_private_string, SND_CONFIG_DLSYM_VERSION_EVALUA
 int snd_determine_driver(int card, char **driver)
 {
 	snd_ctl_t *ctl = NULL;
-	snd_ctl_card_info_t *info;
+	snd_ctl_card_info_t info = {0};
 	char *res = NULL;
 	int err;
 
@@ -674,13 +674,12 @@ int snd_determine_driver(int card, char **driver)
 		SNDERR("could not open control for card %i", card);
 		goto __error;
 	}
-	snd_ctl_card_info_alloca(&info);
-	err = snd_ctl_card_info(ctl, info);
+	err = snd_ctl_card_info(ctl, &info);
 	if (err < 0) {
 		SNDERR("snd_ctl_card_info error: %s", snd_strerror(err));
 		goto __error;
 	}
-	res = strdup(snd_ctl_card_info_get_driver(info));
+	res = strdup(snd_ctl_card_info_get_driver(&info));
 	if (res == NULL)
 		err = -ENOMEM;
 	else {
-- 
2.7.4

  parent reply	other threads:[~2016-07-14 14:08 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-14 14:07 [alsa-lib][PATCH 00/34] pcm/conf/alisp: replace usage of alloca() with automatic variables Takashi Sakamoto
2016-07-14 14:07 ` [PATCH 01/34] pcm: change code formatting for snd_pcm_set_params() Takashi Sakamoto
2016-07-14 14:07 ` [PATCH 02/34] pcm: remove alloca() from snd_pcm_set_params() Takashi Sakamoto
2016-07-14 14:07 ` [PATCH 03/34] pcm: change code formatting for snd_pcm_get_params() Takashi Sakamoto
2016-07-14 14:07 ` [PATCH 04/34] pcm: remove alloca() from snd_pcm_get_params Takashi Sakamoto
2016-07-14 14:07 ` [PATCH 05/34] pcm: change code formatting for snd_pcm_direct_initialize_slave() Takashi Sakamoto
2016-07-14 14:07 ` [PATCH 06/34] pcm: remove alloca() from snd_pcm_direct_initialize_slave Takashi Sakamoto
2016-07-14 14:07 ` [PATCH 07/34] pcm: change code formatting for snd_pcm_direct_initialize_poll_fd() Takashi Sakamoto
2016-07-14 14:07 ` [PATCH 08/34] pcm: remove alloca() from snd_pcm_direct_initialize_poll_fd() Takashi Sakamoto
2016-07-14 14:07 ` [PATCH 09/34] pcm: change code formatting for snd_pcm_direct_set_timer_params() Takashi Sakamoto
2016-07-14 14:07 ` [PATCH 10/34] pcm: remove alloca() from snd_pcm_direct_set_timer_params Takashi Sakamoto
2016-07-14 14:07 ` [PATCH 11/34] pcm: remove alloca() from _snd_pcm_hook_ctl_elems_install() Takashi Sakamoto
2016-07-14 14:07 ` [PATCH 12/34] pcm: change code formatting for snd_pcm_hw_change_timer() Takashi Sakamoto
2016-07-14 14:07 ` [PATCH 13/34] pcm: remove alloca() from snd_pcm_hw_change_timer() Takashi Sakamoto
2016-07-14 14:07 ` [PATCH 14/34] pcm: remove alloca() from snd_pcm_query_chmaps_from_hw() Takashi Sakamoto
2016-07-14 14:07 ` [PATCH 15/34] pcm: remove alloca() from snd_pcm_hw_get_chmap() Takashi Sakamoto
2016-07-14 14:07 ` [PATCH 16/34] pcm: remove alloca() from snd_pcm_hw_set_chmap() Takashi Sakamoto
2016-07-14 14:07 ` [PATCH 17/34] pcm: remove alloca() from snd_spcm_init() Takashi Sakamoto
2016-07-14 14:07 ` [PATCH 18/34] pcm: remove alloca() from snd_spcm_init_duplex() Takashi Sakamoto
2016-07-14 14:07 ` [PATCH 19/34] pcm: change code formatting for softvol_load_control() Takashi Sakamoto
2016-07-14 14:07 ` [PATCH 20/34] pcm: remove alloca() from softvol_load_control() Takashi Sakamoto
2016-07-14 14:07 ` [PATCH 21/34] pcm: change code formatting for _snd_pcm_softvol_open() Takashi Sakamoto
2016-07-14 14:07 ` [PATCH 22/34] pcm: remove alloca() from _snd_pcm_softvol_open() Takashi Sakamoto
2016-07-14 14:07 ` Takashi Sakamoto [this message]
2016-07-14 14:07 ` [PATCH 24/34] conf: remove alloca() from snd_func_card_id() Takashi Sakamoto
2016-07-14 14:07 ` [PATCH 25/34] conf: remove alloca() from snd_func_card_name() Takashi Sakamoto
2016-07-14 14:07 ` [PATCH 26/34] conf: remove alloca() from snd_func_pcm_id() Takashi Sakamoto
2016-07-14 14:07 ` [PATCH 27/34] conf: remove alloca() from snd_func_pcm_args_by_class() Takashi Sakamoto
2016-07-14 14:07 ` [PATCH 28/34] conf: remove alloca() from snd_func_private_pcm_subdevice() Takashi Sakamoto
2016-07-14 14:07 ` [PATCH 29/34] alisp: remove alloca() from FA_card_info() Takashi Sakamoto
2016-07-14 14:07 ` [PATCH 30/34] alisp: remove alloca() from FA_hctl_find_elem() Takashi Sakamoto
2016-07-14 14:07 ` [PATCH 31/34] alisp: remove alloca() from FA_hctl_elem_info() Takashi Sakamoto
2016-07-14 14:07 ` [PATCH 32/34] alisp: remove alloca() from FA_hctl_elem_read() Takashi Sakamoto
2016-07-14 14:07 ` [PATCH 33/34] alisp: remove alloca() from FA_hctl_elem_write() Takashi Sakamoto
2016-07-14 14:07 ` [PATCH 34/34] alisp: remove alloca() from FA_pcm_info() Takashi Sakamoto
2016-07-14 16:02 ` [alsa-lib][PATCH 00/34] pcm/conf/alisp: replace usage of alloca() with automatic variables Takashi Iwai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1468505271-5769-24-git-send-email-o-takashi@sakamocchi.jp \
    --to=o-takashi@sakamocchi.jp \
    --cc=alsa-devel@alsa-project.org \
    --cc=tiwai@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.