From patchwork Fri Jan 26 14:33:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 766357 Delivered-To: patch@linaro.org Received: by 2002:adf:a314:0:b0:337:62d3:c6d5 with SMTP id c20csp267227wrb; Fri, 26 Jan 2024 06:36:08 -0800 (PST) X-Google-Smtp-Source: AGHT+IFl3ywOysHuDm9h6ePC5K1NA7iUkqfYnPOWwiXHUImSaWcMcIT+raaePSsCpcS2m+n2G7Bb X-Received: by 2002:a05:6214:1c4e:b0:685:9014:93f8 with SMTP id if14-20020a0562141c4e00b00685901493f8mr2061285qvb.38.1706279768030; Fri, 26 Jan 2024 06:36:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1706279768; cv=none; d=google.com; s=arc-20160816; b=W2PU7PXJ+6TyZPSOnZ4yYuvTjsCYYB5t0a+hoWtXpcUMRx2YRk0shdo4DVD3dVlJfq v/v4tVvVshpRoJAN0KFmfp96gkdJXqLl0cm3TFSreS4xBtuEdCdxacdu/e7PuHn5ZTnx n8GVysk9IErRteF0evttJqYeyEVttyozQi3Cao5usSNQtI1JlOXjGPdHkT0LN3YHXFWq 7HcXACKfK/j5tUquOMYcECK3DpalmqlN8TaZI0ivaLtctkvDAxmcXoBEr2R5mEJxLToT plQBpCwRjBUOGjtwKni/p21EAjGrcOgN74kf514lrn6kRKzF3COvwx7gsZ57PKknGljx 9GcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=28nbiWFQ3dXc2wMfXx4/3I1JNB6kABMI1o1Dd2Ej4Ok=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=plbJxezNJZ/zfrKgi9UnvMQ6zm2tZ7tBW9pH+AbJnMksNI0vm3WOMB8ZdFLJhX3yTz B3Vig0wVV5dkNKfo/MdlNndwqxj/xsF+NinDL7U9YQlILTnjenbCP6zcJoAtsLSbpQJI jbbRvJ7zplwjY/xuu4UtufyFKXEKvlfQpAR5+IH9l48gARrkVS13MGdn8Tqw2ECj6i6l ziN6TWvzfgsrKfrCSne7Q7jx2H0ONVHiEaYs9R1BBjqlLv889P7pcvKLL3E4j4dKr/4v WRdXjEy9YJHRgxAzpSctoNxpkb4Gjrh1AvIbi7egAzZ9lLJIHxvfF6L5vwJ0nY44P79P Q0jw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YXVVmRfM; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id gu1-20020a056214260100b006819867ed39si1430869qvb.388.2024.01.26.06.36.07 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 26 Jan 2024 06:36:08 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YXVVmRfM; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rTNHQ-0002fx-Pm; Fri, 26 Jan 2024 09:34:04 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rTNHM-0002T7-RX for qemu-devel@nongnu.org; Fri, 26 Jan 2024 09:34:00 -0500 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rTNHL-0007zT-41 for qemu-devel@nongnu.org; Fri, 26 Jan 2024 09:34:00 -0500 Received: by mail-wr1-x433.google.com with SMTP id ffacd0b85a97d-339289fead2so522702f8f.3 for ; Fri, 26 Jan 2024 06:33:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1706279638; x=1706884438; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=28nbiWFQ3dXc2wMfXx4/3I1JNB6kABMI1o1Dd2Ej4Ok=; b=YXVVmRfMnPNwIz5OvFi1mkRn59oMkASYDDtWUrRnlC34BDVQDHjGIQJlxfALkxm7vL o2xIxZ4hiLn3l+SKPxmRZjaFN/JWKxD28bOKGxUVBZuBaLMZStCDFsKVLxyScOlm5tTy Qe6SM0hsQwYN8p1JHWOV3lv/szQZBRhjSt+2iNra6iHV3EXgTdQE1sjOb15R8NRpj+jk aMYyFWkGEtl9gB8bk8LtJ6jveSl4kHINKtuuEttpwyhvQsKOx5JKp8sxfiCVvpkVM6z6 ZeF9bMGOyITPTc4hFknoZCI+pl5TIHj4Z3Tb3Ob2mQ5CJRZW2zv5hSev246bxSUYXE8J IDbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706279638; x=1706884438; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=28nbiWFQ3dXc2wMfXx4/3I1JNB6kABMI1o1Dd2Ej4Ok=; b=YxzH+YPAu2q48YLDct/41lNmtn9STsPiu5s5QUR853sAiik7mBEJ8Uk1zyej2416Q4 oFwfalG+UezCyGWHlnU8PkvleMFhCQL7xbbz+4xjdAPxTb6DYX+TcfpD8EBGoW9Nw3sY 7QHi76S7vmn6ZEVhj3C8M9gLDUKe4l75/4/sXVkA8/qOiLeFS39SLfxfA8PgKE0d2OaD vNBNX1nTP6QXqEVN/BTt54TljdA5E/fMRgyi4lusXBi22oM8XtHOGg+vAZ2HkOfYNVnq SVrxDLXOmqYYzDc5eVR/I+WRfluzCVculJilwQ0srj1Z3vAaCBOsbWupIWUhcRjTHgs7 BmPg== X-Gm-Message-State: AOJu0Yy4lC36GSOtL1fqTjc/pRCIFw4fSySePI1yLIZjfL/R6l1iJeey P2/4SqU3/amVO0W1jvG0RatiP/5pWT2QrH/jTcl4IQ7wPM3anUa7m0loEfUEiNeORSUjeHSNrA8 2 X-Received: by 2002:adf:f88e:0:b0:337:d649:da70 with SMTP id u14-20020adff88e000000b00337d649da70mr834366wrp.138.1706279637863; Fri, 26 Jan 2024 06:33:57 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id n5-20020a5d4845000000b00337f722e5ccsm1396207wrs.65.2024.01.26.06.33.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jan 2024 06:33:57 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 34/36] bswap.h: Fix const_le64() macro Date: Fri, 26 Jan 2024 14:33:39 +0000 Message-Id: <20240126143341.2101237-35-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240126143341.2101237-1-peter.maydell@linaro.org> References: <20240126143341.2101237-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::433; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x433.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org The const_le64() macro introduced in commit 845d80a8c7b187 turns out to have a bug which means that on big-endian systems the compiler complains if the argument isn't already a 64-bit type. This hasn't caused a problem yet, because there are no in-tree uses, but it means it's not possible for anybody to add one without it failing CI. This example is from an attempted use of it with the argument '0', from the s390 CI runner's gcc: ../block/blklogwrites.c: In function ‘blk_log_writes_co_do_log’: ../include/qemu/bswap.h:148:36: error: left shift count >= width of type [-Werror=shift-count-overflow] 148 | ((((_x) & 0x00000000000000ffU) << 56) | \ | ^~ ../block/blklogwrites.c:409:27: note: in expansion of macro ‘const_le64’ 409 | .nr_entries = const_le64(0), | ^~~~~~~~~~ ../include/qemu/bswap.h:149:36: error: left shift count >= width of type [-Werror=shift-count-overflow] 149 | (((_x) & 0x000000000000ff00U) << 40) | \ | ^~ ../block/blklogwrites.c:409:27: note: in expansion of macro ‘const_le64’ 409 | .nr_entries = const_le64(0), | ^~~~~~~~~~ cc1: all warnings being treated as errors Fix this by making all the constants in the macro have the ULL suffix. This will cause them all to be 64-bit integers, which means the result of the logical & will also be an unsigned 64-bit type, even if the input to the macro is a smaller type, and so the shifts will be in range. Fixes: 845d80a8c7b187 ("qemu/bswap: Add const_le64()") Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Thomas Huth Reviewed-by: Kevin Wolf Reviewed-by: Ira Weiny Message-id: 20240122173735.472951-1-peter.maydell@linaro.org --- include/qemu/bswap.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/include/qemu/bswap.h b/include/qemu/bswap.h index 933a66ee87e..bd67468e5e4 100644 --- a/include/qemu/bswap.h +++ b/include/qemu/bswap.h @@ -145,14 +145,14 @@ CPU_CONVERT(le, 64, uint64_t) */ #if HOST_BIG_ENDIAN # define const_le64(_x) \ - ((((_x) & 0x00000000000000ffU) << 56) | \ - (((_x) & 0x000000000000ff00U) << 40) | \ - (((_x) & 0x0000000000ff0000U) << 24) | \ - (((_x) & 0x00000000ff000000U) << 8) | \ - (((_x) & 0x000000ff00000000U) >> 8) | \ - (((_x) & 0x0000ff0000000000U) >> 24) | \ - (((_x) & 0x00ff000000000000U) >> 40) | \ - (((_x) & 0xff00000000000000U) >> 56)) + ((((_x) & 0x00000000000000ffULL) << 56) | \ + (((_x) & 0x000000000000ff00ULL) << 40) | \ + (((_x) & 0x0000000000ff0000ULL) << 24) | \ + (((_x) & 0x00000000ff000000ULL) << 8) | \ + (((_x) & 0x000000ff00000000ULL) >> 8) | \ + (((_x) & 0x0000ff0000000000ULL) >> 24) | \ + (((_x) & 0x00ff000000000000ULL) >> 40) | \ + (((_x) & 0xff00000000000000ULL) >> 56)) # define const_le32(_x) \ ((((_x) & 0x000000ffU) << 24) | \ (((_x) & 0x0000ff00U) << 8) | \