From patchwork Fri Jun 28 12:42:48 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: 808262 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp342027wrr; Fri, 28 Jun 2024 05:46:07 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXbZx76FJwdlzinbBT94J1KqaiSyYNCCKEHgWlUDT1Ud7W+YOleZY4IWZQE8RVyoyd5ZqQGf4IZtF65ktG9U1sR X-Google-Smtp-Source: AGHT+IGlde5Lpt+bD0/i9+voLE1v1KDSMD+d9km4qEIS8IfwIMSEEO9mjwYH2B7p6yGzv8UgJYV5 X-Received: by 2002:a05:622a:a20f:b0:444:f3ce:1552 with SMTP id d75a77b69052e-446556ce388mr22241621cf.34.1719578767152; Fri, 28 Jun 2024 05:46:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719578767; cv=none; d=google.com; s=arc-20160816; b=motRVVrpqfTUrXVgSS6IWFchsxIV51WZ2Y0psjHwdOUgu1hSwEya2x3hLJTa2eR1fD n4pdXcyOeNSyaAi0WVf0ESREOsNuuAat8PRVKRXItqRnza20pBgKH8GogU7srs5w/FrF v0RnW0UTfr+S5s3yDsseMx4ikBIX0aXo6/gsayAA78+6pemvrrKU3h0kGXkL/GQMl3pA zztRXrG+WJii5IqMZ87DxUQCs+N4P/sofroSeTHZEhTM+y9wC2ip9GSicuyu8PptW7OK pVJIyQqcvdxg+A8ieaDLmAukiph0j2lDWxJKWxLyjcZi9ZHVRD6uH8Ccfp9x1ycUEXyv FLbw== 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=sM0rceWGonmSHrbbpeQx+UK29i4a0M/kbqzgulSSnTo=; fh=f05/u3L8SxnQJOoOR/DeDiZV5idUwgWurHbJB0fL01s=; b=U0DwDCfEozpDLfBxs4uwl/ysy2xcmqQKHwFIBNASSYJHGlZ62DJkGmhqQIlvuxdRYL ae3LwnEA4dBx2W7O0oaiPabtFF8boJcco9lQkS0VTfOiaW6ktBiefVxKhNpwyhaVMxou j2PcIOvFT1F1wF3w19+lCKSbX7jRCErBcx014nSGWoSkcmUFkZFbEQ8D0SPQEGH5PqnS d1LcXi8gy5IdYjLwTeszXttv0g0NnDnzqnqw0Vz5c6qBd6deZHpJmWUNKc9SslG+FwmA cHNhPjYXTHZqVxMGDO+WJvJ1WanE7VYsJcS2J4pjNTRGKvwVvOjAJmBNIvoVMKIn8+q4 O/kg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=r2R2omkU; 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 d75a77b69052e-446514d060dsi18378131cf.663.2024.06.28.05.46.06 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 05:46:07 -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=r2R2omkU; 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 1sNAy1-0007Om-Js; Fri, 28 Jun 2024 08:44:41 -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 1sNAwk-0004vX-H6 for qemu-devel@nongnu.org; Fri, 28 Jun 2024 08:43:25 -0400 Received: from mail-ej1-x631.google.com ([2a00:1450:4864:20::631]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sNAwg-0005kB-8z for qemu-devel@nongnu.org; Fri, 28 Jun 2024 08:43:22 -0400 Received: by mail-ej1-x631.google.com with SMTP id a640c23a62f3a-a725282b926so64571666b.0 for ; Fri, 28 Jun 2024 05:43:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719578593; x=1720183393; 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=sM0rceWGonmSHrbbpeQx+UK29i4a0M/kbqzgulSSnTo=; b=r2R2omkUpyJrhyTeOkaGAXij3ywxn2iH1NImZgByvol2DzvAudrYBnharnOHlicALx 2VmCjkQUNYYpY6NCevceHYu5USJ3P5wO2S5FfK2TejJr7ySTlpbP1zHPGFa/w9bs3YiV oCpLECW4H2kL258esVsO0aIlreUtlRMpwCPd6+jqKUurOHYWC3tSPtLaaH1U6LUP8ziI zRyuXYaOBl9ku4gF7qV1vSFEhAVt3/eWFAPaaIbb1Se1oKfpj7Zvyl7sk77Ihmk7F5SU UgjPaA95T5KtwcTpKIMS1ym5HL7eUz7XivySlR0e5DLMht9gf/JfUe5ecLEjEI4ffpI6 kqBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719578593; x=1720183393; 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=sM0rceWGonmSHrbbpeQx+UK29i4a0M/kbqzgulSSnTo=; b=cU6CXXOjmrVPXmQuR/f8UPRAbcXudIQLACIGcZivFg8IAvClYhLrY51I6RLNvOTa+w iQ6lzMcRAVS4PD4sxjWU0b83Q7qxDzzDB+uDB4b52W364q8xBOkfNwppMpKV8jXBno/h LJStK9lIZP+oZG+dKFyFNpjNy+8gDJnVDwKsj6xmTYAcD09LF1EmMKmfxxvR2znb6w5m K42MqxETXlIM16uKS5cM9Z5N/zyFdiwGWB0XF1pJ+/AHuX1mzKEmkVLwRiQVxi4EyxBv GFax5Ap/IuPQM98hpJj1lMkaib7+vjSFaQQGbCAEMrraY91khoAuQBwfAJzsTwMvTtbi H3nA== X-Gm-Message-State: AOJu0YwZE2/gnu/FuVtlMbCn+ozl1FuEZJbcMzfRYOqTrtC/Vwf2d6+F waIlV9i2GqqlCoyLJOaMejaaxv1BYQv3sAxMoBjKR+xAByIKVkfn+5NlLuu4O+U= X-Received: by 2002:a17:907:8688:b0:a72:b34f:beab with SMTP id a640c23a62f3a-a72b34fbffamr84907166b.73.1719578592548; Fri, 28 Jun 2024 05:43:12 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a72b0091016sm51207466b.150.2024.06.28.05.43.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Jun 2024 05:43:09 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 3A0BF5FA3A; Fri, 28 Jun 2024 13:43:00 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: David Hildenbrand , Beraldo Leal , Eduardo Habkost , =?utf-8?q?Alex_Benn=C3=A9e?= , Wainer dos Santos Moschetta , qemu-arm@nongnu.org, Peter Xu , Mads Ynddal , Mahmoud Mandour , Pierrick Bouvier , Laurent Vivier , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Alexandre Iooss , Stefan Hajnoczi , Peter Maydell , Richard Henderson , Thomas Huth , Gustavo Romero Subject: [PATCH 13/23] gdbstub: Clean up process_string_cmd Date: Fri, 28 Jun 2024 13:42:48 +0100 Message-Id: <20240628124258.832466-14-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240628124258.832466-1-alex.bennee@linaro.org> References: <20240628124258.832466-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::631; envelope-from=alex.bennee@linaro.org; helo=mail-ej1-x631.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 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é 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("");