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 81A0AC433F5 for ; Mon, 14 Mar 2022 19:27:08 +0000 (UTC) Received: from localhost ([::1]:39856 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nTqLT-0000Ln-I2 for qemu-devel@archiver.kernel.org; Mon, 14 Mar 2022 15:27:07 -0400 Received: from eggs.gnu.org ([209.51.188.92]:35082) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nTqHi-0000nb-LN for qemu-devel@nongnu.org; Mon, 14 Mar 2022 15:23:14 -0400 Received: from [2a00:1450:4864:20::529] (port=41817 helo=mail-ed1-x529.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nTqHh-0007po-1k for qemu-devel@nongnu.org; Mon, 14 Mar 2022 15:23:14 -0400 Received: by mail-ed1-x529.google.com with SMTP id c20so21330792edr.8 for ; Mon, 14 Mar 2022 12:23:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=references:user-agent:from:to:cc:subject:date:in-reply-to :message-id:mime-version:content-transfer-encoding; bh=vwsEf23SGv9uU5Z5WKKS3nYhdclo4TxJUctKhcssOgU=; b=qvTNjBOvKwjtOKZE7TV+144NPqDHMdIuTMR2L4vLzrDFbF50W8MgId7xWklR7gQ7ee m1QhfAaSvZnLn66ax1xooADuhGrNNgCne1BBid6u3Gh0LdRB3DCFqDiSzHPBkvSQU7/1 ARfBXBv6cFzOjaWh+JerzOI2v5WTvgqMRdwX3XRYHJOQ/bMo0EPsBvdMJlCcZ2qiedRE 03E/08n9fH/SPMmg8wDKXE3wezITjh0Ku7x2GHRQJxOB28dnC8WtnI6ZBWinc58SZVuy SMn1h1Gw/QOgZrbW+ApQnfN+ZY7XwXBwNNPCZU9vR3Re+TkWn2jpxFHrOTbRTUk37cfE AgaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:references:user-agent:from:to:cc:subject:date :in-reply-to:message-id:mime-version:content-transfer-encoding; bh=vwsEf23SGv9uU5Z5WKKS3nYhdclo4TxJUctKhcssOgU=; b=BNE3JyP+StdRni5Z8iSBcW4Erw1dq9WxKUW5+myk+pMLFJ4GM8popyZCetnizxGdOZ NAw1vm3t3iDwWCZcHL6u3Ofstbf8oyxz1PMjRPWK90Ku4LDV9dTdepxcxc+SGyEfBr74 7K/6r8ZUpWOTwsXqx38okVVKwP1JosH2d8pVEvH3413JAn7KVl1yt77KbBPtVFkGrYML x/jxqwwCKzedLyV8ncaxwRUnHcXri4Clxy0Zasjiw5JL9AQekbZEJq6IndeeUTYjkFnZ Hrp/FHAWG/ttKkSUzV5QOCFmJyGbqF7E4nm4mCf0UiEsG/KXmVyUibMX3dHSyXK+aLxQ mzmw== X-Gm-Message-State: AOAM530SxSI+vKj+NZKmx4NkY9ObcQCZSWCAREZ17k9chRTOrVpmX85K vsnv2yMN1uxD4c9qN3W/tmnPJw== X-Google-Smtp-Source: ABdhPJxcq//GLw34w34R/ZbAznfxC0Uo39AL2FcFmtAlAOmZNvx3LMgnwn1d/9NJkypRc95UVUwxTA== X-Received: by 2002:a05:6402:b42:b0:415:e6e7:65aa with SMTP id bx2-20020a0564020b4200b00415e6e765aamr21292242edb.105.1647285791693; Mon, 14 Mar 2022 12:23:11 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id sa13-20020a1709076d0d00b006ce3ef8e1d4sm7068524ejc.31.2022.03.14.12.23.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Mar 2022 12:23:10 -0700 (PDT) Received: from zen (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 117581FFB7; Mon, 14 Mar 2022 19:23:10 +0000 (GMT) References: <20220314160108.1440470-1-armbru@redhat.com> <20220314160108.1440470-3-armbru@redhat.com> User-agent: mu4e 1.7.10; emacs 28.0.92 From: Alex =?utf-8?Q?Benn=C3=A9e?= To: Markus Armbruster Subject: Re: [PATCH 2/3] 9pfs: Use g_new() & friends where that makes obvious sense Date: Mon, 14 Mar 2022 19:23:04 +0000 In-reply-to: <20220314160108.1440470-3-armbru@redhat.com> Message-ID: <87ee345of5.fsf@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::529 (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::529; envelope-from=alex.bennee@linaro.org; helo=mail-ed1-x529.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 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, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Cc: Peter Maydell , Daniel Henrique Barboza , kvm@vger.kernel.org, "Michael S. Tsirkin" , Jason Wang , Christian Schoenebeck , qemu-devel@nongnu.org, Peter Xu , Klaus Jensen , KONRAD Frederic , Konstantin Kostiuk , Gerd Hoffmann , Ani Sinha , Reinoud Zandijk , Eric Blake , Sunil Muthuswamy , Stefano Stabellini , xen-devel@lists.xenproject.org, Yoshinori Sato , Juan Quintela , Paul Durrant , Magnus Damm , Kamil Rytarowski , "Gonglei \(Arei\)" , =?utf-8?Q?Herv=C3=A9?= Poussineau , Michael Roth , Anthony Perard , =?utf-8?Q?Marc-Andr=C3=A9?= Lureau , Artyom Tarasenko , Laurent Vivier , Aleksandar Rikalo , Amit Shah , Mark Cave-Ayland , haxm-team@intel.com, Richard Henderson , Greg Kurz , Fabien Chouteau , Yuval Shaia , Thomas Huth , Eric Auger , Alex Williamson , qemu-arm@nongnu.org, =?utf-8?Q?C=C3=A9dric?= Le Goater , Pavel Dovgalyuk , Paolo Bonzini , Keith Busch , qemu-ppc@nongnu.org, David Hildenbrand , John Snow , David Gibson , Eduardo Habkost , Vladimir Sementsov-Ogievskiy , =?utf-8?Q?Daniel_P=2E_Berrang=C3=A9?= , qemu-block@nongnu.org, Max Filippov , qemu-s390x@nongnu.org, Patrick Venture , Cornelia Huck , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= , Jean-Christophe Dubois , Corey Minyard , Wenchao Wang , Igor Mammedov , "Dr. David Alan Gilbert" , Colin Xu Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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. > > This commit only touches allocations with size arguments of the form > sizeof(T). > > Patch created mechanically with: > > $ spatch --in-place --sp-file scripts/coccinelle/use-g_new-etc.cocci \ > --macro-file scripts/cocci-macro-file.h FILES... > > Except this uncovers a typing error: > > ../hw/9pfs/9p.c:855:13: warning: incompatible pointer types assigning= to 'QpfEntry *' from 'QppEntry *' [-Wincompatible-pointer-types] > val =3D g_new0(QppEntry, 1); > ^ ~~~~~~~~~~~~~~~~~~~ > 1 warning generated. > > Harmless, because QppEntry is larger than QpfEntry. Fix to allocate a > QpfEntry instead. > > Cc: Greg Kurz > Cc: Christian Schoenebeck > Signed-off-by: Markus Armbruster Reviewed-by: Alex Benn=C3=A9e --=20 Alex Benn=C3=A9e