Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp618903ybt; Wed, 17 Jun 2020 09:31:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy7Rbuc423jESc7w2TUKk7hbCQf7Tlv2l2B9ffFVGsUolLJhDR4pipM4et0GDECgIfzGW1a X-Received: by 2002:a17:906:aac8:: with SMTP id kt8mr8548254ejb.460.1592411478950; Wed, 17 Jun 2020 09:31:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592411478; cv=none; d=google.com; s=arc-20160816; b=bJcw7QicI+kEThOungL6uoGGjQVHj5u6Y3nBUkq8qaJ8S4Z96y5a53HeKIGVjnpy/u k7AkSLSAw1alTkW27ddfuM0GBQXHa9Rj/32PG4e9YKfKMIyhUHWdubfdZvWvAWJ75Ga1 y6BRpQwenm+LbOED+BIVcl3VXLATWg6lW0pIpeZx7sVf1KzWAvclQTn8bfkRF+H8x3GO JnvhZ/8QC1+yl/jcofGJIgjuUd+j8Ks3Ehg+npzF0FJItxdR0dNrxOOlh5jLeExB+NGe XruyiRI4QOUt+IeBOdzh/15XzJQ9fptr8tUYrjDLh6E4jOLrUkGdH/KvuqKoPu4weFi7 UDeg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=0hrRgLXuRhMeQ6slbSOKJC3oaC69Z2SF3rsc7qez2XE=; b=dMYFonFkKwG8QLndk6GIv/dVAXLO2ZVNk167S4WHcFxcfbLD7BFMRzertGIha4jxrv XBPGSUjjgis05x/RrrT+an45w+CcuwJr0bXMt/r9kJ1Vi87v+/jqkjbYRMevOKYJ4VHc M0TQpxaC0pdbLesq+x7H2J8WlTBu6d8M7dXFqTWJocPrdyzg+UM7Myn3fDNnXz7rMz5n n0qC+KMw924e7ErV+l0MMgXffU6f//YmqjA3c54GpUNwucQx676dtR7mR/6FPIDXHzUJ QIaCR3xhjgaf1f3XWhIc+Dpc9cW4mgkdC/PHRpJrS5ved1ZVTmZcp85SJ/T5U13IR0uB bpzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=HzvQe3XY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ot10si211077ejb.319.2020.06.17.09.30.53; Wed, 17 Jun 2020 09:31:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=HzvQe3XY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727776AbgFQQ0p (ORCPT + 99 others); Wed, 17 Jun 2020 12:26:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49056 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727069AbgFQQ0b (ORCPT ); Wed, 17 Jun 2020 12:26:31 -0400 Received: from mail-ot1-x344.google.com (mail-ot1-x344.google.com [IPv6:2607:f8b0:4864:20::344]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF7BAC061755 for ; Wed, 17 Jun 2020 09:26:29 -0700 (PDT) Received: by mail-ot1-x344.google.com with SMTP id k15so2089885otp.8 for ; Wed, 17 Jun 2020 09:26:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0hrRgLXuRhMeQ6slbSOKJC3oaC69Z2SF3rsc7qez2XE=; b=HzvQe3XY2utflOg0HvS6MWNBANwSa7sL1NOqNtveiZ8KEicEUoKTea/M6qBwQgmgvu rgz36hkD3lUzeBI9hDQalRU1CKozULtTN/Dw/m7j+Wc/uK7uea+FL+3WUUkIzDR3mj3t lDcwWQhDImnve4Qex48kxHCxQ7L2kbXyM7aecvTcBUUVt44leDClTxIStN+q6SgzkTjv xREsRTM9q2pZFeH5yITwDPZOf1z8VCIVaJKujiDwm3WxgSxrU0Bt/GYvnlDtaRZ7PXl1 4eNosi5+pJA9TXwUAHX9Oye56vwQS4xo/hQMh8HawaltAP7gySGlXLzX3+rtT26CWp1P Dp+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0hrRgLXuRhMeQ6slbSOKJC3oaC69Z2SF3rsc7qez2XE=; b=jkEs9AnxiE9b9kyybSiMYRrCMSHfpCq8ZSovBjbqm/hv1iCDlgo9rjeb3n7Z5BHbzO c0VYPCJbsPihGJKZYECO/HUBsLXmJXzSNFUlZMHMnQcbyASeDDbt7FrbVWBTwn2GaM9A YAYXn0FlKKYH8GZUMds8SI1MRH+nR+JGe4Qpe44Mxzx8QR+TXvDd3TIeev0an1t9ZieS kZ+u0sgUqLYPvXlMmAtZyIcKIUqaheYpCzc1/30IJFOfNRMTE8byB/CgI+q0tkH+iJHO QLnzeTQMz3KLkXEYrO1/MtOq3eJDmc1QhBGf0h6ChSEtxG9D+LCzbnENlrG50sgsK7lQ Cj+Q== X-Gm-Message-State: AOAM533UfGcw/JuyCmh2SRTz8hHMuj+KDqmdkaHfpd4bdxb10Wqta3rH ZpfvOKD/Gvy+q5GBb1M6txM= X-Received: by 2002:a9d:32f7:: with SMTP id u110mr7486878otb.217.1592411189081; Wed, 17 Jun 2020 09:26:29 -0700 (PDT) Received: from frodo.hsd1.co.comcast.net ([2601:284:8204:6ba0::ae4b]) by smtp.googlemail.com with ESMTPSA id h7sm95877otk.48.2020.06.17.09.26.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jun 2020 09:26:28 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, linux-kernel@vger.kernel.org, akpm@linuxfoundation.org, gregkh@linuxfoundation.org Cc: linux@rasmusvillemoes.dk, Jim Cromie Subject: [PATCH v3 17/21] dyndbg: refactor ddebug_read_flags out of ddebug_parse_flags Date: Wed, 17 Jun 2020 10:25:32 -0600 Message-Id: <20200617162536.611386-20-jim.cromie@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200617162536.611386-1-jim.cromie@gmail.com> References: <20200617162536.611386-1-jim.cromie@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Move flag-char reading and validating code to a separate function. This will allow later reuse to read 2 sets of flags: 1- flags to set or clear (after the [=-+] Operator) 2- flags to require or prohibit before changing a callsite's flagstate Signed-off-by: Jim Cromie --- lib/dynamic_debug.c | 37 +++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 22335f7dbac1..8400e4f90b67 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -430,6 +430,26 @@ static int ddebug_parse_query(char *words[], int nwords, return 0; } +static int ddebug_read_flags(const char *str, struct flag_settings *modifiers) +{ + int i; + + for (; *str ; ++str) { + for (i = ARRAY_SIZE(opt_array) - 1; i >= 0; i--) { + if (*str == opt_array[i].opt_char) { + modifiers->flags |= opt_array[i].flag; + break; + } + } + if (i < 0) { + pr_err("unknown flag '%c'\n", *str); + return -EINVAL; + } + } + vpr_info("flags=0x%x\n", modifiers->flags); + return 0; +} + /* * Parse `str' as a flags specification, format [-+=][p]+. * Sets up *maskp and *flagsp to be used when changing the @@ -438,7 +458,7 @@ static int ddebug_parse_query(char *words[], int nwords, */ static int ddebug_parse_flags(const char *str, struct flag_settings *modifiers) { - int op, i; + int op; switch (*str) { case '+': @@ -452,19 +472,8 @@ static int ddebug_parse_flags(const char *str, struct flag_settings *modifiers) } vpr_info("op='%c'\n", op); - for (; *str ; ++str) { - for (i = ARRAY_SIZE(opt_array) - 1; i >= 0; i--) { - if (*str == opt_array[i].opt_char) { - modifiers->flags |= opt_array[i].flag; - break; - } - } - if (i < 0) { - pr_err("unknown flag '%c'\n", *str); - return -EINVAL; - } - } - vpr_info("flags=0x%x\n", modifiers->flags); + if (ddebug_read_flags(str, modifiers)) + return -EINVAL; /* calculate final flags, mask based upon op */ switch (op) { -- 2.26.2