From patchwork Mon Jun 24 05:30:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Gustavo Romero X-Patchwork-Id: 806994 Delivered-To: patch@linaro.org Received: by 2002:a5d:508d:0:b0:362:4979:7f74 with SMTP id a13csp1731737wrt; Sun, 23 Jun 2024 22:31:55 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCW2bR8Nyf4UjwFpEj+Ayxf9r/faZcBoqkB1WrqM+YgudkKC+MtY5FZtqLzJe9ebbMHYzXsesEsqXMjuw3yORWnI X-Google-Smtp-Source: AGHT+IHRl3lJXUpTdJSAqlfZ+bRFh8/Rz6019PgGa3rQ3a3LTLgYoGFS5NOtMRQ6nWXnoMAXG4h2 X-Received: by 2002:a05:620a:4146:b0:797:d3f7:3d48 with SMTP id af79cd13be357-79be6d0689dmr367753085a.10.1719207115374; Sun, 23 Jun 2024 22:31:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719207115; cv=none; d=google.com; s=arc-20160816; b=DFd62EVj5icZLQWog6O8ouMYBTE4J593VkccC+huU2qfN00cxOs5AZdlIjqLmCEpiu udUGzzATH9O4++GJ+1sOd0vjbNdBmbRBQOrUIpTtTIpF6fTftJ5Jmh6Vq+mVQj21gJ5/ v55B83z3ceJwzxOEDPuGUDQaXSTJoS+fum0hMRnmFFN1wFP3j8KzYhZbonDp1tLt4kwV Qhd17nlMMEDlytp5I6plevrCwnRpJBNdoSaSyHPu4ifgSMKfy85/SRsBcUe7TJx50Hmk x8JPaA5F2fO4OUNT2/Ey3wu6zRhPhyRdXvFnxURAy7RwsNcU0HjFclbTfkVDAnsMRN9E XU2A== 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=PsonJ1zRH/+YC/a6OR7EHJ04b9L1NQ9IXkQt5iZNFyk=; fh=b5q3cJgcc12gnKfUWQQbBLXKRqia4x4Q8oLG+cCF/wU=; b=E1sv68I9bialdDok5q0stydAV88oGu/E9ceAdLxZRdvqO9gVfU4q4zlPixA3G1+dpF HpZhisHNgJWO9jY+iRIVkLsBVq42yvmNZTUIAjxb05z+fm8b7uqMLMwff7aGp3nT5fJ9 btfXXpRohYfFbF7Xlj95VaP098s0vH2aCNUf/Ti+hRy/lzkBZkVkjohBTg9ySTABccaS br1Na1mTbbXd6l5g9LxjyCbFawcsNqyG+O+OJao0mSnOQFm6GLJxty+mYq+PMwJtFLCR a2AZDsGZWqXHEwM/Z9lOf90D2VTma9jVAuFzXbDKBZr8WpcNKKQCOvexu/oJWDkfWjug IJxg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GYIlJMe9; 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 af79cd13be357-79bce8826f3si774783385a.91.2024.06.23.22.31.55 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 23 Jun 2024 22:31:55 -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=GYIlJMe9; 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 1sLcIO-00031o-9N; Mon, 24 Jun 2024 01:31:16 -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 1sLcIL-00031I-EI for qemu-devel@nongnu.org; Mon, 24 Jun 2024 01:31:13 -0400 Received: from mail-il1-x12b.google.com ([2607:f8b0:4864:20::12b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sLcIJ-0004ZO-MV for qemu-devel@nongnu.org; Mon, 24 Jun 2024 01:31:13 -0400 Received: by mail-il1-x12b.google.com with SMTP id e9e14a558f8ab-37636c3872bso6964005ab.3 for ; Sun, 23 Jun 2024 22:31:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719207070; x=1719811870; 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=PsonJ1zRH/+YC/a6OR7EHJ04b9L1NQ9IXkQt5iZNFyk=; b=GYIlJMe9PyzXYLOoThosxLGBwB/5uwpLL/r0yugXgkvS/uu8iFh5Tyk7Xstx38xZWR JdlykFA+swzkVEU90FOmHxqnfEjwgCJ8as+/WpCwjPsm1Var1/yf2WHCpshvzPtEhVH3 NL/EV0pUoWIg+DI+aYbOSPNrRHgvqWP2bqZcR8YbQ/cfsjwfMmhZoGinW5DFn3a3qVHB +/pjql9LXwn9EIh6TDF8MiI6smDjDUXGRIxLr3kber9wJlz9cF4beqa+B1YmM3aCJ51h LF65rS2o2hf976219bk8NoLvBohRlEHIGYBnsJkKIl2mJ0SA63bEvI/+DTAIKqmh9zR6 B4Nw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719207070; x=1719811870; 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=PsonJ1zRH/+YC/a6OR7EHJ04b9L1NQ9IXkQt5iZNFyk=; b=rSGIsw3uoGfaiOU3gJATWXQiAHXIAWCkUI4VQvYB40Wv8x8vk58gPCAuTW2mqUBNai yrlCOg7fwJhYDZVXcS+kx2eLs6KDJ8WUumn+GM9XWGq/9jABOjHff3HIWMmhEkOOQDI5 nOWPowhrteKAp1TIkEUZiEHU0D/sek6kvi9cRf2jK8AvGYkkfo+qzD9LSdLHHj45ko+g cb2hNKUTaYWTufxIM+p4s/DQnRyvjAK0LtUP3VgUTHl+vh4BDjdJzlXzAeVkR7fvldaC ZR+yzKnQYY0o9fqg8vNKRqT64+xghFGz4P0PjC2n+Gnahi0dhhiVMzaeX6EMxLXjjw+f MQtQ== X-Gm-Message-State: AOJu0YwARfDpf2SIwjSEvPx/P0tHsNYQ5zyRhPdArWNbBpTVOeNWWtwi vH/QHFZppzL6elakOOxjm7SFebLUoTDn35JE/R5B5iCYrF/uAbQ45ULO8aMEEJBQLv5wc3aoMbt R2a4= X-Received: by 2002:a92:ca0d:0:b0:374:5a2d:178 with SMTP id e9e14a558f8ab-3763f5adca5mr47915645ab.2.1719207070000; Sun, 23 Jun 2024 22:31:10 -0700 (PDT) Received: from amd.. ([2804:7f0:b401:1758:3e7c:3fff:fe7a:e83b]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-716b4a73183sm3953601a12.39.2024.06.23.22.31.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Jun 2024 22:31:09 -0700 (PDT) From: Gustavo Romero To: qemu-devel@nongnu.org, alex.bennee@linaro.org, richard.henderson@linaro.org Cc: philmd@linaro.org, peter.maydell@linaro.org, gustavo.romero@linaro.org Subject: [PATCH v4 1/9] gdbstub: Clean up process_string_cmd Date: Mon, 24 Jun 2024 05:30:38 +0000 Message-Id: <20240624053046.221802-2-gustavo.romero@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240624053046.221802-1-gustavo.romero@linaro.org> References: <20240624053046.221802-1-gustavo.romero@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::12b; envelope-from=gustavo.romero@linaro.org; helo=mail-il1-x12b.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=ham 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 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 --- 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("");