From nobody Mon Feb 9 23:39:18 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1620234077; cv=none; d=zohomail.com; s=zohoarc; b=bdfgo1DYaZ0no4Fspg657MOB80jxmyH7Cwmmj+i8mGpyU6Stdb1w4fcBHFX+Mf7YOGr1c0mW+/eiNiLD4FOJ8GSEOrf9Pj54+UVz3FWhMBTJlS0hRCZniT8tkJaeVIBXtmagzBtoPuGSFrXSFiJOMl2Pn7nBfw1jKX0xpaMfPO0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620234077; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=v6dDjUUr1jX0kd69bV9ZwwKe4Jn9sJZazvtpBwyg5KA=; b=XdHCRuuedJ0TeXfT8QN2v0Ivd3+W5Zjlrvy95qeThOwe3OAnSz89PC1f28WkXD4FEkWFQRVf96QdLbsUvPGaYymkegSpSdNvWLdkzwTXuui8iUp4E+F0iq779KsVgI/lpgWHkHBmXxbvXTyH7MbN+VKnkm7wh2gdsMO2HY80qlg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1620234077362581.6713859656356; Wed, 5 May 2021 10:01:17 -0700 (PDT) Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-475-RICAxLchNhe99C7Ktuw3PQ-1; Wed, 05 May 2021 13:01:13 -0400 Received: by mail-wm1-f71.google.com with SMTP id v2-20020a7bcb420000b0290146b609814dso541289wmj.0 for ; Wed, 05 May 2021 10:01:12 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.redhat.com (astrasbourg-653-1-188-220.w90-13.abo.wanadoo.fr. [90.13.127.220]) by smtp.gmail.com with ESMTPSA id n5sm16047652wrx.31.2021.05.05.10.01.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 May 2021 10:01:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620234074; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=v6dDjUUr1jX0kd69bV9ZwwKe4Jn9sJZazvtpBwyg5KA=; b=BQn4g5Y1gTRMSnjY74nDP4/QPWughTAtUjFUNYgKzov/nALJHxjVSr7c9uuZ4/60beNIGt +Tx2lyVCTSRr+xYtCTNx9n2aVRDU4WxDIGZp2ztd5UssmbLux6TGMuQyy2Kqhg6i+105CS h5sugk4p0g1dOX3cS/BBrc3kqgK7fxg= X-MC-Unique: RICAxLchNhe99C7Ktuw3PQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=v6dDjUUr1jX0kd69bV9ZwwKe4Jn9sJZazvtpBwyg5KA=; b=kZqFX/BAzO6mjYdigTjhtUNwm8ZuTvWMRDPnU7trsTXAg8PbFvFWNRPXBU1WOSjvbV 7VQvJbPNU3uvJVFye94Ng/PBPokMu0sSp6sFmC7QgxVZLKyPDHQbzHhyNknLrwKy8tax unabQD36/Kg9ypxy/z4cwT+eytLumI8iz4GmgO+0tzu4Si6qzHqE5DqGupXspJQUb5sL /BZ83cyK3S/Pp0FeiB9vICr4t2uSzCUvjhz+2zylr574tdvdbm8GoLSdXk9ms1zkgLgt t26HBxttD2O/QkZNj3DdGc2b/f55HoJhOye087jXdyRW1BQMTH/5JZ2nHSGlMLeiDuQr Jl7Q== X-Gm-Message-State: AOAM531v57nsIokdPEOXHSxm+Ynv2edPfJ3Q8LlZvxLb1caKsQWpOhOR NEsq/avL5i/Tk5VqEuzQKJ3F8Q2+1i6Lb5lB+6CNoTA+/ovP0UNQmxK987DerFoiAZ0jZVG8w4W n7cJuWlBDJvQb7w== X-Received: by 2002:a5d:4cce:: with SMTP id c14mr12191wrt.29.1620234071863; Wed, 05 May 2021 10:01:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwUVOp3pO1Wn/Eg12ZEK46NsmpT3zPU6R7yIqJ0Q6XmSE4diSFvuXPe8REXrt2tEMJBnmTrMA== X-Received: by 2002:a5d:4cce:: with SMTP id c14mr12167wrt.29.1620234071681; Wed, 05 May 2021 10:01:11 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , David Gibson , Paolo Bonzini , Warner Losh , Kyle Evans , Greg Kurz , =?UTF-8?q?Alex=20Benn=C3=A9e?= Subject: [PATCH 3/5] gdbstub: Use fixed-size array in GdbCmdParseEntry instead of pointer Date: Wed, 5 May 2021 19:00:53 +0200 Message-Id: <20210505170055.1415360-4-philmd@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210505170055.1415360-1-philmd@redhat.com> References: <20210505170055.1415360-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) GdbCmdParseEntry should have enough room with 20 chars for the command string, and 8 for the schema. Add the GDB_CMD_PARSE_ENTRY_CMD_SIZE and GDB_CMD_PARSE_ENTRY_SCHEMA_SIZE definitions. Do not use pointer to string of unknown length, but array of fixed size. Having constant size will help use to remove the alloca() call in process_string_cmd() in the next commit. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- gdbstub.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index 6f663cbd8dd..0d5569ee539 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1457,11 +1457,13 @@ typedef void (*GdbCmdHandler)(GdbCmdContext *gdb_ct= x, void *user_ctx); * '.' -> Skip 1 char unless reached "\0" * Any other value is treated as the delimiter value itself */ +#define GDB_CMD_PARSE_ENTRY_CMD_SIZE 20 +#define GDB_CMD_PARSE_ENTRY_SCHEMA_SIZE 8 typedef struct GdbCmdParseEntry { GdbCmdHandler handler; - const char *cmd; + const char cmd[GDB_CMD_PARSE_ENTRY_CMD_SIZE]; bool cmd_startswith; - const char *schema; + const char schema[GDB_CMD_PARSE_ENTRY_SCHEMA_SIZE]; } GdbCmdParseEntry; =20 static inline int startswith(const char *string, const char *pattern) @@ -1481,14 +1483,14 @@ static int process_string_cmd(void *user_ctx, const= char *data, =20 for (i =3D 0; i < num_cmds; i++) { const GdbCmdParseEntry *cmd =3D &cmds[i]; - g_assert(cmd->handler && cmd->cmd); + g_assert(cmd->handler && *cmd->cmd); =20 if ((cmd->cmd_startswith && !startswith(data, cmd->cmd)) || (!cmd->cmd_startswith && strcmp(cmd->cmd, data))) { continue; } =20 - if (cmd->schema) { + if (*cmd->schema) { schema_len =3D strlen(cmd->schema); if (schema_len % 2) { return -2; --=20 2.26.3