From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966248AbdJRGcb (ORCPT ); Wed, 18 Oct 2017 02:32:31 -0400 Received: from mout.gmx.net ([212.227.17.20]:59635 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753883AbdJRGc3 (ORCPT ); Wed, 18 Oct 2017 02:32:29 -0400 Subject: Re: scripts/checkpatch: Concatenated strings should use spaces between elements To: Joe Perches , Andy Whitcroft Cc: linux-kernel@vger.kernel.org References: <20171017211751.31343-1-xypron.glpk@gmx.de> <1508280192.6530.31.camel@perches.com> <1508286910.6530.38.camel@perches.com> From: Heinrich Schuchardt Message-ID: <88fabf5b-7240-8f89-2c46-38cf29010aa2@gmx.de> Date: Wed, 18 Oct 2017 08:32:19 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <1508286910.6530.38.camel@perches.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-Provags-ID: V03:K0:bh2tt4GBuDG0z/bjIwWEpFIZ9rZuRwQr1xNjANN0vt4bs4cj6i6 nvertTLXYVVW2Bsyv5zYqBgFia1axDlsntiTiKAafUE/cpk4Vw0SlkVovqbAe8z/o45dTsK gbkKZtj4pKbOW6QbbIb5ivy1p7tNnCnzBfRwXJtfi7iCYv1xi7VKc8o/QubjxYXJltB3btz wDb2dz7MBtGYWtPwVzeqg== X-UI-Out-Filterresults: notjunk:1;V01:K0:zcLnJyd5C0A=:8oomtTGSEeNvvXE50XtW4f 4QkgsEoiqd6G14aAoynhqcpduuBUPku26dLxEceianGVl9JiimNuNZHk+n5gyB2Pykrq62IeJ MiSqY/R3VVa80QXNfCkgWkmKb24wDqoPUTKFvwVyRv8Ds+Tvuo2msZqqW7wYRjsURyEn282uw 2gT2D/ATrvi7r7sFYJMn5PGYjt1A6fbbwfZZM9NUJC15HtXpxOeGyeIh4sKRHxiTfRUEfSDvj 5Pw2KYvWa4xvO5wp3KEW1jSvhowjhcLjPMixvIDMQXfArPwnjYhUwlQ7zR6ICemkszifLjk1+ 4F1KqVurnaiCII55umkqy10BgwN4mSzWmlGG82JVExrfsrR6h4Bai1/5w19Ne6Utu/XMxZcbb 7mAdH8HR6N/gboW28yVcL2OBJVcKEBkh2EK11RAnCD8XiSTOueNPrrBAqiJROL5xEKr7h7qrn ghsJxR1kC3hyZ08nnzTq8lTuiztcUzihcS861FOpCpZZkKpcCXpkEM8y0BXCwt8Z6xIEohExt VQuMCbIvmDfo3Oafnwj+ihqEEwPt696A/xywYHoFAFHyL9ECV4Q9xzgsmCun9Yu2Wa9f6n4mx SmOxJ9gdLWUCknosz8lBc1y+vv9DfkJ6Bo4XTiqf7+Kd8risYyStGqCXBZLy/2X41Trws7MuZ O3VulV+x4OcpV2SLkcc1jdsQdYmg+7w6GJEVtzOuT7+mW4HHSvL8xzl2HPIRMKUsHWTDxw3M4 KAgSWAnMlsN4ldQHszq/qi4KuggcuE9LjHuZhSCzvHmpmpQ8yW00+yerjo5yPze8gDzb+9LCy GfsVWP6lRJhO8n/uMT1xM4YJTLIMNv3Kf5L+7pIRIliQrIVllA= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/18/2017 02:35 AM, Joe Perches wrote: > On Wed, 2017-10-18 at 00:58 +0200, Heinrich Schuchardt wrote: >> On 10/18/2017 12:43 AM, Joe Perches wrote: >>> On Tue, 2017-10-17 at 23:17 +0200, Heinrich Schuchardt wrote: >>>> This patch creates a warning (CHECK) >>>> "Concatenated strings should use spaces between elements" > [] >>>> +void foo(void) >>>> +{ >>>> + test(L"\""); >>> >>> In this case, L must be a constant string and you >>> are concatenating L and "\"" >>> >>> >> >> See ISO/IEC 9899:1999 >> >> 6.4.5 String literals >> >> >> A character string literal is a sequence of zero or more multibyte >> characters enclosed in double-quotes, as in "xyz" >> A wide string literal is the same, except prefixed by the >> letter L. >> >> >> L"foo" is a literal of type wchar_t * and not two strings. >> L is a qualifier and not a constant string. >> >> Just like ULL in 10ULL. > > How about trying this: > >>>From 99bd0ab78a810f537e18a24be42379a6af9d5045 Mon Sep 17 00:00:00 2001 > Message-Id: <99bd0ab78a810f537e18a24be42379a6af9d5045.1508286849.git.joe@perches.com> > From: Joe Perches > Date: Tue, 17 Oct 2017 17:11:14 -0700 > Subject: [PATCH] checkpatch: Support wide strings > > Allow prefixing typical strings with L for wide strings > > Signed-off-by: Joe Perches > --- >  scripts/checkpatch.pl | 7 ++++--- >  1 file changed, 4 insertions(+), 3 deletions(-) > > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl > index 359c02b0954e..9f04f803e96b 100755 > --- a/scripts/checkpatch.pl > +++ b/scripts/checkpatch.pl > @@ -393,7 +393,7 @@ our $Binary = qr{(?i)0b[01]+$Int_type?}; >  our $Hex = qr{(?i)0x[0-9a-f]+$Int_type?}; >  our $Int = qr{[0-9]+$Int_type?}; >  our $Octal = qr{0[0-7]+$Int_type?}; > -our $String = qr{"[X\t]*"}; > +our $String = qr{(?:\bL)?"[X\t]*"}; >  our $Float_hex = qr{(?i)0x[0-9a-f]+p-?[0-9]+[fl]?}; >  our $Float_dec = qr{(?i)(?:[0-9]+\.[0-9]*|[0-9]*\.[0-9]+)(?:e-?[0-9]+)?[fl]?}; >  our $Float_int = qr{(?i)[0-9]+e-?[0-9]+[fl]?}; > @@ -5262,13 +5262,14 @@ sub process { >   } >   >  # concatenated string without spaces between elements > - if ($line =~ /$String[A-Z_]/ || $line =~ /[A-Za-z0-9_]$String/) { > + if ($line =~ /$String[A-Z_]/ || > +     ($line =~ /([A-Za-z0-9_]+)$String/ && $1 !~ /^L$/)) { >   CHK("CONCATENATED_STRING", >       "Concatenated strings should use spaces between elements\n" . $herecurr); >   } >   >  # uncoalesced string fragments > - if ($line =~ /$String\s*"/) { > + if ($line =~ /$String\s*L?"/) { >   WARN("STRING_FRAGMENTS", >        "Consecutive strings are generally better as a single string\n" . $herecurr); >   } > --  > 2.10.0.rc2.1.g053435c > > The patch solves my problem. Thank you. Best regards Heinrich