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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 7B388C433EF for ; Mon, 14 Mar 2022 20:39:08 +0000 (UTC) Received: from localhost ([::1]:36206 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nTrT9-0007xt-B3 for qemu-devel@archiver.kernel.org; Mon, 14 Mar 2022 16:39:07 -0400 Received: from eggs.gnu.org ([209.51.188.92]:50068) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nTrS9-0006Na-Dl; Mon, 14 Mar 2022 16:38:05 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:38497) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nTrS7-0001w3-JZ; Mon, 14 Mar 2022 16:38:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=lizzy; h=Content-Type:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Content-ID:Content-Description; bh=KF8x4q8MycoHpg2xC2ppJT33EhSOfBmOE9odyg8H5bM=; b=VxWrwGsYfWl0j+4yzzjaKIIlcc 8xd/GykZchfzxIwxLFdMxPJ57GT1FerR4J3x/R5sOO6JSA+9Z9NURazqZ7GZ8oVe57BPVBDDlhR/F 9ztGmpJHOGc4UA8v2Jy1E6t5jF57lE5IUPcgQI1GVprljnGfXZX3Le8Zl5nUsv62csdJTvh3+XtzA M80ScXk1eztYgD8SX1erdIPf7MnAgw2MadHs8zbf5fN2zrk1f72+DzklfbEeIXjsmV+/g0mUPsTuK IP3Gy5N1ORQjoPthZyvzqwAxdIaq9rCA8rKE7SewEkR8B50i951zLLV9CH5zt+HKYwKa0XLk2ubLw L2q1LeRw==; From: Christian Schoenebeck To: Alex =?ISO-8859-1?Q?Benn=E9e?= Cc: Markus Armbruster , qemu-devel@nongnu.org, Paolo Bonzini , Richard Henderson , Gerd Hoffmann , "Gonglei (Arei)" , =?ISO-8859-1?Q?Marc=2DAndr=E9?= Lureau , "Michael S. Tsirkin" , Igor Mammedov , Ani Sinha , Laurent Vivier , Amit Shah , Peter Maydell , Stefano Stabellini , Anthony Perard , Paul Durrant , =?ISO-8859-1?Q?Herv=E9?= Poussineau , Aleksandar Rikalo , Corey Minyard , Patrick Venture , Eduardo Habkost , Marcel Apfelbaum , Peter Xu , Jason Wang , =?ISO-8859-1?Q?C=E9dric?= Le Goater , Daniel Henrique Barboza , David Gibson , Greg Kurz , Philippe =?ISO-8859-1?Q?Mathieu=2DDaud=E9?= , Jean-Christophe Dubois , Keith Busch , Klaus Jensen , Yuval Shaia , Yoshinori Sato , Magnus Damm , Fabien Chouteau , KONRAD Frederic , Mark Cave-Ayland , Artyom Tarasenko , Alex Williamson , Eric Auger , Max Filippov , Juan Quintela , "Dr. David Alan Gilbert" , Konstantin Kostiuk , Michael Roth , Daniel =?ISO-8859-1?Q?P=2E_Berrang=E9?= , Pavel Dovgalyuk , David Hildenbrand , Wenchao Wang , Kamil Rytarowski , Reinoud Zandijk , Sunil Muthuswamy , Cornelia Huck , Thomas Huth , Eric Blake , Vladimir Sementsov-Ogievskiy , John Snow , kvm@vger.kernel.org, qemu-arm@nongnu.org, xen-devel@lists.xenproject.org, qemu-ppc@nongnu.org, qemu-block@nongnu.org, haxm-team@intel.com, qemu-s390x@nongnu.org Subject: Re: [PATCH 3/3] Use g_new() & friends where that makes obvious sense Date: Mon, 14 Mar 2022 21:37:00 +0100 Message-ID: <3080370.YxCODQx3Uq@silver> In-Reply-To: <877d8w5m9e.fsf@linaro.org> References: <20220314160108.1440470-1-armbru@redhat.com> <20220314160108.1440470-4-armbru@redhat.com> <877d8w5m9e.fsf@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="iso-8859-1" Received-SPF: pass client-ip=91.194.90.13; envelope-from=qemu_oss@crudebyte.com; helo=lizzy.crudebyte.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" On Montag, 14. M=E4rz 2022 20:48:47 CET Alex Benn=E9e wrote: > Markus Armbruster writes: > > g_new(T, n) is neater than g_malloc(sizeof(T) * n). It's also safer, > > for two reasons. One, it catches multiplication overflowing size_t. > > Two, it returns T * rather than void *, which lets the compiler catch > > more type errors. > >=20 > > This commit only touches allocations with size arguments of the form > > sizeof(T). > >=20 > > Patch created mechanically with: > > $ spatch --in-place --sp-file scripts/coccinelle/use-g_new-etc.cocc= i \ > > =20 > > --macro-file scripts/cocci-macro-file.h FILES... > >=20 > > Signed-off-by: Markus Armbruster >=20 > >=20 > > --- a/audio/jackaudio.c > > +++ b/audio/jackaudio.c > > @@ -97,9 +97,9 @@ static void qjack_buffer_create(QJackBuffer *buffer, = int > > channels, int frames)>=20 > > buffer->used =3D 0; > > buffer->rptr =3D 0; > > buffer->wptr =3D 0; > >=20 > > - buffer->data =3D g_malloc(channels * sizeof(float *)); > > + buffer->data =3D g_new(float *, channels); > >=20 > > for (int i =3D 0; i < channels; ++i) { > >=20 > > - buffer->data[i] =3D g_malloc(frames * sizeof(float)); > > + buffer->data[i] =3D g_new(float, frames); >=20 > Are these actually buffers of pointers to floats? I guess I leave that > to the JACK experts... That's correct. JACK does not use interleaved audio format, it uses separat= e=20 buffers for each audio channel. For the audio stuff of this patch: Reviewed-by: Christian Schoenebeck Best regards, Christian Schoenebeck