From: Thomas Huth Subject: Re: [kvm-unit-tests PATCH] s390x/intercept: Fix problem with bad compiler warning Date: Tue, 27 Jun 2017 11:03:38 +0200 Message-ID: <5d79acce-1cb8-3b8e-def3-e495f8c91244@redhat.com> References: <1498537095-627-1-git-send-email-thuth@redhat.com> <250f0a2e-0e0f-cdcf-e939-0fbd8a2ef5b2@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Cc: Paolo Bonzini , =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= To: Laurent Vivier , David Hildenbrand , kvm@vger.kernel.org, Drew Jones Return-path: Received: from mx1.redhat.com ([209.132.183.28]:11135 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751629AbdF0JDr (ORCPT ); Tue, 27 Jun 2017 05:03:47 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D0957FEEE7 for ; Tue, 27 Jun 2017 09:03:46 +0000 (UTC) In-Reply-To: Content-Language: en-US Sender: kvm-owner@vger.kernel.org List-ID: On 27.06.2017 10:53, Laurent Vivier wrote: > On 27/06/2017 10:33, Thomas Huth wrote: >> On 27.06.2017 10:24, David Hildenbrand wrote: >>> On 27.06.2017 06:18, Thomas Huth wrote: >>>> The intercept test currently can not be compiled with GCC 4.8 anymore. >>>> It generates the following warning (which is fatal due to -Werror): >>>> >>>> s390x/intercept.c: In function ‘test_stidp’: >>>> s390x/intercept.c:111:9: error: missing initializer for field ‘version’ of ‘struct cpuid’ [-Werror=missing-field-initializers] >>>> struct cpuid id = {}; >>>> ^ >>>> Fix it by using a "0" as intializer here. >>>> >>>> Signed-off-by: Thomas Huth >>>> --- >>>> NB: We could also remove the -Wextra from the CFLAGS instead. IMHO >>>> using -Wextra together with -Werror is just like playing Russian roulette. >>>> Since -Wextra is some kind of "compiler warning playground" for the GCC >>>> folks, you never know which compiler version will trigger an unexpected >>>> (and often also unfounded) warning here, so using this together with -Werror >>>> is just a nuisance. >>> >>> I agree, this is really not deterministic. >>> >>>> >>>> s390x/intercept.c | 2 +- >>>> 1 file changed, 1 insertion(+), 1 deletion(-) >>>> >>>> diff --git a/s390x/intercept.c b/s390x/intercept.c >>>> index 9766289..9fe86cf 100644 >>>> --- a/s390x/intercept.c >>>> +++ b/s390x/intercept.c >>>> @@ -108,7 +108,7 @@ static void test_stap(void) >>>> /* Test the STORE CPU ID instruction */ >>>> static void test_stidp(void) >>>> { >>>> - struct cpuid id = {}; >>>> + struct cpuid id = { 0 }; >>>> >>>> asm volatile ("stidp %0\n" : "+Q"(id)); >>>> report("type set", id.type); >>>> >>> >>> arm and powerpc also use -Wextra, maybe we should remove this then for all. >>> >>> Whatever you prefer. >> >> True ... maybe Drew and Laurent can also comment on whether they like >> -Wextra or not ... if we all agree, then we can remove it, otherwise >> let's try to go with this patch first (in the hope that we won't hit the >> next problem too soon). > > I like -Wextra :) > > My opinion is more checking we have, less error we have. The problem is that -Wextra often produces unfounded or even wrong warnings, like in this case. I'd prefer to add the individual parameters that rather always make sense instead, like -Wtype-limits for example. Thomas