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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B9170C433F5 for ; Fri, 1 Oct 2021 15:29:12 +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 41C3061A07 for ; Fri, 1 Oct 2021 15:29:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 41C3061A07 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=crudebyte.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:56996 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mWKTG-00028z-7X for qemu-devel@archiver.kernel.org; Fri, 01 Oct 2021 11:29:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60496) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mWKRL-0000nI-4X for qemu-devel@nongnu.org; Fri, 01 Oct 2021 11:27:11 -0400 Received: from kylie.crudebyte.com ([5.189.157.229]:40913) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mWKRJ-00020c-9N for qemu-devel@nongnu.org; Fri, 01 Oct 2021 11:27:10 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=kylie; h=Content-Type:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Content-ID:Content-Description; bh=U9xXzKTdMOgii859ZIwfiIob9l3wpxTEIR8Z5UwaiUo=; b=Yt8JdPikVW7zgZDDu9akZqh+WN eho5rAYAWHZBKEX+MZJ212wTNcveRU9VpFjLsTdQGrRsJlSbuYSWeZM5oxMmd3ToY8gF8Lk8UXfot EWDyq1KXJlSkm2Q45rwfoTlkEqdPd6+Kxl1dvONSB2yfBeDn0HqLOZGYTOWKGpuuTIr7fo+QUbLrY 88ffp0pgnIrLCUcWTQA7CP1GPUAk1UrSxU6Lo0ls9EZNYCCWUus6yxPSaLsBtzh8X7nxAEz4lY4t8 Mu2hv9WxpmhjW3gXhvn2/nJqlGMYfMM9B7B0OlQEAUycFvjbMIFoDv7BYF8aMpLr/hcR7RcMiIEHb DZyrJiH8KgV7tGQ4Ku8gSgHi6VLzCwtclEfaQ8qq90BEQYmEusUvFb9Wbm2enrzInLO7J3cZyKB4E SeRUe6h0ZZ1ru7R/UxPYFvoEstRwJBDyeNahC3AfqkCeMyiwVoNqkOlH09XDmvK/hmWKuZhiylV2E N1s+ZHLw5y+SwaZ/4CLAjvykwOpw2rH/5uQJoW3pqR9GKTEnXq192ehd0/rkEYviniIX+liCkgsy1 uzixRHqxetue61xrh86DfJS6YECEEZj8f1g0FS9+Sf02kCEOt0f01qFZEvldMQLv6bDcXQYHRA8qa 40IoO2WT+dJVuQX/2TnOC/QQiBzKcOk4j44qvOziY=; From: Christian Schoenebeck To: qemu-devel@nongnu.org, Daniel =?ISO-8859-1?Q?P=2E_Berrang=E9?= Cc: Richard Henderson , Greg Kurz Subject: Re: [PATCH 1/5] 9pfs: introduce P9Array Date: Fri, 01 Oct 2021 17:27:06 +0200 Message-ID: <3721374.iaAHClRopi@silver> In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="iso-8859-1" Received-SPF: pass client-ip=5.189.157.229; envelope-from=qemu_oss@crudebyte.com; helo=kylie.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 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" On Freitag, 1. Oktober 2021 17:16:47 CEST Daniel P. Berrang=E9 wrote: > On Fri, Oct 01, 2021 at 04:26:17PM +0200, Christian Schoenebeck wrote: > > Implements deep auto free of arrays while retaining common C-style > > squared bracket access. Main purpose of this API is to get rid of > > error prone individual array deallocation pathes in user code, i.e. > >=20 > > turning something like this: > > void doSomething(size_t n) { > > =20 > > Foo *foos =3D malloc(n * sizeof(Foo)); > > for (...) { > > =20 > > foos[i].s =3D malloc(...); > > if (...) { > > =20 > > goto out; > > =20 > > } > > =20 > > } > > =20 > > out: > > if (...) { > > =20 > > for (...) { > > =20 > > /* deep deallocation */ > > free(foos[i].s); > > =20 > > } > > /* array deallocation */ > > free(foos); > > =20 > > } > > =20 > > } > >=20 > > into something more simple and safer like: > > void doSomething(size_t n) { > > =20 > > P9ARRAY_REF(Foo) foos =3D NULL; > > P9ARRAY_NEW(Foo, foos, n); > > for (...) { > > =20 > > foos[i].s =3D malloc(...); > > if (...) { > > =20 > > return; /* array auto freed here */ > > =20 > > } > > =20 > > } > > /* array auto freed here */ > > =20 > > } >=20 > As explained before, I'm against the idea of introducing new ways > to automatically free local variables that are not using g_auto* > functionality. It is not following the QEMU wide coding style > that is documented. Yes, your concerns are linked in the cover letter. And I also made it clear= =20 that what you suggested does not fit either. So my position has not changed. Best regards, Christian Schoenebeck