From patchwork Mon Nov 18 02:07:46 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Price X-Patchwork-Id: 3195241 Return-Path: X-Original-To: patchwork-linux-sparse@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 094DDC045B for ; Mon, 18 Nov 2013 02:12:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2E846206B7 for ; Mon, 18 Nov 2013 02:12:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 326E3206B0 for ; Mon, 18 Nov 2013 02:12:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751599Ab3KRCMz (ORCPT ); Sun, 17 Nov 2013 21:12:55 -0500 Received: from dmz-mailsec-scanner-3.mit.edu ([18.9.25.14]:45851 "EHLO dmz-mailsec-scanner-3.mit.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751377Ab3KRCMz (ORCPT ); Sun, 17 Nov 2013 21:12:55 -0500 X-Greylist: delayed 300 seconds by postgrey-1.27 at vger.kernel.org; Sun, 17 Nov 2013 21:12:55 EST X-AuditID: 1209190e-b7efb6d000000bb9-81-528976795aa5 Received: from mailhub-auth-2.mit.edu ( [18.7.62.36]) (using TLS with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by dmz-mailsec-scanner-3.mit.edu (Symantec Messaging Gateway) with SMTP id 9C.99.03001.97679825; Sun, 17 Nov 2013 21:07:53 -0500 (EST) Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11]) by mailhub-auth-2.mit.edu (8.13.8/8.9.2) with ESMTP id rAI27px3021567; Sun, 17 Nov 2013 21:07:51 -0500 Received: from localhost (department-of-alchemy.mit.edu [18.9.64.20]) (authenticated bits=0) (User authenticated as price@ATHENA.MIT.EDU) by outgoing.mit.edu (8.13.8/8.12.4) with ESMTP id rAI27k5j031767; Sun, 17 Nov 2013 21:07:47 -0500 Date: Sun, 17 Nov 2013 21:07:46 -0500 From: Greg Price To: Al Viro , Christopher Li Cc: Joe Perches , Erico Nunes , linux-sparse@vger.kernel.org, dwmw2 , linux-mtd , linux-kernel Subject: [PATCH] Clarify error on directive in macro arguments (Re: [PATCH] jffs2: fix sparse errors: directive in argument list) Message-ID: <20131118020746.GX16018@ringworld.MIT.EDU> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20131118013349.GM13318@ZenIV.linux.org.uk> User-Agent: Mutt/1.5.21 (2010-09-15) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprLKsWRmVeSWpSXmKPExsUixG6noltZ1hlkcPiRnsXElZOZLWbff8xi cXnXHDaL3U3L2C3u3d7PYtHSu4TRomvNIVaL83+PszpweKxYdYXFY+esu+wem1doeWxeUu/x ZdU1Zo/Pm+Q8Nj15yxTAHsVlk5Kak1mWWqRvl8CVcWn3VraCmQIVM/5eY29g/MDTxcjJISFg IrG04QALhC0mceHeerYuRi4OIYHZTBLvZr5gBEkICWxklJj6WAzC/sUo0XBHrYuRg4NFQFXi eZ8qSJhNQEHix/x1zCBhEQEviQPXNUHGMAt8YZR4dL+TCcQRFmhmlGhvbmYGaeAVMJN49eo6 lC0ocXLmE7AjmAW0JG78e8kEMohZQFpi+T8OkDCngIVEZ+chsHNEBVQkppzcxjaBUWAWku5Z SLpnIXQvYGRexSibklulm5uYmVOcmqxbnJyYl5dapGusl5tZopeaUrqJERQLnJJ8Oxi/HlQ6 xCjAwajEw6sR1hkkxJpYVlyZe4hRkoNJSZTXsgQoxJeUn1KZkVicEV9UmpNafIhRgoNZSYTX xB8ox5uSWFmVWpQPk5LmYFES573JYR8kJJCeWJKanZpakFoEk5Xh4FCS4C0pBWoULEpNT61I y8wpQUgzcXCCDOcBGt4PUsNbXJCYW5yZDpE/xagoJc4rBJIQAElklObB9cJS1StGcaBXhHmn glTxANMcXPcroMFMQIOPP28DGVySiJCSamDU+f5tl97FgGX32XpNxAvnJ5nWnKyvNnwcm/ni bEj5XL4FfJOtC/zDD3skP2ixYohmY4rlP5H9ce39N0cctmxvqP7x9Uukk+AvpSufEtwPGxil W0spMIbfZ57xiOGM2mv2n4kF7/Jn193g7L8RnCt89rIql97qHF0+dyab3+/uCsbGfi/8+kiJ pTgj0VCLuag4EQDGV9rGMAMAAA== Sender: linux-sparse-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP [+linux-sparse and Chris] On Mon, Nov 18, 2013 at 01:33:49AM +0000, Al Viro wrote: > On Sun, Nov 17, 2013 at 02:45:05PM -0800, Joe Perches wrote: > > Yes. I think it's a defect in how sparse > > treats string concatenation. > > > > That style [... with printk ...] is pretty common in the kernel sources. > > ... and it's perfectly fine, until somebody starts playing in nasal > daemon country and do that in *macro* arguments. And a nasal daemon > country it is - it's an undefined behaviour. See 6.10.3p11 in C99. > And trying to define a semantics for that gets real ugly real fast. > sparse matches gcc behaviour (I hope), but it warns about such abuses. > It's a defect, all right - one being reported by sparse. Perhaps the following tweak to the error message would make this subtlety clearer? Cheers, Greg From: Greg Price Date: Sun, 17 Nov 2013 17:57:41 -0800 Subject: [PATCH] Clarify error on directive in macro arguments Preprocessor directives in the arguments of a real function are innocuous and in some contexts common. If a developer doesn't realize that a "function" is implemented as a macro, they may mistake this error for a false alarm. See http://www.spinics.net/lists/kernel/msg1636974.html and http://www.spinics.net/lists/kernel/msg1636976.html for an example. Easy enough to clarify that this is a macro, so do it. Signed-off-by: Greg Price Reviewed-by: Josh Triplett --- pre-process.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pre-process.c b/pre-process.c index d521318..db58a97 100644 --- a/pre-process.c +++ b/pre-process.c @@ -204,7 +204,7 @@ static struct token *collect_arg(struct token *prev, int vararg, struct position if (next->pos.newline && match_op(next, '#')) { if (!next->pos.noexpand) { sparse_error(next->pos, - "directive in argument list"); + "directive in macro argument list"); preprocessor_line(stream, p); __free_token(next); /* Free the '#' token */ continue;