From nobody Mon Feb 9 03:14:29 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1623668968; cv=none; d=zohomail.com; s=zohoarc; b=P+5jlY46DzneT1V+eXqfBecmin/4FgnM56dgaLrZeIatL7wrAYe7xBcweNDBzaMrUnjMl3oWKPRRb+2UDiDZcGOGW/oo9zoOAzNZJu0SvwC/EYdX7wA6c0sID3oFxyv3OhAQl6xnNGYTZjEqWiesxowRY3PrWJcn4eBPK3yBsTc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1623668968; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=NZ0pwwf2ZwD9iYEMaGaZ2AKkje/4hBntkDNUaj8QzF4=; b=LjD605p9jHcsbMCSprIUHFTQWQcQC3tJvugYNgegLvhhGoRf9aiTArG9wdkd9mT7TC3Ru8OKIesCZfsl+cyah04hiyYRpzvK18BFMbPDfrMHSiHiBvFj2icLgbvLuElRoXgd3517V90zc4CHPsg2grRzRapdkkYo0jNoA0hsoA8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1623668968679603.7846561237156; Mon, 14 Jun 2021 04:09:28 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-51-URjsJEhnNUuvPvNE7h3IOg-1; Mon, 14 Jun 2021 07:09:26 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2A4A78015DB; Mon, 14 Jun 2021 11:09:21 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9FB805C22B; Mon, 14 Jun 2021 11:09:20 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 53C351809CBB; Mon, 14 Jun 2021 11:09:20 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 15EB6SxD017968 for ; Mon, 14 Jun 2021 07:06:28 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6F49E10023B5; Mon, 14 Jun 2021 11:06:28 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.193.46]) by smtp.corp.redhat.com (Postfix) with ESMTP id DAC4510013C1 for ; Mon, 14 Jun 2021 11:06:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623668967; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=NZ0pwwf2ZwD9iYEMaGaZ2AKkje/4hBntkDNUaj8QzF4=; b=KjPPT8JzeAcPR8faifn9DivJ9k3euQfh3bQGTzK+9x/GLzIEO+jgnlTutTDuwDoS8LibAb EOHFwhqcQzOdwUUuSUUDMTRrEAxmliBuAWF94v9to4aQq8eILyuiupV81OB/jrzVfbhUyc vu9aOv4w+wvUMZSlkVu4DyqFmd3H1Fg= X-MC-Unique: URjsJEhnNUuvPvNE7h3IOg-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 3/3] src: Use 1U for bit shifting Date: Mon, 14 Jun 2021 13:06:14 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" In a few places we take 1 and shift it left repeatedly. So much that it won't longer fit into signed integer. The problem is that this is undefined behaviour. Switching to 1U makes us stay within boundaries. Signed-off-by: Michal Privoznik Reviewed-by: Tim Wiederhake --- src/conf/domain_capabilities.h | 2 +- src/cpu/cpu_x86.c | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/conf/domain_capabilities.h b/src/conf/domain_capabilities.h index 69e90893cc..b6433b20c9 100644 --- a/src/conf/domain_capabilities.h +++ b/src/conf/domain_capabilities.h @@ -231,7 +231,7 @@ virDomainCapsCPUModelsGet(virDomainCapsCPUModels *cpuMo= dels, const char *name); =20 #define VIR_DOMAIN_CAPS_ENUM_IS_SET(capsEnum, value) \ - ((capsEnum).values & (1 << value)) + ((capsEnum).values & (1U << value)) =20 #define VIR_DOMAIN_CAPS_ENUM_SET(capsEnum, ...) \ do { \ diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c index a4599499d0..a4792c21da 100644 --- a/src/cpu/cpu_x86.c +++ b/src/cpu/cpu_x86.c @@ -2575,12 +2575,12 @@ cpuidSetLeafD(virCPUData *data, sub1 =3D *cpuid; for (sub =3D 2; sub < 64; sub++) { if (sub < 32 && - !(sub0.eax & (1 << sub)) && - !(sub1.ecx & (1 << sub))) + !(sub0.eax & (1U << sub)) && + !(sub1.ecx & (1U << sub))) continue; if (sub >=3D 32 && - !(sub0.edx & (1 << (sub - 32))) && - !(sub1.edx & (1 << (sub - 32)))) + !(sub0.edx & (1U << (sub - 32))) && + !(sub1.edx & (1U << (sub - 32)))) continue; =20 cpuid->ecx_in =3D sub; @@ -2614,7 +2614,7 @@ cpuidSetLeafResID(virCPUData *data, return -1; =20 for (sub =3D 1; sub < 32; sub++) { - if (!(res & (1 << sub))) + if (!(res & (1U << sub))) continue; cpuid->ecx_in =3D sub; cpuidCall(cpuid); --=20 2.31.1