Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp1133528imm; Tue, 5 Jun 2018 09:34:03 -0700 (PDT) X-Google-Smtp-Source: ADUXVKID8pIQ5A4Qc9QmVljzqrt7i/gvi4IzQtgRSVo3vQ+lvrgegdyVwCHvH4doLpnvLNWhX+Bx X-Received: by 2002:a17:902:301:: with SMTP id 1-v6mr27188837pld.127.1528216443704; Tue, 05 Jun 2018 09:34:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528216443; cv=none; d=google.com; s=arc-20160816; b=LhYwzUWPW7Bb95n64a2d4vRSDPJz6ow6xMq3zmIOB5HEvEwh5q5BcYVKkrdWjX0AsJ nTjuCW8OhV3m+YBNzacdPQsl2QjBsR5f8fDXjZK+ksgY54z01dlmck66Vke0vKLLaHCe STuHUYwgHrd3Iis9/jfNWPEtuBTvzdAyh8OvEy53uLYbHKZARoobj19iFrxi/cTHyXbk FUX1mmQ+7qZvigkAkVwStYy6xncl8O/7DKdXSoS1X3I4T7fzpMKjaT70Y49bHsiFc26s xEJTC2nAZUQ/kHiJM2mRLKbcLmx+aEExpuyAB5amEG5lYU3KNz+nge/0nbdESc8gb0mN YCdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=APVrbFjDU+UeseL9AgwPeBoaBJMcoHZ7AVTKWMC6QWw=; b=AH1y3tSPvAY82LOtyxLg5TMA6O13x4eMiQwGObWGW8mZns2BrjO8gcopjFvur8C7RT AvhjP0rYST05DY1tHMo5GuQETqR6GarRCSXpourHJ1lgvh1tqVbWgLJ3HSy40a5IGNtO 81zajms/pulBZWBjEKmZOBbatkZJop8ZTLgPTgIZHNn5k9fERxOH7AaLDITg0ckTLEjc Z90i32LMj1c/BY9yXmaQ1SJoVTYXG0m0p/XWv+1t7Pejr+D/vaN5uG3O2POCziYOCWi7 DZ5QDUhmkdaN72AdkVq37PSAg4hjZVX1FweolnyOn8jomVao4y8ulw1bdIhGDwBPiK05 23Eg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=NhIB0yWs; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id u32-v6si26856759pgn.488.2018.06.05.09.33.48; Tue, 05 Jun 2018 09:34:03 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=NhIB0yWs; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1751864AbeFEQc7 (ORCPT + 99 others); Tue, 5 Jun 2018 12:32:59 -0400 Received: from mail-qt0-f196.google.com ([209.85.216.196]:44470 "EHLO mail-qt0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751539AbeFEQc6 (ORCPT ); Tue, 5 Jun 2018 12:32:58 -0400 Received: by mail-qt0-f196.google.com with SMTP id l33-v6so3056808qta.11 for ; Tue, 05 Jun 2018 09:32:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=APVrbFjDU+UeseL9AgwPeBoaBJMcoHZ7AVTKWMC6QWw=; b=NhIB0yWscarMkbN/4QhQHOotBfnsn7YagwiG9g4t4cqt7UnGmB00uCstwxpbl403Yb qxrY/QXBMLmHYawkiTcdJclNCll/EFnrzeHq9DBd0hdpu8qeG5ycK9qOMFcyyQjL+NdR W2Kb/K/dqGB3QeZS5e8E/D5hecF7A/Wk7NzkbOhCXg/RAAz7yiSNE7VJIPToJY6vG7Hf sInPKRUcHPqa6HUQ41bArX5h9bbn3YcsabnooBprIAE4GY/so7i28IKQHOvd6+pXd+9W ptnPtath4d3VeC6TgLiaix4TSWIzLPixDF1c+QOTmBm75eL0CFi09LMKFQKE5JxhBMzq 5AaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=APVrbFjDU+UeseL9AgwPeBoaBJMcoHZ7AVTKWMC6QWw=; b=Q8SS11yTwDHJ5KYtgAQaAfpnppopPcGXNwxu2gNs1lSI/qeoszZncGrn9jni+VEPGS iCLKSJJLxSjbLMjnLw6RVtDhrfkTz1JZXOuOmnb82rQ/lm1PhVNGH1hJqvuvtqa+VP6L kjBloAKTE308H5RjXRALJCFdfoTLV0/tX4VaxDrfyG55wLlKCCLRhCndP3TcXKkuxeHK eqZoFwRSF12pRHr9vRSdZqzMbeumTFLstg4+oa6hI5M3YtA99CE2doHKmxuD58AxVP5P XE7wFQSeFgkUnIoH2y/FGwD+z20UbXFGe6+ptYqD8i9MpNyhAS/dvxw3gEPIUv0YTFXT 7hyg== X-Gm-Message-State: APt69E2uJ+cus6eDeoKQTKbwniVynWBkIYn72noGIXjS7x1KeOEzcXEa maPPSltFw+ccC+PWqnUXOWn/0RZJMpKsRv4E6Xc= X-Received: by 2002:ac8:32f3:: with SMTP id a48-v6mr23995529qtb.404.1528216377996; Tue, 05 Jun 2018 09:32:57 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a0c:98f9:0:0:0:0:0 with HTTP; Tue, 5 Jun 2018 09:32:57 -0700 (PDT) In-Reply-To: <1526546163-4609-1-git-send-email-xieyisheng1@huawei.com> References: <1526546163-4609-1-git-send-email-xieyisheng1@huawei.com> From: Andy Shevchenko Date: Tue, 5 Jun 2018 19:32:57 +0300 Message-ID: Subject: Re: [PATCH] tracing: use match_string() to simplify the code To: Yisheng Xie Cc: Steven Rostedt , Ingo Molnar , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 17, 2018 at 11:36 AM, Yisheng Xie wrote: > match_string() returns the index of an array for a matching string, > which can be used to simplify the code. > FWIW, Reviewed-by: Andy Shevchenko > Signed-off-by: Yisheng Xie > --- > kernel/trace/trace.c | 15 +++++---------- > 1 file changed, 5 insertions(+), 10 deletions(-) > > diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c > index 414d721..4bd653a 100644 > --- a/kernel/trace/trace.c > +++ b/kernel/trace/trace.c > @@ -4395,8 +4395,7 @@ static int trace_set_options(struct trace_array *tr, char *option) > { > char *cmp; > int neg = 0; > - int ret = -ENODEV; > - int i; > + int ret; > size_t orig_len = strlen(option); > > cmp = strstrip(option); > @@ -4408,16 +4407,12 @@ static int trace_set_options(struct trace_array *tr, char *option) > > mutex_lock(&trace_types_lock); > > - for (i = 0; trace_options[i]; i++) { > - if (strcmp(cmp, trace_options[i]) == 0) { > - ret = set_tracer_flag(tr, 1 << i, !neg); > - break; > - } > - } > - > + ret = match_string(trace_options, -1, cmp); > /* If no option could be set, test the specific tracer options */ > - if (!trace_options[i]) > + if (ret < 0) > ret = set_tracer_option(tr, cmp, neg); > + else > + ret = set_tracer_flag(tr, 1 << ret, !neg); > > mutex_unlock(&trace_types_lock); > > -- > 1.7.12.4 > -- With Best Regards, Andy Shevchenko