Return-Path: Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id f7-20020a17090631c700b006b293ddbca1sm7314593ejf.35.2022.03.14.15.55.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Mar 2022 15:55:10 -0700 (PDT) Received: from zen (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 47A0E1FFB7; Mon, 14 Mar 2022 22:55:09 +0000 (GMT) References: <20220314160108.1440470-1-armbru@redhat.com> <20220314160108.1440470-4-armbru@redhat.com> User-agent: mu4e 1.7.10; emacs 28.0.92 From: Alex =?utf-8?Q?Benn=C3=A9e?= To: Markus Armbruster Cc: qemu-devel@nongnu.org, Paolo Bonzini , Richard Henderson , Gerd Hoffmann , Christian Schoenebeck , "Gonglei (Arei)" , =?utf-8?Q?Marc-Andr=C3=A9?= Lureau , "Michael S. Tsirkin" , Igor Mammedov , Ani Sinha , Laurent Vivier , Amit Shah , Peter Maydell , Stefano Stabellini , Anthony Perard , Paul Durrant , =?utf-8?Q?Herv=C3=A9?= Poussineau , Aleksandar Rikalo , Corey Minyard , Patrick Venture , Eduardo Habkost , Marcel Apfelbaum , Peter Xu , Jason Wang , =?utf-8?Q?C=C3=A9dric?= Le Goater , Daniel Henrique Barboza , David Gibson , Greg Kurz , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= , 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 , =?utf-8?Q?Daniel_P=2E_Berrang=C3=A9?= , Pavel Dovgalyuk , David Hildenbrand , Wenchao Wang , Colin Xu , 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 22:52:52 +0000 In-reply-to: <20220314160108.1440470-4-armbru@redhat.com> Message-ID: <87y21c401e.fsf@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-TUID: ZscR6zjZ3Hbs 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. > > diff --git a/semihosting/config.c b/semihosting/config.c > index 137171b717..6d48ec9566 100644 > --- a/semihosting/config.c > +++ b/semihosting/config.c > @@ -98,7 +98,7 @@ static int add_semihosting_arg(void *opaque, > if (strcmp(name, "arg") =3D=3D 0) { > s->argc++; > /* one extra element as g_strjoinv() expects NULL-terminated arr= ay */ > - s->argv =3D g_realloc(s->argv, (s->argc + 1) * sizeof(void *)); > + s->argv =3D g_renew(void *, s->argv, s->argc + 1); This did indeed break CI because s->argv is an array of *char: ../semihosting/config.c:101:17: error: assignment to =E2=80=98const char **= =E2=80=99 from incompatible pointer type =E2=80=98void **=E2=80=99 [-Werror= =3Dincompatible-pointer-types] 101 | s->argv =3D g_renew(void *, s->argv, s->argc + 1); | ^ cc1: all warnings being treated as errors So it did the job of type checking but failed to build ;-) --=20 Alex Benn=C3=A9e