From patchwork Fri Jul 5 08:40:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 810355 Delivered-To: patch@linaro.org Received: by 2002:adf:a199:0:b0:367:895a:4699 with SMTP id u25csp1507680wru; Fri, 5 Jul 2024 01:42:04 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWGTqww/CsraACT54UG+XwzvkRXEjCdc7SDfH7uh9CubA1ODATLSQkkINISDmeZ3WCLVPxjSXfTiOTy6fZMUH+E X-Google-Smtp-Source: AGHT+IEnIC8NadfL8/LqoGtdLBy8ozlXwh/FwNQ5pA/XS434UukzpTYVKx4y4mYhvmsT6VGhwLY1 X-Received: by 2002:a5d:468b:0:b0:367:9b1c:d2be with SMTP id ffacd0b85a97d-3679dd2acb7mr2566103f8f.20.1720168924718; Fri, 05 Jul 2024 01:42:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1720168924; cv=none; d=google.com; s=arc-20160816; b=iE5389gwAwiyyM8LvVrcrt0W+bC4H50GeTUu61vPanSkJjrcrjRdAWkz+VYVCOLQuG Ub/Xfq4MX2CcUGixq/nVP52eiaw2CcXrK96YKlIRFy8QVlXjBmsrwd/0sGZ2pQ99aOFs 3h1j5mjZItyAL74Bm3rhQ9zAohKsZdSfuw90wKojOvABcwaT7XXJWOSfcs4cHLpZL7Yk mDrs2ZrR6hBwYtZSwkOU7gzE0NG+IdoRUxxRqkY0S9K4LS4+OzGXtmz8IJlSMvXrBJ2G cQ0c0TOMWBULT4z1LjMst/vhzrGTlQWtV28iAfbXgKY5+L4EmU1qDLLcv4ju3RAgKGW4 Mw7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=n7/WIgjhiNKuvbrWJzfyGMGasKiffFNGnc0cAcukpvo=; fh=CmSyVYIEcjWAsoiANsGVn2Fd1yxvvkujSIjgup/cCF4=; b=asMNf/A9CGrikhiAwy6fkD/omIlf2EHmYQuGpTYmGD3EcD3BS5TXnkCs4guuDZ1tTJ 2IEQSi/nuU6QCaQLNh0SJq64hKhq3uvxen25crBY9ZM9KYH0SwOD7Pk3+1dgw1WA/CJ3 NRRyUHjQUKKEaVxcZhMKa4UBpX1s5XKpbkEFT/s4CsXQIFZthghYJbSM0iEVEVpsHLH/ 6VVmaT6Qk9wh+J3vwrm5VCX6xBfdv901f+Za9qHlLyTaRoGJLhMpnFEznKmjHJngk+LM GNw2sjsh18QLGdqcxrnZrSPrXLUtK9Pe2P47Of+62+BE0uyoR14Uu9hXQ40WE5Iso+cn Ktuw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RZ6ju7fI; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id ffacd0b85a97d-36796b4c853si2783981f8f.959.2024.07.05.01.42.04 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 05 Jul 2024 01:42:04 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RZ6ju7fI; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sPeVr-00026K-Sa; Fri, 05 Jul 2024 04:41:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sPeVH-0000B1-Or for qemu-devel@nongnu.org; Fri, 05 Jul 2024 04:41:17 -0400 Received: from mail-ej1-x62b.google.com ([2a00:1450:4864:20::62b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sPeVD-0003Ii-KI for qemu-devel@nongnu.org; Fri, 05 Jul 2024 04:41:14 -0400 Received: by mail-ej1-x62b.google.com with SMTP id a640c23a62f3a-a77baa87743so154559966b.3 for ; Fri, 05 Jul 2024 01:41:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1720168869; x=1720773669; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=n7/WIgjhiNKuvbrWJzfyGMGasKiffFNGnc0cAcukpvo=; b=RZ6ju7fIZhHAnlNc3hviFnG3Ms0Ttx4OC2Hft5JZi4fKYm4lT9/aI3P8NtWkfSmiWe tdfMoLIAJqFUogWXN17FYyhVussQEWzfeFV0Py/bhiCBrhCxezXt1eTjynHgHR92sW5/ aF1ahvzMxuTtwTQlIMABmOj8yBM/3RDU3U2F2mgI40jk1EkVamlJjmQqRfWNC8it06vK h4ItX73KiMZQbAO/xUZcovmTLkpNQHzPm4Z/9TGRT4vZqYzuxaFB8lr7JRe2N+KYxjl/ NL+xDWPhq/ed9rSOEurIiw+T9/1rZNUzaLocK3R1/LT/syjYxgT2AZTt3czk/8V34/L6 N/Bg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720168869; x=1720773669; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=n7/WIgjhiNKuvbrWJzfyGMGasKiffFNGnc0cAcukpvo=; b=Z13JkJELskZHDe0aGeajfY5kItrdaFq+kcSX21qUeJcNK/IUcrh2kzQxBykIVdsrTQ 8gMf+sKU8G2z7GbXw5cH4SSqtdAHmqbXGdXXli01X9M0PLFH41y6yDLV4tzqzlrh2WSm kZCk/Xu6PDe/qLyBIflu4qDkaDktHCsOT0zRrx2Po0fMg5Mq/DX2xqDF6GygtQPXbc9N aaFPdVZUEJvih3VKOztZvyVbX1OoraHgazFuotSaNEmvv/PGiHoJ7OPl5krBGTPXMwEQ VJR3KvOIJDbuGKycHVBmgOmskAnKe9jZvmK16WJrEzqdj0KAGyiqaqneES8I3vqWGNqE ZpNQ== X-Gm-Message-State: AOJu0YwdIOTkXm9zREwi1zjSBec30snT5HL57obU12bB+n70kxWUkXAz 963gC1ZbrC6Ft14bXQIYDK+G5E9RrMosFJuKr1LT5YAFEsi3n3VhReL6o1jjvgY= X-Received: by 2002:a17:906:f296:b0:a77:cdaa:88aa with SMTP id a640c23a62f3a-a77cdaa8b23mr68176466b.4.1720168869010; Fri, 05 Jul 2024 01:41:09 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a72aaf18933sm668677766b.13.2024.07.05.01.40.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jul 2024 01:41:04 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 9461162157; Fri, 5 Jul 2024 09:40:50 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Wainer dos Santos Moschetta , Beraldo Leal , David Hildenbrand , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Pierrick Bouvier , Alexandre Iooss , Thomas Huth , Mahmoud Mandour , Peter Maydell , qemu-arm@nongnu.org, Aleksandar Rikalo , Mads Ynddal , Yanan Wang , Eduardo Habkost , Peter Xu , Richard Henderson , Marcel Apfelbaum , Paul Burton , Stefan Hajnoczi , =?utf-8?q?Alex_Benn=C3=A9e?= , Laurent Vivier , Gustavo Romero Subject: [PATCH v2 30/40] gdbstub: Clean up process_string_cmd Date: Fri, 5 Jul 2024 09:40:37 +0100 Message-Id: <20240705084047.857176-31-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240705084047.857176-1-alex.bennee@linaro.org> References: <20240705084047.857176-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::62b; envelope-from=alex.bennee@linaro.org; helo=mail-ej1-x62b.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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Gustavo Romero Change 'process_string_cmd' to return true on success and false on failure, instead of 0 and -1. Signed-off-by: Gustavo Romero Reviewed-by: Alex Bennée Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Alex Bennée Message-Id: <20240628050850.536447-2-gustavo.romero@linaro.org> --- gdbstub/gdbstub.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index b3574997ea..37314b92e5 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -962,14 +962,14 @@ static inline int startswith(const char *string, const char *pattern) return !strncmp(string, pattern, strlen(pattern)); } -static int process_string_cmd(const char *data, - const GdbCmdParseEntry *cmds, int num_cmds) +static bool process_string_cmd(const char *data, + const GdbCmdParseEntry *cmds, int num_cmds) { int i; g_autoptr(GArray) params = g_array_new(false, true, sizeof(GdbCmdVariant)); if (!cmds) { - return -1; + return false; } for (i = 0; i < num_cmds; i++) { @@ -984,16 +984,16 @@ static int process_string_cmd(const char *data, if (cmd->schema) { if (cmd_parse_params(&data[strlen(cmd->cmd)], cmd->schema, params)) { - return -1; + return false; } } gdbserver_state.allow_stop_reply = cmd->allow_stop_reply; cmd->handler(params, NULL); - return 0; + return true; } - return -1; + return false; } static void run_cmd_parser(const char *data, const GdbCmdParseEntry *cmd) @@ -1007,7 +1007,7 @@ static void run_cmd_parser(const char *data, const GdbCmdParseEntry *cmd) /* In case there was an error during the command parsing we must * send a NULL packet to indicate the command is not supported */ - if (process_string_cmd(data, cmd, 1)) { + if (!process_string_cmd(data, cmd, 1)) { gdb_put_packet(""); } } @@ -1523,9 +1523,9 @@ static void handle_v_commands(GArray *params, void *user_ctx) return; } - if (process_string_cmd(get_param(params, 0)->data, - gdb_v_commands_table, - ARRAY_SIZE(gdb_v_commands_table))) { + if (!process_string_cmd(get_param(params, 0)->data, + gdb_v_commands_table, + ARRAY_SIZE(gdb_v_commands_table))) { gdb_put_packet(""); } } @@ -1889,15 +1889,15 @@ static void handle_gen_query(GArray *params, void *user_ctx) return; } - if (!process_string_cmd(get_param(params, 0)->data, - gdb_gen_query_set_common_table, - ARRAY_SIZE(gdb_gen_query_set_common_table))) { + if (process_string_cmd(get_param(params, 0)->data, + gdb_gen_query_set_common_table, + ARRAY_SIZE(gdb_gen_query_set_common_table))) { return; } - if (process_string_cmd(get_param(params, 0)->data, - gdb_gen_query_table, - ARRAY_SIZE(gdb_gen_query_table))) { + if (!process_string_cmd(get_param(params, 0)->data, + gdb_gen_query_table, + ARRAY_SIZE(gdb_gen_query_table))) { gdb_put_packet(""); } } @@ -1908,13 +1908,13 @@ static void handle_gen_set(GArray *params, void *user_ctx) return; } - if (!process_string_cmd(get_param(params, 0)->data, - gdb_gen_query_set_common_table, - ARRAY_SIZE(gdb_gen_query_set_common_table))) { + if (process_string_cmd(get_param(params, 0)->data, + gdb_gen_query_set_common_table, + ARRAY_SIZE(gdb_gen_query_set_common_table))) { return; } - if (process_string_cmd(get_param(params, 0)->data, + if (!process_string_cmd(get_param(params, 0)->data, gdb_gen_set_table, ARRAY_SIZE(gdb_gen_set_table))) { gdb_put_packet("");