From patchwork Fri Jun 28 05:08:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Gustavo Romero X-Patchwork-Id: 808135 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp194846wrr; Thu, 27 Jun 2024 22:21:49 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCW8rSGP+NCvQg+OLh6D/pOR0I4sS85vfntmXwfdg/psSQBhj42AlIP/R9D1yCJJJs+XVie3/De77eRhDpcVXqW6 X-Google-Smtp-Source: AGHT+IF6KwhiL29Nf53pguoZ3F3TyJIwpFaI9plWbygf1gbITHdC/LS864zlV09Fwz186HFO3WGK X-Received: by 2002:ac8:7d43:0:b0:440:ccb8:af2a with SMTP id d75a77b69052e-444d91cef8fmr174792291cf.12.1719552109623; Thu, 27 Jun 2024 22:21:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719552109; cv=none; d=google.com; s=arc-20160816; b=ubRAJUjZ+KjUFM51+Z+/7jdB19BIw0hoEBMaVb+OI96UDObH7ZO27KoaEwkgGIaKFp P4D2O3ZAHux7dpM1MNjQcx8za5w8YRodjNBYh4UxOURoHD9/h/F0wISspX6NSgjS2LSv a2xAM1nDexwzZUIOjk2LnHPCuF3yrpsH0St4cUmF0N+2d/YMxRfsn4QejEAqynou73ME p4YZ7AjdAioDS3FHvNlYD0QOChTvkqc7PQiVjrDYijYjer0hwIkolOfq9M5mGtywoY5h a4IANAQ9ZueUemTzXJP13I/CzMHtJlGjRSat6pdS7yrQwdgfijkqoz2wxMW6Zh4Bfs+O PJdg== 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=fQSRkfw+DkTHa5KQssXieneufL+rl3wPoA2jkVIsZpk=; b=QwoZZpR+AI6sc9aivhsKDllMYRiB34X5F6JADVttpyt1KOpOhZK39ysjhgcvPfbA0X rOm4LulCh40TKT4JKGMIHJyEvjXTXdgoV1mB8z61Fp5LTv7hC+Bbmv1G0Rw/ow1BVnGW n9k2C3sTov+L5I7tVDTbaVD9U0FzP4WMx0NHvCbGI3OY4TD/250xgP2G5FtxU+r+QRFr +Dl8xpLKKOxDIhDUa7ojnjJpNpdkpoBHj/+I5JTkITxyITVmjC7IOGHTJRWiazd1pXqC ecfVpftCbP0H1iH9S3NlfSTxjd7anf0QNBubl1T1rqci+awRLhQiI0z6CcHzAZ/M2PIW GCUQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Yk+X0SJZ; 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-446512cca58si12082681cf.81.2024.06.27.22.21.49 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 27 Jun 2024 22:21:49 -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=Yk+X0SJZ; 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 1sN42n-0003FV-Ab; Fri, 28 Jun 2024 01:21:09 -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 1sN42h-0003Eg-Ta for qemu-devel@nongnu.org; Fri, 28 Jun 2024 01:21:03 -0400 Received: from mail-pf1-x42f.google.com ([2607:f8b0:4864:20::42f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sN42d-0008CT-Rz for qemu-devel@nongnu.org; Fri, 28 Jun 2024 01:21:03 -0400 Received: by mail-pf1-x42f.google.com with SMTP id d2e1a72fcca58-707f9c3bd02so239873b3a.0 for ; Thu, 27 Jun 2024 22:20:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719552058; x=1720156858; 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=Yk+X0SJZ8gg4IjA8xDZY56fUkAluveEEGPZm7kjqrU7TCV42AHggUObH/vPvyukBp+ fn7bOCThaC2ubnv99YPfczpKsUhBaVtdDsaw40jQk4OM6W8pZwTdKUqYCIfOc9LlADWu 5KA2CjovvZRcRrBvEuIJGMk1w9geWAumSgOSHmrOiZjCKkr+Ng5CuIv++ufg/+R/hXgX EPv8Yo8ecbE/ObwqX2MmJ3mbggxC0oVMSMC92Z/b8bc9bOnISO96z9048wQAGWv8OalC hKlMedGBS0e7RHp0Eedm9/RrhwpY4L93ZhDo7eRJbcfTv5ZwehUnQVBbKL6cYLGgkRxT hGww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719552058; x=1720156858; 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=SZ/s6hVJHnOk3j5Z/VQG5YW5J874KQvZXvXvyLg0w2VsNlWe5USMn4irW+I8cVQMsv 8qk1drsmYzzQZ+gNjHPe1AUUhzUedO2Jzow2X4csXrKshzhv36BK8bRaPUHcVOerQB9K XJPG69C3DV4Z0B27Ji+aecIDaI7njDmAuMGs3AdtH6tmzrk40ltZz4sQUJDP/Qayto1z WhFc+xIGjKPfHAxK/g4npq/b1q7xD2MBLjl4xFrI+XOlzEXteY694KqQBZaggorD65jL 218rakME+olLGp3fZmW3H9WrbWeDCE+OeN2f/LBx3fWpQysi5AWEgAFaH2i44POCRt2x rPnQ== X-Gm-Message-State: AOJu0Yxh+w18065FjBCdtFgfdlawJnwRUxaZh8TRE0YvIqJhueoaG4lG rOpVEcPG0YX/J+7ZHfHkd/Gp/00U6ljmGMHc8+i8ooy8xtkp+2tqiyYbj71tkhj15zeVveeLh0K I X-Received: by 2002:a05:6a00:3e1b:b0:705:cade:1f40 with SMTP id d2e1a72fcca58-70674593833mr16412176b3a.11.1719552057744; Thu, 27 Jun 2024 22:20:57 -0700 (PDT) Received: from amd.. ([2804:7f0:b401:391e:3e7c:3fff:fe7a:e83b]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-72c6b2a16cdsm423932a12.46.2024.06.27.22.20.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jun 2024 22:20:57 -0700 (PDT) From: Gustavo Romero To: qemu-devel@nongnu.org, philmd@linaro.org, alex.bennee@linaro.org, richard.henderson@linaro.org Cc: peter.maydell@linaro.org, gustavo.romero@linaro.org Subject: [PATCH v6 01/11] gdbstub: Clean up process_string_cmd Date: Fri, 28 Jun 2024 05:08:40 +0000 Message-Id: <20240628050850.536447-2-gustavo.romero@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240628050850.536447-1-gustavo.romero@linaro.org> References: <20240628050850.536447-1-gustavo.romero@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42f; envelope-from=gustavo.romero@linaro.org; helo=mail-pf1-x42f.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 Reviewed-by: Philippe Mathieu-Daudé --- 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("");