Skip to contentSkip to conversation

greybus: remove unused header variable in gb_operation_message_alloc()

PATCH In review Tom Rix 2 participants 2 messages Jan 28, 2023 Greybus

lore
Share & tools
lore

Tom Rix

author
#0 lore raw

PATCH 1/1 greybus: remove unused header variable in gb_operation_message_alloc()

cppcheck reports
drivers/greybus/operation.c:365:31: style: Variable 'header' is not assigned a value. [unassignedVariable]

 struct gb_operation_msg_hdr *header;
                              ^

header is only used to calculate the size of the messge. This can be done without a variable but rather with calling sizeof() with the struct type.

Fixes dc779229b538 ("greybus: introduce gb_operation_message_init()")
---
 drivers/greybus/operation.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/greybus/operation.c +1 -2
index 8459e9bc0749..9d322fc6531b 100644
@@ -362,8 +362,7 @@ gb_operation_message_alloc(struct gb_host_device *hd, u8 type,
 			   size_t payload_size, gfp_t gfp_flags)
 {
 	struct gb_message *message;
-	struct gb_operation_msg_hdr *header;
-	size_t message_size = payload_size + sizeof(*header);
+	size_t message_size = payload_size + sizeof(struct gb_operation_msg_hdr);
 
 	if (message_size > hd->buffer_size_max) {
 		dev_warn(&hd->dev, "requested message size too big (%zu > %zu)\n",
Signature · 1 line
2.26.3
maintainer
#1 lore raw
Quoted 4 lines · Tom Rix

cppcheck reports
drivers/greybus/operation.c:365:31: style: Variable 'header' is not assigned a value. [unassignedVariable]

 struct gb_operation_msg_hdr *header;
                              ^

That's not a real problem.

Quoted 4 lines

header is only used to calculate the size of the messge. This can be done without a variable but rather with calling sizeof() with the struct type.

Fixes dc779229b538 ("greybus: introduce gb_operation_message_init()")

This is not a bug that is being fixed.

Quoted 10 lines
---
 drivers/greybus/operation.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/greybus/operation.c +0 -0
index 8459e9bc0749..9d322fc6531b 100644

drivers/greybus/operation.c gb_operation_message_alloc(struct gb_host_device *hd, u8 type, · line 365

Quoted 6 lines
drivers/greybus/operation.c +1 -2
@@ -362,8 +362,7 @@ gb_operation_message_alloc(struct gb_host_device *hd, u8 type,
 			   size_t payload_size, gfp_t gfp_flags)
 {
 	struct gb_message *message;
-	struct gb_operation_msg_hdr *header;
-	size_t message_size = payload_size + sizeof(*header);
+	size_t message_size = payload_size + sizeof(struct gb_operation_msg_hdr);

The compiler does not use any extra room for header, so this should be fine, it's not a real issue.

cppcheck almost never finds anything real, be careful...

thanks,

greg k-h