From patchwork Tue Jun 20 10:35:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simone Ballarin X-Patchwork-Id: 13285637 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0C06BC0015E for ; Tue, 20 Jun 2023 11:01:59 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.551555.861210 (Exim 4.92) (envelope-from ) id 1qBZ75-0001AM-Qp; Tue, 20 Jun 2023 11:01:31 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 551555.861210; Tue, 20 Jun 2023 11:01:31 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qBZ75-00015l-Gm; Tue, 20 Jun 2023 11:01:31 +0000 Received: by outflank-mailman (input) for mailman id 551555; Tue, 20 Jun 2023 10:35:37 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qBYi1-0004Pq-7O for xen-devel@lists.xenproject.org; Tue, 20 Jun 2023 10:35:37 +0000 Received: from support.bugseng.com (mail.bugseng.com [162.55.131.47]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 314738fd-0f56-11ee-b234-6b7b168915f2; Tue, 20 Jun 2023 12:35:36 +0200 (CEST) Received: from beta.bugseng.com (93-40-74-174.ip37.fastwebnet.it [93.40.74.174]) by support.bugseng.com (Postfix) with ESMTPSA id 506864EE0755; Tue, 20 Jun 2023 12:35:35 +0200 (CEST) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 314738fd-0f56-11ee-b234-6b7b168915f2 From: Simone Ballarin To: xen-devel@lists.xenproject.org Cc: consulting@bugseng.com, Gianluca Luparini , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Stefano Stabellini , Michal Orzel , Xenia Ragiadakou , Ayan Kumar , Simone Ballarin Subject: [XEN PATCH 11/13] xen/vpci: fixed violations of MISRA C:2012 Rule 7.2 Date: Tue, 20 Jun 2023 12:35:03 +0200 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 From: Gianluca Luparini The xen sources contains violations of MISRA C:2012 Rule 7.2 whose headline states: "A "u" or "U" suffix shall be applied to all integer constants that are represented in an unsigned type". I propose to use "U" as a suffix to explicitly state when an integer constant is represented in an unsigned type. Signed-off-by: Simone Ballarin Reviewed-by: Stefano Stabellini --- xen/drivers/vpci/msi.c | 2 +- xen/drivers/vpci/msix.c | 2 +- xen/drivers/vpci/vpci.c | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/xen/drivers/vpci/msi.c b/xen/drivers/vpci/msi.c index 8f2b59e61a..7908a5dac6 100644 --- a/xen/drivers/vpci/msi.c +++ b/xen/drivers/vpci/msi.c @@ -124,7 +124,7 @@ static void cf_check address_hi_write( struct vpci_msi *msi = data; /* Clear and update high part. */ - msi->address &= 0xffffffff; + msi->address &= 0xffffffffU; msi->address |= (uint64_t)val << 32; update_msi(pdev, msi); diff --git a/xen/drivers/vpci/msix.c b/xen/drivers/vpci/msix.c index 25bde77586..d440ffcd81 100644 --- a/xen/drivers/vpci/msix.c +++ b/xen/drivers/vpci/msix.c @@ -531,7 +531,7 @@ static int cf_check msix_write( case PCI_MSIX_ENTRY_UPPER_ADDR_OFFSET: entry->updated = true; - entry->addr &= 0xffffffff; + entry->addr &= 0xffffffffU; entry->addr |= (uint64_t)data << 32; break; diff --git a/xen/drivers/vpci/vpci.c b/xen/drivers/vpci/vpci.c index d73fa76302..3bec9a4153 100644 --- a/xen/drivers/vpci/vpci.c +++ b/xen/drivers/vpci/vpci.c @@ -319,7 +319,7 @@ static void vpci_write_hw(pci_sbdf_t sbdf, unsigned int reg, unsigned int size, static uint32_t merge_result(uint32_t data, uint32_t new, unsigned int size, unsigned int offset) { - uint32_t mask = 0xffffffff >> (32 - 8 * size); + uint32_t mask = 0xffffffffU >> (32 - 8 * size); return (data & ~(mask << (offset * 8))) | ((new & mask) << (offset * 8)); } @@ -402,7 +402,7 @@ uint32_t vpci_read(pci_sbdf_t sbdf, unsigned int reg, unsigned int size) data = merge_result(data, tmp_data, size - data_offset, data_offset); } - return data & (0xffffffff >> (32 - 8 * size)); + return data & (0xffffffffU >> (32 - 8 * size)); } /* @@ -427,7 +427,7 @@ static void vpci_write_helper(const struct pci_dev *pdev, data = merge_result(val, data, size, offset); } - r->write(pdev, r->offset, data & (0xffffffff >> (32 - 8 * r->size)), + r->write(pdev, r->offset, data & (0xffffffffU >> (32 - 8 * r->size)), r->private); }