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=-13.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 autolearn=unavailable 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 D8425C433B4 for ; Thu, 6 May 2021 19:24:49 +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 493BD61164 for ; Thu, 6 May 2021 19:24:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 493BD61164 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:51526 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lejc8-0002sp-8B for qemu-devel@archiver.kernel.org; Thu, 06 May 2021 15:24:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40180) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lejaA-0001UQ-Pa for qemu-devel@nongnu.org; Thu, 06 May 2021 15:22:48 -0400 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]:37516) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1leja2-0001sh-TN for qemu-devel@nongnu.org; Thu, 06 May 2021 15:22:44 -0400 Received: by mail-wr1-x436.google.com with SMTP id z6so6777389wrm.4 for ; Thu, 06 May 2021 12:22:36 -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=OcGko0AZpfeOMrm5jT5N9J347dkqKIUp28FiXKFtwdk=; b=fELVnzK2+xFRsnRGPh//ft7E2TmxIFR18SqhN97yrkYySqfxwRVM7nMPS1kmx9/BX/ d8lCU2LfQu25BYAvEswZgx22e/LoyRz6+EIYTY4eU4ShXsZS/nYDa5+gP/KWIDKszo/c M0WLyrc3i91S1+Dy53iMsyCIuA2sDNPcVDcPjPC7qyxyKhKP25ltlUClufgWfb8yGrCk nuYBeT2/NCmJpSWDs9bpLugSq6FqorqXdwEsuh+hTexVA3ScBlU6LaLTbyHaC3qGg09f eP09zF4EfJaaw1dnt1Ubroq5jzpysEQSFMaOeh6uqcEe9kqH31NAzOmISGT8QpyI/XLS P2nA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:references:user-agent:from:to:cc:subject:date :in-reply-to:message-id:mime-version:content-transfer-encoding; bh=OcGko0AZpfeOMrm5jT5N9J347dkqKIUp28FiXKFtwdk=; b=gWIqpHuiwJV7dd5VfkPQVar/3YcL/f2jOp6inGfAMzQMtQofINKhj6d+cmefRrokkL InF2dqrSCO80xFBLXJ4XSQh+b8/G3ZfZu5r6gw7nsKolVT8kqk9x9nTet2uno186Z4Pu 9nAujcziHvR5XYFKrsvcXJXH0/mS2hWhsebQX7pzAKLTcpPk2yJ04hOVUWwWWu2iebHP RgcNYnzqeIkE26fUTiCdqju3df9luV4WOwHSejllQPLvwhLRBv9X7eCp3tNb752sLRsk x0rqT0JFElsKYKdHb/RMKmzvz+STaaPKnWTOmyu4e85Uog/KqtiWg8wSL5DhltP1QUMK RDyA== X-Gm-Message-State: AOAM532xmoVJ7OxcAoRBHpmv7OeHK7ff77zooQhVYRqt05WOW+YL6O0w cJ0RSAKvqABlsLOOwkJeN83A4g== X-Google-Smtp-Source: ABdhPJz7hohkJdA1qQSV8cIlvzUqbOP6alUWSu9tndMQ8CfhwlXE/7/aWSvUceGtoPB3tbC5F9TWzw== X-Received: by 2002:a5d:6648:: with SMTP id f8mr7554311wrw.396.1620328955527; Thu, 06 May 2021 12:22:35 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id t7sm5572382wrw.60.2021.05.06.12.22.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 May 2021 12:22:34 -0700 (PDT) Received: from zen (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 811051FF7E; Thu, 6 May 2021 20:22:33 +0100 (BST) References: <20210506133758.1749233-1-philmd@redhat.com> <20210506133758.1749233-8-philmd@redhat.com> User-agent: mu4e 1.5.13; emacs 28.0.50 From: Alex =?utf-8?Q?Benn=C3=A9e?= To: Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= Subject: Re: [PATCH v2 7/9] gdbstub: Replace alloca() + memset(0) by g_new0() Date: Thu, 06 May 2021 20:22:01 +0100 In-reply-to: <20210506133758.1749233-8-philmd@redhat.com> Message-ID: <87v97vmzuu.fsf@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=2a00:1450:4864:20::436; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x436.google.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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable 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, qemu-devel@nongnu.org, qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Gerd Hoffmann , Paolo Bonzini Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Philippe Mathieu-Daud=C3=A9 writes: > The ALLOCA(3) man-page mentions its "use is discouraged". > > Replace the alloca() and memset(0) calls by g_new0(). > > Signed-off-by: Philippe Mathieu-Daud=C3=A9 Please see: Subject: [ALT PATCH] gdbstub: Replace GdbCmdContext with plain g_array() Date: Thu, 6 May 2021 17:07:41 +0100 Message-Id: <20210506160741.9841-1-alex.bennee@linaro.org> which also includes elements of 6/9 which can be kept split off. > --- > gdbstub.c | 5 ++--- > 1 file changed, 2 insertions(+), 3 deletions(-) > > diff --git a/gdbstub.c b/gdbstub.c > index 7cee2fb0f1f..666053bf590 100644 > --- a/gdbstub.c > +++ b/gdbstub.c > @@ -1487,14 +1487,13 @@ static int process_string_cmd(void *user_ctx, con= st char *data, > if (cmd->schema) { > int schema_len =3D strlen(cmd->schema); > int max_num_params =3D schema_len / 2; > + g_autofree GdbCmdVariant *params =3D NULL; >=20=20 > if (schema_len % 2) { > return -2; > } >=20=20 > - gdb_ctx.params =3D (GdbCmdVariant *)alloca(sizeof(*gdb_ctx.p= arams) > - * max_num_params); > - memset(gdb_ctx.params, 0, sizeof(*gdb_ctx.params) * max_num_= params); > + gdb_ctx.params =3D params =3D g_new0(GdbCmdVariant, max_num_= params); >=20=20 > if (cmd_parse_params(&data[strlen(cmd->cmd)], cmd->schema, > gdb_ctx.params, &gdb_ctx.num_params)) { --=20 Alex Benn=C3=A9e