From mboxrd@z Thu Jan 1 00:00:00 1970 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=-19.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT 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 96BF3C433B4 for ; Thu, 6 May 2021 13:38:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5EB0D613F9 for ; Thu, 6 May 2021 13:38:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234310AbhEFNjG (ORCPT ); Thu, 6 May 2021 09:39:06 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:30329 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234072AbhEFNjG (ORCPT ); Thu, 6 May 2021 09:39:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620308288; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/bdOhY3sBOcIHJeoCe6CkJ1QfZvAaT12hvfPxmFulM0=; b=diAk3LMOlfbES4tV7FjKNoalRYDIzxql+fuvw50YYXcjrxxjmW98+zMC6uRAF5HQrsAU7U X1MzwlvgmJLId0zYbCZutsDUbsq7JH3SjRoBb3iSDlRZljwSgcpEUpuuV/CUbXl3uJW9Ms gyNv0PZMEjVVs+XkW90LB4grNr5xT/4= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-190-IUzylFh0Nz-lohi4v2qUBQ-1; Thu, 06 May 2021 09:38:06 -0400 X-MC-Unique: IUzylFh0Nz-lohi4v2qUBQ-1 Received: by mail-wr1-f72.google.com with SMTP id 93-20020adf80e60000b0290106fab45006so2205420wrl.20 for ; Thu, 06 May 2021 06:38:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/bdOhY3sBOcIHJeoCe6CkJ1QfZvAaT12hvfPxmFulM0=; b=RZS87O7GzTn8lL39Rexk2UXU9L3yM0JrQox4X/F47tqa9mGpWAKajgqzoMX/sz75lj JjtO1cWZMAcm4BwxIKoiMjFKinDltJv+1I1tDjwhtGWNT7qBgmmGKMUwp0yYAMSqWALy 6q6KCZcxzFuf9mQIWg0hLfm4azm2a5aJ1yJNWQqpRKahDywXBSfsksD8aqfubr0ZveQw j8LgpKNx3pkAfs4NSw9xJE/1e1rCV26B2XumD0+1SJerX/I/FmGy5r8LWtGrkFYrRyr3 rGIQIxtW21eql/9Pr6AfJirmj+pTiGsRbVdtiQcLghZkhxrjeGCSZemTM27P7yMUw7gg OHvA== X-Gm-Message-State: AOAM531h/HROpZ2bMr1Ci2LfzehQKstnBlsDpJd1wDIE3WU0WqqBSh+e j5rywdckh9o3TX6kV7V/3D4/eECEDprhUTILhEd8BGqx3NId+2iYe14Spq8ZGJZtb7QGuTa7x73 FDyFM5Es+3hcV X-Received: by 2002:a1c:1bc9:: with SMTP id b192mr15231214wmb.3.1620308285136; Thu, 06 May 2021 06:38:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwaU39xWPKmAxzTDnRmk4BpB3yHtP51ZUdmNXUtU3rYDqeE9UGHa8wm/T1yoDDa+r7xsmcCLw== X-Received: by 2002:a1c:1bc9:: with SMTP id b192mr15231189wmb.3.1620308284991; Thu, 06 May 2021 06:38:04 -0700 (PDT) Received: from localhost.localdomain (astrasbourg-652-1-219-60.w90-40.abo.wanadoo.fr. [90.40.114.60]) by smtp.gmail.com with ESMTPSA id o17sm4231200wrs.48.2021.05.06.06.38.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 May 2021 06:38:04 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: kvm@vger.kernel.org, qemu-ppc@nongnu.org, qemu-arm@nongnu.org, Gerd Hoffmann , Paolo Bonzini , =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v2 1/9] audio/alsaaudio: Replace ALSA alloca() by malloc() equivalent Date: Thu, 6 May 2021 15:37:50 +0200 Message-Id: <20210506133758.1749233-2-philmd@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210506133758.1749233-1-philmd@redhat.com> References: <20210506133758.1749233-1-philmd@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org The ALLOCA(3) man-page mentions its "use is discouraged". Define the cleanup functions for the snd_pcm_[hw/sw]_params_t types, and replace the ALSA alloca() calls by equivalent ALSA malloc(). Signed-off-by: Philippe Mathieu-Daudé --- audio/alsaaudio.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/audio/alsaaudio.c b/audio/alsaaudio.c index fcc2f62864f..f39061ebc42 100644 --- a/audio/alsaaudio.c +++ b/audio/alsaaudio.c @@ -70,6 +70,9 @@ struct alsa_params_obt { snd_pcm_uframes_t samples; }; +G_DEFINE_AUTOPTR_CLEANUP_FUNC(snd_pcm_hw_params_t, snd_pcm_hw_params_free) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(snd_pcm_sw_params_t, snd_pcm_sw_params_free) + static void GCC_FMT_ATTR (2, 3) alsa_logerr (int err, const char *fmt, ...) { va_list ap; @@ -410,9 +413,9 @@ static void alsa_dump_info (struct alsa_params_req *req, static void alsa_set_threshold (snd_pcm_t *handle, snd_pcm_uframes_t threshold) { int err; - snd_pcm_sw_params_t *sw_params; + g_autoptr(snd_pcm_sw_params_t) sw_params = NULL; - snd_pcm_sw_params_alloca (&sw_params); + snd_pcm_sw_params_malloc(&sw_params); err = snd_pcm_sw_params_current (handle, sw_params); if (err < 0) { @@ -444,7 +447,7 @@ static int alsa_open(bool in, struct alsa_params_req *req, AudiodevAlsaOptions *aopts = &dev->u.alsa; AudiodevAlsaPerDirectionOptions *apdo = in ? aopts->in : aopts->out; snd_pcm_t *handle; - snd_pcm_hw_params_t *hw_params; + g_autoptr(snd_pcm_hw_params_t) hw_params = NULL; int err; unsigned int freq, nchannels; const char *pcm_name = apdo->has_dev ? apdo->dev : "default"; @@ -455,7 +458,7 @@ static int alsa_open(bool in, struct alsa_params_req *req, freq = req->freq; nchannels = req->nchannels; - snd_pcm_hw_params_alloca (&hw_params); + snd_pcm_hw_params_malloc(&hw_params); err = snd_pcm_open ( &handle, -- 2.26.3 From mboxrd@z Thu Jan 1 00:00:00 1970 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=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT 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 6150FC433ED for ; Thu, 6 May 2021 13:42:00 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (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 D5C3261027 for ; Thu, 6 May 2021 13:41:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D5C3261027 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:33104 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1leeGM-0003yt-Oe for qemu-devel@archiver.kernel.org; Thu, 06 May 2021 09:41:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56488) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leeCg-0006jg-6Q for qemu-devel@nongnu.org; Thu, 06 May 2021 09:38:10 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:40377) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leeCe-0007eG-LG for qemu-devel@nongnu.org; Thu, 06 May 2021 09:38:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620308288; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/bdOhY3sBOcIHJeoCe6CkJ1QfZvAaT12hvfPxmFulM0=; b=diAk3LMOlfbES4tV7FjKNoalRYDIzxql+fuvw50YYXcjrxxjmW98+zMC6uRAF5HQrsAU7U X1MzwlvgmJLId0zYbCZutsDUbsq7JH3SjRoBb3iSDlRZljwSgcpEUpuuV/CUbXl3uJW9Ms gyNv0PZMEjVVs+XkW90LB4grNr5xT/4= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-192-WcTK1gb8P8uVtBlkp6njpw-1; Thu, 06 May 2021 09:38:06 -0400 X-MC-Unique: WcTK1gb8P8uVtBlkp6njpw-1 Received: by mail-wm1-f69.google.com with SMTP id s66-20020a1ca9450000b0290149fce15f03so2675155wme.9 for ; Thu, 06 May 2021 06:38:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/bdOhY3sBOcIHJeoCe6CkJ1QfZvAaT12hvfPxmFulM0=; b=oDFI+sNziKos2ieYMOurQf0q8qtlcZpYrPz7ktnSpc461hN980EKIIVNMFE/LWWI0S ux1VdeBhKG+E8lW1rTqAehkGP+mfs/AA1KSGgbFQrxo+WWojB5AT4cuy77R7Qmm8NBgV xHywu0DuwlXQkxF9XRqbGveRk1557kAgu4pAMC3wNMZd8yxlmdJ2rZhaBBD5Yh7tqtFM Diq1PLq4nCpeGBfZ9byklSPJwU9uTTI3gcWrN7ZzfxnBTxkLLMI+5JoyKooavBexKmn6 RX+1yAV6I+PHQ34TjBFcpjAUr72SowfMUfaUvZez8GopW1eWKg+dV9o2tcwnHHHgti5y sKAA== X-Gm-Message-State: AOAM531ZFu20sUmiNsrZMSZ9orTZ+PY6d/KDzwUIO4pgF24KefSnWjLw 3EgozNR9Z0v4W6lymcii4zB3eRoNTeT2rg8h4Fv5JntGfPbaxA+HP7AUd8WmdWdK8e5+dcu3QFC Ic17SCYnfQXNJyIPcfHCV4RY+/2r3q8hQqZorzgFuwBzNfQZ4dSf6TkQ4WmTFi3JJ X-Received: by 2002:a1c:1bc9:: with SMTP id b192mr15231220wmb.3.1620308285237; Thu, 06 May 2021 06:38:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwaU39xWPKmAxzTDnRmk4BpB3yHtP51ZUdmNXUtU3rYDqeE9UGHa8wm/T1yoDDa+r7xsmcCLw== X-Received: by 2002:a1c:1bc9:: with SMTP id b192mr15231189wmb.3.1620308284991; Thu, 06 May 2021 06:38:04 -0700 (PDT) Received: from localhost.localdomain (astrasbourg-652-1-219-60.w90-40.abo.wanadoo.fr. [90.40.114.60]) by smtp.gmail.com with ESMTPSA id o17sm4231200wrs.48.2021.05.06.06.38.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 May 2021 06:38:04 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 1/9] audio/alsaaudio: Replace ALSA alloca() by malloc() equivalent Date: Thu, 6 May 2021 15:37:50 +0200 Message-Id: <20210506133758.1749233-2-philmd@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210506133758.1749233-1-philmd@redhat.com> References: <20210506133758.1749233-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=170.10.133.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.69, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kvm@vger.kernel.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Gerd Hoffmann , Paolo Bonzini , =?UTF-8?q?Alex=20Benn=C3=A9e?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" The ALLOCA(3) man-page mentions its "use is discouraged". Define the cleanup functions for the snd_pcm_[hw/sw]_params_t types, and replace the ALSA alloca() calls by equivalent ALSA malloc(). Signed-off-by: Philippe Mathieu-Daudé --- audio/alsaaudio.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/audio/alsaaudio.c b/audio/alsaaudio.c index fcc2f62864f..f39061ebc42 100644 --- a/audio/alsaaudio.c +++ b/audio/alsaaudio.c @@ -70,6 +70,9 @@ struct alsa_params_obt { snd_pcm_uframes_t samples; }; +G_DEFINE_AUTOPTR_CLEANUP_FUNC(snd_pcm_hw_params_t, snd_pcm_hw_params_free) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(snd_pcm_sw_params_t, snd_pcm_sw_params_free) + static void GCC_FMT_ATTR (2, 3) alsa_logerr (int err, const char *fmt, ...) { va_list ap; @@ -410,9 +413,9 @@ static void alsa_dump_info (struct alsa_params_req *req, static void alsa_set_threshold (snd_pcm_t *handle, snd_pcm_uframes_t threshold) { int err; - snd_pcm_sw_params_t *sw_params; + g_autoptr(snd_pcm_sw_params_t) sw_params = NULL; - snd_pcm_sw_params_alloca (&sw_params); + snd_pcm_sw_params_malloc(&sw_params); err = snd_pcm_sw_params_current (handle, sw_params); if (err < 0) { @@ -444,7 +447,7 @@ static int alsa_open(bool in, struct alsa_params_req *req, AudiodevAlsaOptions *aopts = &dev->u.alsa; AudiodevAlsaPerDirectionOptions *apdo = in ? aopts->in : aopts->out; snd_pcm_t *handle; - snd_pcm_hw_params_t *hw_params; + g_autoptr(snd_pcm_hw_params_t) hw_params = NULL; int err; unsigned int freq, nchannels; const char *pcm_name = apdo->has_dev ? apdo->dev : "default"; @@ -455,7 +458,7 @@ static int alsa_open(bool in, struct alsa_params_req *req, freq = req->freq; nchannels = req->nchannels; - snd_pcm_hw_params_alloca (&hw_params); + snd_pcm_hw_params_malloc(&hw_params); err = snd_pcm_open ( &handle, -- 2.26.3