From patchwork Mon Jun 17 06:28:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Gustavo Romero X-Patchwork-Id: 804834 Delivered-To: patch@linaro.org Received: by 2002:adf:fb90:0:b0:360:93e7:1765 with SMTP id a16csp423745wrr; Sun, 16 Jun 2024 23:30:23 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVzrahOcZZ3XvWeyRSYcP0czBZcep929qKdu/fq9Q0h+45CiXupmMwEKh/k10/pVjhW0S/IF10ciE+w81ty/ZTp X-Google-Smtp-Source: AGHT+IFH6+LV46DNU69m9q/1xFoduKR+afIq5PThZ23Kye/uKugxu4/ySo0YgSaFr5tejSaIQI5A X-Received: by 2002:a05:6214:21e9:b0:6b1:e371:99d9 with SMTP id 6a1803df08f44-6b2afd66b39mr118348646d6.8.1718605823664; Sun, 16 Jun 2024 23:30:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1718605823; cv=none; d=google.com; s=arc-20160816; b=qj4ADXbvRgv7mb+JeeGOtQwggRi3lEtSg5kpX2BV9zP9TUJBJ1joi/i9BuT5pYUWS+ uy8T0ahcVgoQRNJVVmRLm2RzzdaBcrcowgXkGCr35YSgd+OpIToexbqpkg+KogOo9c3+ xdOhePU35U90BANZ04ojxeKzitiDE1IisAz5d/nlnI/BOfeZCoz5+TTOOnkZfHgYyDmD Su1XQWRW/Zkjhg1nTzcizwUAow+Go/NaI6XAgWaaUxle1b3yv2+wPX0PuvhaoFLeoIP/ IaLpQ64GXaLe14+3ItAFzOqacFG4WrjNvF6YnMBY16bUjxKUwBcVBxXnaTQBMaR/LTQy YayA== 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=LjO3sCIUBtHps7O0z2KWESgFmJaLDV1pcN1gD8v3XwE=; fh=ZLVo7h1WCYX+mCQET83n+8bPmyNFw4pMQxFlbH8xyms=; b=LxInrSeO7hjX5CCKseAkuI1cya0wlYSpF5z6Fppb9DzSArT9oQ6mEuD8kkICHgkoRh QfzZFJAPKqj4lfG7RhvQ+0AdLTEeSqG21Eh0cBWDpwOXu0JsNp/sVlz/bvfopH+HwSjP GNlerKswdB1KRyQBhgX/fxXsc2IAuNKgFL226qv+62Aj0lsOf7dl+YlwbIzDy/NwHBVI XVLuHiS2l02SSu9NSG+cUFktDT1pz3sU+SDCnZKIcILMwkf4+Ard2Vp/JSgMr3/RL6+s hMn3K+nR5WHoNl69emI6jpFyT5fUuX5jxdNZhAxaNl+o7votZ6+arULHpHCkAcLzlk7i k7ww==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KsrFPOy6; 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 6a1803df08f44-6b2a5afe3d8si96217236d6.203.2024.06.16.23.30.23 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 16 Jun 2024 23:30:23 -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=KsrFPOy6; 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 1sJ5rh-0003lJ-LP; Mon, 17 Jun 2024 02:29:17 -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 1sJ5rg-0003l6-37 for qemu-devel@nongnu.org; Mon, 17 Jun 2024 02:29:16 -0400 Received: from mail-pj1-x102e.google.com ([2607:f8b0:4864:20::102e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sJ5re-0003S6-F5 for qemu-devel@nongnu.org; Mon, 17 Jun 2024 02:29:15 -0400 Received: by mail-pj1-x102e.google.com with SMTP id 98e67ed59e1d1-2bfffa3c748so3283068a91.3 for ; Sun, 16 Jun 2024 23:29:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1718605752; x=1719210552; 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=LjO3sCIUBtHps7O0z2KWESgFmJaLDV1pcN1gD8v3XwE=; b=KsrFPOy6gWSUIE6kjTBOwsAgGcvZQ4tgtMvjUCKM4eXmYcR4YTk44+xtEQMXobU5Hn 571U8p6gYV777wMDqGmXa9Qta75qfV/3arfzX3pmdu8lvGf98oiwHauvZZsS+hAmK1DO ItL3NB5tTv2ulcQHEj8CubxURbrj+tVsg8yESAd2yeTPwWG9W9yzriVll+YJjX2VQQnM i+3F5VNzIpQaQGTTNkt/KPAlFdQBA5XjXTTu/4by8wwh4iMof3ogMDKpWUPRl9/l43A6 +X9SKEjJVBEIKacm9PGk7M01FDfM4A+fUkewp2U6cymMmU1cnZyvWO4amgU3WijmLq8T /+/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718605752; x=1719210552; 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=LjO3sCIUBtHps7O0z2KWESgFmJaLDV1pcN1gD8v3XwE=; b=jcoEP+HsqmOLJp7s3fQ9dOIomdDsGlTkvFRjS9RPL/b/wy4B+gBOgK/wlj7d76DqJ1 NPcClinaHsjTKGWOm/1crPdg5WrBJ6ZIpHdNbEx9Zodh2nGEknI2K8zGXyQK4V6BvcZn EZSaKKx8BtUa6/eyhYFrYY7Dna/Jmg7P+67Xy1feSgHcbyJ8nQl+sfy13pY1iw7A/NsU NowSCn00CUsE/4Sdx/a70cpR3BclEP18PxQI+3hCmx3OTrdJNOUunTPmT9EEumbOytMm +EcJT/8GRX6c/I8dEdw/4eFKwjhzoTG8LYdQBsB4121xfnYsW36vc+CJV1hrGAIf4m1E f6YA== X-Gm-Message-State: AOJu0YwFtKJ08JO+wxwyaGzfm1/f/hyuJJ8QE64C7HUbnGwDXvW+Bq2w n/5KF40yf+h8p6yXEdXFMr+GsE+5XmRk5nDOIOjZEoJPQInZHbT+dD60na8qn5n0gq21Yoo0SfZ L X-Received: by 2002:a17:90b:2288:b0:2c4:ac12:d269 with SMTP id 98e67ed59e1d1-2c4da9d0b32mr8825719a91.0.1718605752289; Sun, 16 Jun 2024 23:29:12 -0700 (PDT) Received: from amd.. ([2804:7f0:b400:8dcb:3e7c:3fff:fe7a:e83b]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2c4a75ed69csm10641863a91.14.2024.06.16.23.29.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 16 Jun 2024 23:29:11 -0700 (PDT) From: Gustavo Romero To: qemu-devel@nongnu.org, philmd@linaro.org, peter.maydell@linaro.org, alex.bennee@linaro.org, richard.henderson@linaro.org Cc: gustavo.romero@linaro.org Subject: [PATCH v3 1/9] gdbstub: Clean up process_string_cmd Date: Mon, 17 Jun 2024 06:28:41 +0000 Message-Id: <20240617062849.3531745-2-gustavo.romero@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240617062849.3531745-1-gustavo.romero@linaro.org> References: <20240617062849.3531745-1-gustavo.romero@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102e; envelope-from=gustavo.romero@linaro.org; helo=mail-pj1-x102e.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, T_SCC_BODY_TEXT_LINE=-0.01 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("");