diff mbox series

[v4,03/31] scsi: pm8001: Fix pm8001_update_flash() local variable type

Message ID 20220217132956.484818-4-damien.lemoal@opensource.wdc.com (mailing list archive)
State Superseded
Headers show
Series libsas and pm8001 fixes | expand

Commit Message

Damien Le Moal Feb. 17, 2022, 1:29 p.m. UTC
Change the type of partitionSizeTmp from u32 to __be32 to suppress the
sparse warning:

warning: cast to restricted __be32

Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
---
 drivers/scsi/pm8001/pm8001_ctl.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Jinpu Wang Feb. 17, 2022, 7:03 p.m. UTC | #1
On Thu, Feb 17, 2022 at 2:30 PM Damien Le Moal
<damien.lemoal@opensource.wdc.com> wrote:
>
> Change the type of partitionSizeTmp from u32 to __be32 to suppress the
> sparse warning:
>
> warning: cast to restricted __be32
>
> Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
Reviewed-by: Jack Wang <jinpu.wang@ionos.com>
thx!

> ---
>  drivers/scsi/pm8001/pm8001_ctl.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/scsi/pm8001/pm8001_ctl.c b/drivers/scsi/pm8001/pm8001_ctl.c
> index 66307783c73c..73f036bed128 100644
> --- a/drivers/scsi/pm8001/pm8001_ctl.c
> +++ b/drivers/scsi/pm8001/pm8001_ctl.c
> @@ -721,7 +721,8 @@ static int pm8001_update_flash(struct pm8001_hba_info *pm8001_ha)
>         DECLARE_COMPLETION_ONSTACK(completion);
>         u8              *ioctlbuffer;
>         struct fw_control_info  *fwControl;
> -       u32             partitionSize, partitionSizeTmp;
> +       __be32          partitionSizeTmp;
> +       u32             partitionSize;
>         u32             loopNumber, loopcount;
>         struct pm8001_fw_image_header *image_hdr;
>         u32             sizeRead = 0;
> @@ -742,7 +743,7 @@ static int pm8001_update_flash(struct pm8001_hba_info *pm8001_ha)
>         image_hdr = (struct pm8001_fw_image_header *)pm8001_ha->fw_image->data;
>         while (sizeRead < pm8001_ha->fw_image->size) {
>                 partitionSizeTmp =
> -                       *(u32 *)((u8 *)&image_hdr->image_length + sizeRead);
> +                       *(__be32 *)((u8 *)&image_hdr->image_length + sizeRead);
>                 partitionSize = be32_to_cpu(partitionSizeTmp);
>                 loopcount = DIV_ROUND_UP(partitionSize + HEADER_LEN,
>                                         IOCTL_BUF_SIZE);
> --
> 2.34.1
>
diff mbox series

Patch

diff --git a/drivers/scsi/pm8001/pm8001_ctl.c b/drivers/scsi/pm8001/pm8001_ctl.c
index 66307783c73c..73f036bed128 100644
--- a/drivers/scsi/pm8001/pm8001_ctl.c
+++ b/drivers/scsi/pm8001/pm8001_ctl.c
@@ -721,7 +721,8 @@  static int pm8001_update_flash(struct pm8001_hba_info *pm8001_ha)
 	DECLARE_COMPLETION_ONSTACK(completion);
 	u8		*ioctlbuffer;
 	struct fw_control_info	*fwControl;
-	u32		partitionSize, partitionSizeTmp;
+	__be32		partitionSizeTmp;
+	u32		partitionSize;
 	u32		loopNumber, loopcount;
 	struct pm8001_fw_image_header *image_hdr;
 	u32		sizeRead = 0;
@@ -742,7 +743,7 @@  static int pm8001_update_flash(struct pm8001_hba_info *pm8001_ha)
 	image_hdr = (struct pm8001_fw_image_header *)pm8001_ha->fw_image->data;
 	while (sizeRead < pm8001_ha->fw_image->size) {
 		partitionSizeTmp =
-			*(u32 *)((u8 *)&image_hdr->image_length + sizeRead);
+			*(__be32 *)((u8 *)&image_hdr->image_length + sizeRead);
 		partitionSize = be32_to_cpu(partitionSizeTmp);
 		loopcount = DIV_ROUND_UP(partitionSize + HEADER_LEN,
 					IOCTL_BUF_SIZE);