[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH RFC] bunzip: work around gcc13 warning


  • To: George Dunlap <george.dunlap@xxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Wed, 8 Mar 2023 12:02:45 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=82gSJGC8Qmr2D39y8z0eCkXsZwn26/w8AM53seY8BE4=; b=TgfXkluN5QrC1K+sfE1vwum4pzYvtduSvd0vYKegsfxZF8lbUZo+VqgffFI/omHQhVc1HR13xhUZYA2GDJ0pFjWd9q2NzlXz0fQUdg655hdPd0CMBe3jWOtU3FVXH4hRp2IbltoReUtfU0nxx1/8VFo/L4WJKgoHZm8CVZMXZq/m3rJ7nt9FLXys0PTPI8gWZF3lfuwZ1WFBVlOQsk2e7XW7aAKhp9hT96wEo6xb+Mx6eaIIPBtDW3mYaFNoRKjQ8OS6Vt034m4glkWdK6aGkstk53SI2w6f/L8zzcl7bIFfK+BJgHEvxOMJQJInQnPyLaB5Ezuw1V6DHu1jCXriIw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PkUpMfbaaH4UC/Fe/xL6c9ZK7e94koZ2ui5QhYAETX2WaIoaw2AXGgOj0D6nq4G6UpZqbUfndWTRF7mPjwC1GpftEr9Sm/uhRdLnD6CYY9jRB7Al2B3d943moGda5miu9XH8gXz0wTKPJdhU9nfXJ4pdN4D2IlP/nHQquW5lIbo+8so3iIluN7P96QOz1Ta9rwL9li/qLYimU3jewPgHZ42y45N7Tm1JZBpOfAmqVYySte+JyGj9nnUp35IFqzbtgYlJAHEQQ9PWWLw5ETwae0WiL1SRB5qxyKEjiGhLOLo3/06ipK/XKuZ1MbW+mtAPjLxnXj/pAhCauXwZog9Y1A==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>
  • Delivery-date: Wed, 08 Mar 2023 11:03:00 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 08.03.2023 11:37, George Dunlap wrote:
> On Fri, Mar 3, 2023 at 7:29 AM Jan Beulich <jbeulich@xxxxxxxx> wrote:
> 
>> While provable that length[0] is always initialized (because symCount
>> cannot be zero), upcoming gcc13 fails to recognize this and warns about
>> the unconditional use of the value immediately following the loop.
>>
>> See also https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106511.
>>
>> Reported-by: Martin Liška <martin.liska@xxxxxxxx>
>> Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
>> ---
>> RFC: We've cloned this code from Linux and the code is unchanged there.
>>      Therefore the same issue should exist there, and we may better get
>>      whatever workaround is going to be applied there. But I'm unaware
>>      of the issue, so far, having been observed in and reported against
>>      Linux. This may be because they disable the maybe-uninitialized
>>      warning by default, and they re-enable it only when building with
>>      W=2.
>>
>> --- a/xen/common/bunzip2.c
>> +++ b/xen/common/bunzip2.c
>> @@ -233,7 +233,7 @@ static int __init get_next_block(struct
>>                    becomes negative, so an unsigned inequality catches
>>                    it.) */
>>                 t = get_bits(bd, 5)-1;
>> -               for (i = 0; i < symCount; i++) {
>> +               for (length[0] = i = 0; i < symCount; i++) {
>>
> 
> My main comment here is that nobody looking at this code will immediately
> think, "Oh, I bet this is to work around a gcc bug that can't tell that
> length[0] will always be initialized".  I'd put it in a separate line, with
> a comment explaining the situation.

I can certainly do so. The main question though needs answering first:
Are we okay to diverge from Linux here?

Jan



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.