From patchwork Fri Jul 5 15:30:42 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: 810419 Delivered-To: patch@linaro.org Received: by 2002:adf:a199:0:b0:367:895a:4699 with SMTP id u25csp1669882wru; Fri, 5 Jul 2024 08:38:32 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVP9gic7sXKCqQgvzVKcA5uf/hn3Zll2k0hODyXvrOkUqAui4plvGWr63VsM8T3FNLdf3D3cm8Hjo3TDMn0AgC1 X-Google-Smtp-Source: AGHT+IFXmYr06BtIc76uxIAsZqBenc2wJJkXm0Q9dMkioCuWjSWC0YrRt4+e2A6yOdiiYCf3iPPs X-Received: by 2002:ac8:5d50:0:b0:446:3db0:bdbb with SMTP id d75a77b69052e-447cbeede96mr58052581cf.13.1720193911793; Fri, 05 Jul 2024 08:38:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1720193911; cv=none; d=google.com; s=arc-20160816; b=AvoMTFc4/9GhyvjKlcK2fPbFPkbja/A3agUXsIx3cLVdiL4IX37NQsv/48dg+8vJPU QSjyQk7+sCzfVAgp3A/j9t2vlM4/3fIE1Lbi3gaKhOV+xzhPg+VwBqeVAFwkxpf709HJ Jnrcy1CX69Jw0ShI2zCttAd+6ntWt3bqPBnm2UBLiFMrnoRfqd4JkFUZ/xX5A+aDL8lL axrpr2jjPKQbDiur6AR4+EaJMz7NTjbsYoNPJul/VbPnYTzVf1FEzadZ0cR3YZ/4I6m7 X8k9akYNHcV6+23rmDDbMcmsph60hn1+/Z6l8dMq0XV79Z2GnTb87257axr4s6qp/Z7v l5gg== 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=AzZJILDpjzCFS1oa5xiSH1SXLCbMpnINOysIyIIVbec=; fh=8Mm9BQmeLpRTl6qJya1IDznvLrd/qBiwVIi7B51sjeA=; b=Y3AnlKpb6sJGkurlpKaxjxFO1HumqSTwrqCi8wu5N7l9fQHZVGaknHCLeJilXTU253 3iRiub0j73f2tO7tnwgittcFuVAAKidLc69/Qf3mElOtY8bycptpG/77BE8YlXS/Gdxh JMMMr5S6q2mY0ThC53xG2mDgrTWD3ka1+3CzVesCBMw9za3PT9B5g3gxkm2tEm+GYEyE RJlym3ZNFELvQo6n21cceYvwBusmAu3ilg9V/WGW2uqSZaphGHfycElFfJYIngcUxOlx hff2J1IKqagFtNUSlXPtcfV5sfL/xlPx3RzWlQaXPnvDj3q80VRywoZuSnLXqM5ALIKV 0arA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EgeIztKz; 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-4465876aec3si163013371cf.120.2024.07.05.08.38.31 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 05 Jul 2024 08:38:31 -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=EgeIztKz; 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 1sPl0F-00033B-07; Fri, 05 Jul 2024 11:37:39 -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 1sPl04-0002eb-7Z for qemu-devel@nongnu.org; Fri, 05 Jul 2024 11:37:28 -0400 Received: from mail-ed1-x535.google.com ([2a00:1450:4864:20::535]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sPl00-0001JG-BZ for qemu-devel@nongnu.org; Fri, 05 Jul 2024 11:37:27 -0400 Received: by mail-ed1-x535.google.com with SMTP id 4fb4d7f45d1cf-58b447c511eso2387501a12.2 for ; Fri, 05 Jul 2024 08:37:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1720193843; x=1720798643; 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=AzZJILDpjzCFS1oa5xiSH1SXLCbMpnINOysIyIIVbec=; b=EgeIztKz2EHAecYecCkmc1FD4HYzuqcefh/0ypZ53JtnGiVAJa+bcN4PQ2tBtywOR5 K8pQ0k1brxtRbzYHTlkRqkeYrr2WBPag6Lrk4udXlQphWulWKhnnst744wygd2ZnUesf RR0GUx9T3qtyAoU+Jw6KwfZjLrHSOMNKDNrREjDCy2Z8DwSASqbbaeImvO1aNS3DprGR DyG/GX7+NYlLo8KPAOWjnFWdCMrwKKS1WP16c2bMvuk5VXiqveWYLCTNtXatIkQ+aODV u1vHyGzSUyywY4UdZ8Dr/KC/VFldB/NCLkGi06JWessoiwAoJNULMzjLZMygM4zSu8k5 BmiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720193843; x=1720798643; 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=AzZJILDpjzCFS1oa5xiSH1SXLCbMpnINOysIyIIVbec=; b=Csk46In+rMXN3G5Hb4dV3c7Lmr7rYYQFtgTJ9S2LQ5ppnA44t7Bdjrrv+xjtO5i5so Jyisf6K0zIV4XY9BmLP0z+oUMaCRwZ/GyiYU+5nXA3++iAVINhcpKQN2wcyw1HJasx89 ugPixiA4ipSSYlht0eczBXzZf1QWjwXjbrNoFUgy5gtJRHX1mGDIXbNRttVkjaB45vg5 1YGsxIaJZUUdEOPQxH0mKihrsunEfcrNHbT2ZNLemdYSeL2AjvkYfq7yqwC2tNFMztPq oFs7hxGuX/PyiAtPwohdTSw53kkyo+Jq7hjY7SQuKsQVai6Ng3K2x/pVnVFE0i5Bfq75 Ae6w== X-Gm-Message-State: AOJu0Yw2i5oymJAXRptfcV3zljI+Cg30H/6ggP2eMWDtsqjfHRjD122S g5mXFB1I79ZCP6x8rx6aQyGPN43YjCITEwaPGSmL+bGabL0DCGNugh5k7L2iizc= X-Received: by 2002:a17:906:64f:b0:a77:de2a:af00 with SMTP id a640c23a62f3a-a77de2ab225mr27017066b.44.1720193842241; Fri, 05 Jul 2024 08:37:22 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a72aaf638fesm686349366b.68.2024.07.05.08.37.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jul 2024 08:37:20 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id CE3E55F931; Fri, 5 Jul 2024 16:30:55 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Gustavo Romero , =?utf-8?q?Alex_Benn=C3=A9e?= , Richard Henderson , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= Subject: [PULL 30/40] gdbstub: Clean up process_string_cmd Date: Fri, 5 Jul 2024 16:30:42 +0100 Message-Id: <20240705153052.1219696-31-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240705153052.1219696-1-alex.bennee@linaro.org> References: <20240705153052.1219696-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::535; envelope-from=alex.bennee@linaro.org; helo=mail-ed1-x535.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> Signed-off-by: Alex Bennée Message-Id: <20240705084047.857176-31-alex.bennee@linaro.org> 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("");