Skip to contentSkip to conversation

soc: kunpeng_hccs: fix size_t format string

PATCH In review Arnd Bergmann 3 participants 3 messages Aug 12, 2023 – Aug 14, 2023 HiSilicon kunpeng SoC hccs driver

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 soc: kunpeng_hccs: fix size_t format string

From: Arnd Bergmann <[email protected]>

Printing a size_t using the %lu format string causes a warning on architectures that define the type as 'unsigned int':

In file included from include/linux/device.h:15,
from include/linux/acpi.h:14,
from drivers/soc/hisilicon/kunpeng_hccs.c:25:
drivers/soc/hisilicon/kunpeng_hccs.c: In function 'hccs_get_bd_info':
drivers/soc/hisilicon/kunpeng_hccs.c:441:25: error: format '%lu' expects argument of type 'long unsigned int', but argument 3 has type 'size_t' {aka 'unsigned int'} [-Werror=format=]

Use the correct %zu format instead.

Fixes 886bdf9c883bc ("soc: hisilicon: Support HCCS driver on Kunpeng SoC")

---
I've already applied this one on top of the soc/drivers branch after I merged the branch with the new driver and noticed the regression.

 drivers/soc/hisilicon/kunpeng_hccs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/soc/hisilicon/kunpeng_hccs.c +1 -1
index 6864d203c6782..0d6f6bacd3f62 100644
@@ -438,7 +438,7 @@ static int hccs_get_bd_info(struct hccs_dev *hdev, u8 opcode,
 	head = &rsp->rsp_head;
 	if (head->data_len > buf_len) {
 		dev_err(hdev->dev,
-			"buffer overflow (buf_len = %lu, data_len = %u)!\n",
+			"buffer overflow (buf_len = %zu, data_len = %u)!\n",
 			buf_len, head->data_len);
 		return -ENOMEM;
 	}
Signature · 1 line
2.39.2
#1 lore raw

Hi Arnd,

Quoted 28 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

Printing a size_t using the %lu format string causes a warning on architectures that define the type as 'unsigned int':

In file included from include/linux/device.h:15,
from include/linux/acpi.h:14,
from drivers/soc/hisilicon/kunpeng_hccs.c:25:
drivers/soc/hisilicon/kunpeng_hccs.c: In function 'hccs_get_bd_info':
drivers/soc/hisilicon/kunpeng_hccs.c:441:25: error: format '%lu' expects argument of type 'long unsigned int', but argument 3 has type 'size_t' {aka 'unsigned int'} [-Werror=format=]

Use the correct %zu format instead.

Fixes 886bdf9c883bc ("soc: hisilicon: Support HCCS driver on Kunpeng SoC")

---
I've already applied this one on top of the soc/drivers branch after I merged the branch with the new driver and noticed the regression.

 drivers/soc/hisilicon/kunpeng_hccs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/soc/hisilicon/kunpeng_hccs.c +0 -0
index 6864d203c6782..0d6f6bacd3f62 100644

drivers/soc/hisilicon/kunpeng_hccs.c static int hccs_get_bd_info(struct hccs_dev *hdev, u8 opcode, · line 444

Quoted 8 lines
drivers/soc/hisilicon/kunpeng_hccs.c +1 -1
@@ -438,7 +438,7 @@ static int hccs_get_bd_info(struct hccs_dev *hdev, u8 opcode,
 	head = &rsp->rsp_head;
 	if (head->data_len > buf_len) {
 		dev_err(hdev->dev,
-			"buffer overflow (buf_len = %lu, data_len = %u)!\n",
+			"buffer overflow (buf_len = %zu, data_len = %u)!\n",
 			buf_len, head->data_len);
 		return -ENOMEM;
 	}

Thanks!

Best Regards,
Wei

maintainer Acked-by
#2 lore raw

Thanks Arnd,

Quoted 44 lines · Wei Xu

Hi Arnd,

Quoted 28 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

Printing a size_t using the %lu format string causes a warning on architectures that define the type as 'unsigned int':

In file included from include/linux/device.h:15,
from include/linux/acpi.h:14,
from drivers/soc/hisilicon/kunpeng_hccs.c:25:
drivers/soc/hisilicon/kunpeng_hccs.c: In function 'hccs_get_bd_info':
drivers/soc/hisilicon/kunpeng_hccs.c:441:25: error: format '%lu' expects argument of type 'long unsigned int', but argument 3 has type 'size_t' {aka 'unsigned int'} [-Werror=format=]

Use the correct %zu format instead.

Fixes 886bdf9c883bc ("soc: hisilicon: Support HCCS driver on Kunpeng SoC")

---
I've already applied this one on top of the soc/drivers branch after I merged the branch with the new driver and noticed the regression.

  drivers/soc/hisilicon/kunpeng_hccs.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/soc/hisilicon/kunpeng_hccs.c +0 -0
index 6864d203c6782..0d6f6bacd3f62 100644

drivers/soc/hisilicon/kunpeng_hccs.c static int hccs_get_bd_info(struct hccs_dev *hdev, u8 opcode, · line 444

Quoted 8 lines
drivers/soc/hisilicon/kunpeng_hccs.c +1 -1
@@ -438,7 +438,7 @@ static int hccs_get_bd_info(struct hccs_dev *hdev, u8 opcode,
  	head = &rsp->rsp_head;
  	if (head->data_len > buf_len) {
  		dev_err(hdev->dev,
-			"buffer overflow (buf_len = %lu, data_len = %u)!\n",
+			"buffer overflow (buf_len = %zu, data_len = %u)!\n",
  			buf_len, head->data_len);
  		return -ENOMEM;
  	}

Thanks!

Best Regards,
Wei
.