Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2526342imu; Sun, 23 Dec 2018 01:38:12 -0800 (PST) X-Google-Smtp-Source: ALg8bN6/FJZpA+bZVHTfRvgNq6jiKIMdsnsM85I4pK8zybnaseUvnLw6N3yxz6gO0dzjkUBdSoBZ X-Received: by 2002:a65:610d:: with SMTP id z13mr8792503pgu.427.1545557892905; Sun, 23 Dec 2018 01:38:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545557892; cv=none; d=google.com; s=arc-20160816; b=QOWal2cmZPSdGlVCjIajqVtWUcljlJSle5cxbb1/usAhVhuBh5+k+Kn0YkDnXV34CC LvsiIQ08oDd7OfPdup25HmOQT88eE+bm0gFX3k2I1AhM6Mwth/SPoaqafmDyGSl/J5X+ WADUDJIxvxftMQVE8+0ZFWSMnO7rnaQApkYQGbIQp9L9vLgsNhyRP+xLaHllbMSiIR6M pyCuDY8xRlF623J0e8gc+SCs24ckZu/RNZnlFfJibkOWRUOkwPq7AuiD+pL7pgUsSMlt htYeNXBiQvnLLYPsSHFa5Xgna2gFJKK9zwqOMzUcDx8HoaTpn5rh1XQ6sslGHZJLI0vA 26nQ== 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=p17TIOyW3a4GpkRbnRUuD3rHrIfop1dYYvNbC20Sf4M=; b=Vr2ZEMLS71mOCDEyZMtSyCmla+PIa+VZ+UmgOypIxqr1mAq6oIGnBe9XQeM5fI+7YQ FdrcjC0l748BpPHEEksrP4mthlB0dKL0T5S+7sBOR4Bwr338JRttH7eltxhOeMG/gZaM b7Jco9U1ai03P15MgtyznaypoeyyrTvY8nrDbFAsScIxDi6P/F6DTFabk0Kjox7E5rqT k1hTh4fyfNllhNmnNpe4xppbwQ+s5K8jTfRZ341XCrJY9j1zfFPreSoG8uAUIX+vt/Mp 3hsIpKEH0ej9NuuocKa0jbGJRIQE/njq5tdjvtKSvIo5/CBlgFvTDQFNnZ+i9NRWc+H9 v3lw== 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 33si25231941plg.62.2018.12.23.01.37.57; Sun, 23 Dec 2018 01:38:12 -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 S2403887AbeLUXDw (ORCPT + 99 others); Fri, 21 Dec 2018 18:03:52 -0500 Received: from mail.kernel.org ([198.145.29.99]:53010 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387417AbeLUXDv (ORCPT ); Fri, 21 Dec 2018 18:03:51 -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 1CE71218D9; Fri, 21 Dec 2018 23:03:50 +0000 (UTC) Date: Fri, 21 Dec 2018 18:03:48 -0500 From: Steven Rostedt To: Linus Torvalds Cc: Linux List Kernel Mailing , Ingo Molnar , Andrew Morton , Namhyung Kim , Masami Hiramatsu , Joe Perches , Tom Zanussi , Greg Kroah-Hartman Subject: Re: [for-next][PATCH 23/24] string.h: Add strncmp_prefix() helper macro Message-ID: <20181221180348.766f7712@gandalf.local.home> In-Reply-To: References: <20181221175618.968519903@goodmis.org> <20181221175659.208858193@goodmis.org> <20181221144054.20bdeb33@gandalf.local.home> <20181221153526.5e6055ca@gandalf.local.home> <20181221155513.11450ca6@gandalf.local.home> <20181221174816.0ed7af47@gandalf.local.home> 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 Fri, 21 Dec 2018 14:57:13 -0800 Linus Torvalds wrote: > On Fri, Dec 21, 2018 at 2:48 PM Steven Rostedt wrote: > > > > > Your patch actually had them, but in the body of your email you did > > > > > > > #define have_prefix(str, prefix) ({ \ > > > > const char *__pfx = (const char *)prefix; \ > > > > > > which is just completely wrong. > > > > > > Considering your _old_ patch had the exact same bug, I really think > > > you need to start internalizing the whole "macro arguments *have* to > > > be properly protected" thing. > > > > Well, there's less with assignments that can go wrong than with other > > code. That is, there's little that can happen with "int x = arg;" where > > arg is the macro paramater to cause something really nasty. > > What's wrong, Steven? We are miscommunicating here... I was talking about the missing parenthesis on the original patch, which you stated was missing as well. And the original patch didn't have the typecast. > > The assignment is entirely irrelevant. > > The problem is the cast. > > A type cast has a very high priority, and so if you do > > (const char *)prefix > > it breaks completely if you might have something like"a+6" as the argument. > > Think about what if "a" is of type "unsigned long", for example? Yes, when writing the real code, I noticed that the typecast could cause issues without the parenthesis, and added them. The email you are replying to was saying there's not much that can go wrong with: #define MACRO(x) { \ int __p = x; \ I definitely can see something wrong with: #define MACRO(x) { \ int __p = (int)x; \ because exactly what you stated. There's nothing wrong with adding (x) for the first one, but it's unlikely anything will cause it harm. The second one the (x) *is* most definitely required. This is a long winded "I agree with you" ;-) -- Steve