From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753352AbbIYKJN (ORCPT ); Fri, 25 Sep 2015 06:09:13 -0400 Received: from mailout3.w1.samsung.com ([210.118.77.13]:37672 "EHLO mailout3.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752345AbbIYKJL (ORCPT ); Fri, 25 Sep 2015 06:09:11 -0400 X-AuditID: cbfec7f5-f794b6d000001495-4d-56051d442397 Subject: Re: [PATCH] coccinelle: assign signed result to unsigned variable To: SF Markus Elfring References: <1443099286-16559-1-git-send-email-a.hajda@samsung.com> <56041BE5.5010005@users.sourceforge.net> Cc: Bartlomiej Zolnierkiewicz , Gilles Muller , Marek Szyprowski , Michal Marek , Nicolas Palix , kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org, cocci@systeme.lip6.fr From: Andrzej Hajda Message-id: <56051D2B.5040802@samsung.com> Date: Fri, 25 Sep 2015 12:08:43 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-version: 1.0 In-reply-to: <56041BE5.5010005@users.sourceforge.net> Content-type: text/plain; charset=iso-8859-15 Content-transfer-encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrNLMWRmVeSWpSXmKPExsVy+t/xq7ousqxhBr8fq1hsnLGe1eLHptVs Fuc7lzNbzP55icli6y1pi8u75rBZrD1yl91iTussNotjL5czOXB6HDvWyuyxd0uWR9+WVYwe 67dcZfF4tOw+i0fTqXZWj8+b5ALYo7hsUlJzMstSi/TtErgyJu6WKjjDVfF4+We2Bsb5HF2M nBwSAiYSW3dPZoKwxSQu3FvP1sXIxSEksJRRYt6H3+wQznNGiZ2f9rGCVAkLeEl0NL1k7mLk 4BARMJX4cyIEJCwkkCexv2MSK0g9s8BGJolpcxYxgiTYBDQl/m6+yQZi8wpoSbx7sQxsDouA qsTlt7dYQGxRgQiJU2ffQtUISvyYfA8szgk0/8eRJYwgu5gFdCUWbPAACTMLyEtsXvOWeQKj wCwkHbMQqmYhqVrAyLyKUTS1NLmgOCk910ivODG3uDQvXS85P3cTIyQKvu5gXHrM6hCjAAej Eg+vQitLmBBrYllxZe4hRgkOZiUR3qo/QCHelMTKqtSi/Pii0pzU4kOM0hwsSuK8M3e9DxES SE8sSc1OTS1ILYLJMnFwSjUwVqTVfK/IF/EMXn5rUh5T7opLaWG3HJYdXlTyqvBy3QGD6Lqu xqLove2ccZPk4z5x65+xf9FkySoTv/5S5DIXvZkly98umxp+Y2b3TOebtp/lz95TNjqVefQn 4wXbX1titm1/rSPYpC15ceK7PQuT7uQs3rztzmWL7ZO26zH/8N4rP/fVy8bOaCWW4oxEQy3m ouJEACyOAfp+AgAA Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 09/24/2015 05:51 PM, SF Markus Elfring wrote: >> +@rs@ >> +position p; >> +typedef bool, u8, u16, u32, u64, s8, s16, s32, s64; >> +{char, short int, int, long, long long, s8, s16, s32, s64} vs; > Can it matter to specify also the type modifier "signed" in this SmPL approach? > http://coccinelle.lip6.fr/docs/main_grammar005.html#ctype_qualif According to my tests it does not matter. Btw I should replace short int, with short, to allow catch short intergers. > > >> +{unsigned char, unsigned short, unsigned int, unsigned long, unsigned long long, size_t, bool, u8, u16, u32, u64} vu; > How do you think about to reformat such a data type enumeration? If you mean split line to be below 80 chars, OK. > > >> +@@ >> + >> +vu@p = vs >> + >> +@r@ >> +position rs.p; >> +identifier v, f; >> +statement S1, S2; >> +expression e; >> +@@ >> + >> +*v@p = f(...); > Do you try to check here if the value receiver is at the same source code > position from the SmPL rule "rs"? Yes. Generally I want to catch all assignments of signed function result to unsigned var. In this script I have implemented it this way: 1. Look for all assignments 'unsigned = signed' (rs rule). 2. Check if signed from rs rule looks as a function call. Is there better way to do it? Regards Andrzej > > Regards, > Markus >