From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39518) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZhHQN-0006Di-8l for qemu-devel@nongnu.org; Wed, 30 Sep 2015 09:28:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZhHQH-0002Cz-DR for qemu-devel@nongnu.org; Wed, 30 Sep 2015 09:27:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39911) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZhHQH-0002Ci-7d for qemu-devel@nongnu.org; Wed, 30 Sep 2015 09:27:53 -0400 References: <1443558863-26132-1-git-send-email-ehabkost@redhat.com> <1443558863-26132-2-git-send-email-ehabkost@redhat.com> From: Paolo Bonzini Message-ID: <560BE355.60901@redhat.com> Date: Wed, 30 Sep 2015 15:27:49 +0200 MIME-Version: 1.0 In-Reply-To: <1443558863-26132-2-git-send-email-ehabkost@redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 1/2] target-i386: Use 1UL for bit shift List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eduardo Habkost , qemu-devel@nongnu.org Cc: Richard Henderson On 29/09/2015 22:34, Eduardo Habkost wrote: > Fix undefined behavior detected by clang runtime check: > > qemu/target-i386/cpu.c:1494:15: runtime error: > left shift of 1 by 31 places cannot be represented in type 'int' > > While doing that, add extra parenthesis for clarity. > > Reported-by: Peter Maydell > Signed-off-by: Eduardo Habkost > --- > target-i386/cpu.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/target-i386/cpu.c b/target-i386/cpu.c > index 2b914b2..6af6db9 100644 > --- a/target-i386/cpu.c > +++ b/target-i386/cpu.c > @@ -1491,7 +1491,7 @@ static void report_unavailable_features(FeatureWord w, uint32_t mask) > int i; > > for (i = 0; i < 32; ++i) { > - if (1 << i & mask) { > + if ((1UL << i) & mask) { 1U is enough. Paolo ps: Ego ceterum censeo that these warnings are useless and uglify the code unnecessarily. But it looks like I'm in a minority so the patch is okay. > const char *reg = get_register_name_32(f->cpuid_reg); > assert(reg); > fprintf(stderr, "warning: %s doesn't support requested feature: " >