Skip to contentSkip to conversation

staging:gpib: Fix error message formatting and adjust memory allocation style

PATCH In review Ravi Kumar kairi 3 participants 6 messages Feb 17, 2025 – Feb 19, 2025 Staging

lore
Share & tools
lore
#0 lore raw

cover staging:gpib: Fix error message formatting and adjust memory allocation style

From: Ravi Kumar Kairi <[email protected]>

This patch series includes two minor improvements:
1. Updates the error message format for invalid base I/O addresses to use hexadecimal notation.
2. Changes the memory allocation style for private_data to use pointer dereference rather than hardcoding the struct type. which is perfered by checkpatch.

Ravi Kumar Kairi (2):
staging:gpib:hp_82335: Fix error message format for invalid base IO
address
staging:glib:hp_82335: Refactor kzalloc size calculation to use
pointer dereference

 drivers/staging/gpib/hp_82335/hp82335.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Signature · 1 line
2.48.1
#1 lore raw

PATCH 1/2 staging:gpib:hp_82335: Fix error message format for invalid base IO address

From: Ravi Kumar Kairi <[email protected]>

Updated the error message to correctly format the base IO address using %#x instead of %u, ensuring it is displayed with a leading '0x'.

---
 drivers/staging/gpib/hp_82335/hp82335.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/gpib/hp_82335/hp82335.c +1 -1
index 451d5dc6d3..f1c2045570 100644
@@ -274,7 +274,7 @@ static int hp82335_attach(gpib_board_t *board, const gpib_board_config_t *config
 	case 0xfc000:
 		break;
 	default:
-		pr_err("hp82335: invalid base io address 0x%u\n", config->ibbase);
+		pr_err("hp82335: invalid base io address 0x%#x\n", config->ibbase);
 		return -EINVAL;
 	}
 	if (!request_mem_region(upper_iomem_base, hp82335_upper_iomem_size, "hp82335")) {
Signature · 1 line
2.48.1
#2 lore raw

PATCH 2/2 staging:glib:hp_82335: Refactor kzalloc size calculation to use pointer dereference

In reply to Ravi Kumar kairi

From: Ravi Kumar Kairi <[email protected]>

Replaced sizeof(struct hp82335_priv) with sizeof(*board->private_data) *as checkpatch* suggested.

---
 drivers/staging/gpib/hp_82335/hp82335.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/gpib/hp_82335/hp82335.c +1 -1
index f1c2045570..66557d6964 100644
@@ -205,7 +205,7 @@ static gpib_interface_t hp82335_interface = {
 
 static int hp82335_allocate_private(gpib_board_t *board)
 {
-	board->private_data = kzalloc(sizeof(struct hp82335_priv), GFP_KERNEL);
+	board->private_data = kzalloc(sizeof(*board->private_data), GFP_KERNEL);
 	if (!board->private_data)
 		return -1;
 	return 0;
Signature · 1 line
2.48.1
#3 lore raw

Re: [PATCH 2/2] [PATCH 2/2] staging:glib:hp_82335: Refactor kzalloc size calculation to use pointer dereference

Quoted 15 lines · Ravi Kumar kairi

From: Ravi Kumar Kairi <[email protected]>

Replaced sizeof(struct hp82335_priv) with sizeof(*board->private_data) *as checkpatch* suggested.

---
 drivers/staging/gpib/hp_82335/hp82335.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/gpib/hp_82335/hp82335.c +0 -0
index f1c2045570..66557d6964 100644

drivers/staging/gpib/hp_82335/hp82335.c static gpib_interface_t hp82335_interface = { · line 208

Quoted 5 lines
drivers/staging/gpib/hp_82335/hp82335.c +1 -1
@@ -205,7 +205,7 @@ static gpib_interface_t hp82335_interface = {
 
 static int hp82335_allocate_private(gpib_board_t *board)
 {
-	board->private_data = kzalloc(sizeof(struct hp82335_priv), GFP_KERNEL);
+	board->private_data = kzalloc(sizeof(*board->private_data), GFP_KERNEL);

No, this doesn't work. board->private_data is a void pointer.

I recently wrote a Smatch check for this kind of bug, but I was letting someone send all the fixes before I publish it.

regards,
dan carpenter

maintainer
#4 lore raw
In reply to Ravi Kumar kairi
Quoted 7 lines · Ravi Kumar kairi

From: Ravi Kumar Kairi <[email protected]>

This patch series includes two minor improvements:
1. Updates the error message format for invalid base I/O addresses to use hexadecimal notation.
2. Changes the memory allocation style for private_data to use pointer dereference rather than hardcoding the struct type. which is perfered by checkpatch.

Quoted 13 lines

Ravi Kumar Kairi (2):
staging:gpib:hp_82335: Fix error message format for invalid base IO
address
staging:glib:hp_82335: Refactor kzalloc size calculation to use
pointer dereference

 drivers/staging/gpib/hp_82335/hp82335.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Signature · 1 line
2.48.1

No longer applies to my tree :(

#5 lore raw
Quoted 17 lines · Greg KH
Quoted 16 lines · Ravi Kumar kairi

From: Ravi Kumar Kairi <[email protected]>

This patch series includes two minor improvements:
1. Updates the error message format for invalid base I/O addresses to use hexadecimal notation.
2. Changes the memory allocation style for private_data to use pointer dereference rather than hardcoding the struct type. which is perfered by checkpatch.

Ravi Kumar Kairi (2):
staging:gpib:hp_82335: Fix error message format for invalid base IO
address
staging:glib:hp_82335: Refactor kzalloc size calculation to use
pointer dereference

 drivers/staging/gpib/hp_82335/hp82335.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 6 lines
Quoted 4 lines
Signature · 1 line
2.48.1

No longer applies to my tree :(

yeah, I you applied another patch that fixes same issues, I just noticed it, guess I was late. anyway have a great night/day.

regards,
Ravi