From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751616AbbLDADJ (ORCPT ); Thu, 3 Dec 2015 19:03:09 -0500 Received: from smtprelay0111.hostedemail.com ([216.40.44.111]:58051 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751170AbbLDADI (ORCPT ); Thu, 3 Dec 2015 19:03:08 -0500 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::::::::::,RULES_HIT:41:355:379:541:599:973:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1540:1593:1594:1711:1730:1747:1777:1792:2393:2559:2562:2691:2828:3138:3139:3140:3141:3142:3352:3622:3866:3871:3872:3873:3874:4321:5007:6261:7875:10004:10400:10848:11026:11232:11473:11658:11914:12043:12517:12519:12740:13069:13311:13357:13894:14659:21080:30054:30091,0,RBL:error,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:error,Custom_rules:0:0:0,LFtime:2000,LUA_SUMMARY:none X-HE-Tag: bikes05_37cdc368df241 X-Filterd-Recvd-Size: 2144 Message-ID: <1449187382.17296.16.camel@perches.com> Subject: Re: [PATCH v3 04/14] lib/vsprintf.c: expand field_width to 24 bits From: Joe Perches To: Andrew Morton , Andy Shevchenko Cc: Rasmus Villemoes , Kees Cook , Martin Kletzander , Andy Shevchenko , Maurizio Lombardi , Tejun Heo , linux-kernel@vger.kernel.org Date: Thu, 03 Dec 2015 16:03:02 -0800 In-Reply-To: <20151203153407.85761faeab07e7c2fed84e81@linux-foundation.org> References: <1449175873-1780-1-git-send-email-linux@rasmusvillemoes.dk> <1449175873-1780-5-git-send-email-linux@rasmusvillemoes.dk> <1449176047.17296.4.camel@perches.com> <1449178138.15393.161.camel@linux.intel.com> <20151203153407.85761faeab07e7c2fed84e81@linux-foundation.org> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.18.2-0ubuntu2 Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 2015-12-03 at 15:34 -0800, Andrew Morton wrote: > I've been fiddling with a BUILD_BUG_ON which works outside functions > using gcc's __COUNTER__ - something like > > #define BBO(expr) typedef char __bbo##__COUNTER__[1-2*(!!expr)] nit:  you need another parenthesis around expr > BBO(1 == 1); > BBO(2 == 2); > > but that comes out as > > typedef char __bbo__COUNTER__[1-2*(!!1 == 1)]; > typedef char __bbo__COUNTER__[1-2*(!!2 == 2)]; > > instead of > > typedef char __bbo0[1-2*(!!1 == 1)]; > typedef char __bbo1[1-2*(!!2 == 2)]; > > There's some trick here but I've forgotten what it is. I believe it's something like: #define __stringify_2(a, b) a##b #define __stringify2(a, b) __stringify_2(a, b) #define BBO(expr) typedef char __stringify2(bbo, __COUNTER__)[1 - 2*(!!(expr))]