Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1210540imu; Wed, 16 Jan 2019 14:53:41 -0800 (PST) X-Google-Smtp-Source: ALg8bN4VM5dGhpGjxWc4pvUZnFJPS6utXJXHWIdkoL4CiqvXo3b0uDyijweAW+jgaGZ83tlCOcWZ X-Received: by 2002:a62:d005:: with SMTP id p5mr12290935pfg.175.1547679221246; Wed, 16 Jan 2019 14:53:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547679221; cv=none; d=google.com; s=arc-20160816; b=q6Q9NNrDadZgdL0ufE4BQ91sj8p19ulTTbStcJYaKU14A070zjpGQ/hu5sH1i6CfBy o381Kb2aACGKoG0rIzji7MQ4e2KykkFJ70VFQv3n1plzNsfnj9551P727bEWN5DwxlL6 y0VFJao8SLHnYK5G6GANjGujGLxss+FmDVMu+DbzS6LbOtbvNgymKWm1vJ59NjeoMDcA q4XUmaM2qv5/SGTZcWVBa3mVOZDTU8zMx0cRZS9fEg+HByQAlDaL7kFKGW+NUY/Wrr2a e/V28AUVv8v7DQ2Rc6UgE4VBjmYatPPzypCVwIzjBWPfCKMjGvJP0dPPiGgINB8nmCyt SA3A== 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:date:cc:to:from:subject:message-id; bh=6tEzYBarheETuWX8SYCXQfNsfgniH9qVvrHadmaWiGw=; b=XRTdwyj7658U8oin0Kv9zc3NNLAcJ7XK1EJgoYfJqEQmcncRB8fi+fYCJxI8dq8nWz XGMJMKrKPwaJlvE1Igv+Tbly41PBeARPpqsPGRcCNKhZMtX0LdwJS2vxrg3sPxs9Fxok ZnPMnPinzYNUz0htUIeefxpiOs4VNMSSFMTL00fMz4i2MKEfUpO2/G07Qe8SLQD9mNNe jSTamPBZWidTRfrZCcupeutqBeHz9qSSt+4QeE6A+tUKjFYk+ECZUZSxWSrWa64vVIiy AclOcQTQswjAAX9Vbpy0RTnJCXzUZZsy+GtwExYrUM0nLK+D69xCAXkgP2LDJ6o7kIhD 63/w== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p15si7476170plq.24.2019.01.16.14.53.25; Wed, 16 Jan 2019 14:53:41 -0800 (PST) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404819AbfAPPux (ORCPT + 99 others); Wed, 16 Jan 2019 10:50:53 -0500 Received: from mga05.intel.com ([192.55.52.43]:59242 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726834AbfAPPux (ORCPT ); Wed, 16 Jan 2019 10:50:53 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Jan 2019 07:50:53 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,486,1539673200"; d="scan'208";a="126520213" Received: from gregmoor-mobl.amr.corp.intel.com ([10.254.11.196]) by orsmga002.jf.intel.com with ESMTP; 16 Jan 2019 07:50:50 -0800 Message-ID: Subject: Re: [PATCH v12 01/16] tracing: Use str_has_prefix() in synth_event_create() From: Tom Zanussi To: Joe Perches , Tom Zanussi , rostedt@goodmis.org Cc: tglx@linutronix.de, mhiramat@kernel.org, namhyung@kernel.org, vedang.patel@intel.com, bigeasy@linutronix.de, joel@joelfernandes.org, mathieu.desnoyers@efficios.com, julia@ni.com, linux-kernel@vger.kernel.org, linux-rt-users@vger.kernel.org Date: Wed, 16 Jan 2019 09:50:49 -0600 In-Reply-To: <7c07519607d08c0afe448a03fb2010bce13cd77f.camel@perches.com> References: <7c07519607d08c0afe448a03fb2010bce13cd77f.camel@perches.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.5 (3.28.5-1.fc28) Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Joe, On Tue, 2019-01-15 at 20:59 -0800, Joe Perches wrote: > On Tue, 2019-01-15 at 16:05 -0600, Tom Zanussi wrote: > > Since we now have a str_has_prefix() that returns the length, we > > can > > use that instead of explicitly calculating it. > > [] > > diff --git a/kernel/trace/trace_events_hist.c > > b/kernel/trace/trace_events_hist.c > > [] > > @@ -1200,8 +1200,7 @@ static int synth_event_create(int argc, const > > char **argv) > > > > /* This interface accepts group name prefix */ > > if (strchr(name, '/')) { > > - len = sizeof(SYNTH_SYSTEM "/") - 1; > > - if (strncmp(name, SYNTH_SYSTEM "/", len)) > > + if ((len = str_has_prefix(name, SYNTH_SYSTEM "/")) == > > 0) > > Since this is a single test, and not multiple if/else if > blocks, I believe this would read better on two lines > > len = str_has_prefix(name, SYNTH_SYSTEM "/"); > if (len == 0) > > > return -EINVAL; > > name += len; > > } > And I was so happy to have finally found a legitimate reason to put an assignment inside an if statement, sigh. OK, I'll change it. ;-) Thanks, Tom