Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp89496imu; Wed, 19 Dec 2018 14:12:42 -0800 (PST) X-Google-Smtp-Source: AFSGD/VPpguQk5HBZ3A5yFweMmdaT3rJqeJChZond7CKJKfRl2391BdzvAGDebutto/I1y02oXQe X-Received: by 2002:a63:6ecf:: with SMTP id j198mr21267344pgc.3.1545257562093; Wed, 19 Dec 2018 14:12:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545257562; cv=none; d=google.com; s=arc-20160816; b=MudKHSIddfF2aY3AU/QwMzsVRX3tiUUu94WD5uFoVrnU+I3WkPfLy4P7C/9LRxWLcS 17IB03aS25YCu+PQupuSa9+uAJhciDR4lFjGspZLxzbyG0A+mPvK5AEfbMML9YOofKdE a0JsFyRhHnTStlLcUHcz/GmhqPzxjm2dBOJpFW/WudaYlN9NxDBWu2jvZWcZvzaTpVzP 0dQOC5uDmFfkdeZFKyyJZ7L7TCcMN7A/V1v//Rb9s5uitNeGM4bDnyHj2Cb6CkSKhIrh Dxo9JC2bQO2EKihOS2qTH+MvmE9p+k2Vg0GcDZYgmSwPRYMqDgnqiQXl/qPvTL7dUnHh TyWQ== 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:subject:cc:to:from:date; bh=JvM6TB/yCnj3o3rnVa9KmUL9ZkFV4FGIUvM7HGY376Y=; b=sW8AgVj/+EG4GUigr0HkHdT3b91EYqDkwWUI3KK2zoZt8c6PSuyjgCZk6eSc5gIRO/ mT7TcWUSIRGS8DplEQyrDVR6zPHOWVroBTlR4kcmPwLjOTExcjqSz/dvHBHSAI0QeZkw 9gjJYJHBHB8gjAt4qqeAlaM3urpb1aA2tok9V97ruMQPT+YFWM/x4RKumbK6l2qdaNxg V/M4pzH4VliEg8lVWeNcdh0Zy7xIiLqtdubJUlBpWjXk7Kq19+ytUJaDoXAxmfHEk4nv npELC/ShvS6Fh2dFhlKKkAewtd6mNeseJH3qATBZoLQlkn1DZGKMSQQ43AxWW6/eFThG 8Fpw== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e66si15822200plb.107.2018.12.19.14.12.26; Wed, 19 Dec 2018 14:12:42 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730064AbeLSUev (ORCPT + 99 others); Wed, 19 Dec 2018 15:34:51 -0500 Received: from mail.kernel.org ([198.145.29.99]:40774 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727818AbeLSUeu (ORCPT ); Wed, 19 Dec 2018 15:34:50 -0500 Received: from gandalf.local.home (cpe-66-24-56-78.stny.res.rr.com [66.24.56.78]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id EFF7220866; Wed, 19 Dec 2018 20:34:48 +0000 (UTC) Date: Wed, 19 Dec 2018 15:34:47 -0500 From: Steven Rostedt To: Joe Perches Cc: Tom Zanussi , 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 Subject: Re: [PATCH 2/7] tracing: Change strlen to sizeof for hist trigger static strings Message-ID: <20181219153447.3684100d@gandalf.local.home> In-Reply-To: References: <20181219144047.49fabfa6@gandalf.local.home> <1545248809.2396.2.camel@kernel.org> <1545250591.4161.2.camel@kernel.org> X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 19 Dec 2018 12:22:38 -0800 Joe Perches wrote: > On Wed, 2018-12-19 at 14:16 -0600, Tom Zanussi wrote: > > > > How's this? > > > > [PATCH] tracing: Introduce and use strcmp_const() for hist triggers > > > > Provide a new strcmp_const() macro and make use of it instead of the > > longer and more error-prone strncmp(str, "str", sizeof("str") - 1). > [] > > diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c > [] > > @@ -22,6 +22,9 @@ > > > > #define STR_VAR_LEN_MAX 32 /* must be multiple of sizeof(u64) */ > > > > +#define strcmp_const(str, str_const) \ > > + strncmp(str, str_const, sizeof(str_const) - 1) > > Not good as it's too easy to pass a pointer as str_const > and sizeof(pointer) - 1 isn't likely the string length. Agreed. And I noticed that this is used all over the kernel, so I'm not going to add this patch. I'm going to add a: #define strncmp_prefix(str, prefix) \ strncmp(str, prefix, strlen(prefix)) in include/linux/string.h And go around and use that throughout the kernel. By doing a quick grep, I already spotted a few bugs. -- Steve