Skip to contentSkip to conversation

Staging: media: davinci_vpfe: Fix preferred form of passing a size

PATCH Superseded Madhumitha Prabakaran 2 participants 2 messages Mar 22, 2019 – Mar 23, 2019

Subsystems (2)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Staging: media: davinci_vpfe: Fix preferred form of passing a size

Fix perferred form of passing a size of a struct to improve readability and eradicate an opportunity for a bug when the pointer variable type is changed but the corresponding sizeof that is passed to a memory allocator is not.

---
 drivers/staging/media/davinci_vpfe/dm365_ipipe.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/media/davinci_vpfe/dm365_ipipe.c +2 -2
index 3d910b85905c..dc7dde83727e 100644
@@ -1264,7 +1264,7 @@ static int ipipe_s_config(struct v4l2_subdev *sd, struct vpfe_ipipe_config *cfg)
 		module_if = &ipipe_modules[i];
 		from = *(void **)((void *)cfg + module_if->config_offset);
 
-		params = kmalloc(sizeof(struct ipipe_module_params),
+		params = kmalloc(sizeof(*params),
 				 GFP_KERNEL);
 		to = (void *)params + module_if->param_offset;
 		size = module_if->param_size;
@@ -1306,7 +1306,7 @@ static int ipipe_g_config(struct v4l2_subdev *sd, struct vpfe_ipipe_config *cfg)
 		module_if = &ipipe_modules[i];
 		to = *(void **)((void *)cfg + module_if->config_offset);
 
-		params = kmalloc(sizeof(struct ipipe_module_params),
+		params = kmalloc(sizeof(*params),
 				 GFP_KERNEL);
 		from = (void *)params + module_if->param_offset;
 		size = module_if->param_size;
Signature · 1 line
2.17.1
#1 lore raw
Quoted 15 lines · Madhumitha Prabakaran

Fix perferred form of passing a size of a struct to improve readability and eradicate an opportunity for a bug when the pointer variable type is changed but the corresponding sizeof that is passed to a memory allocator is not.

---
 drivers/staging/media/davinci_vpfe/dm365_ipipe.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/media/davinci_vpfe/dm365_ipipe.c +0 -0
index 3d910b85905c..dc7dde83727e 100644

drivers/staging/media/davinci_vpfe/dm365_ipipe.c static int ipipe_s_config(struct v4l2_subdev *sd, struct vpfe_ipipe_config *cfg) · line 1268

Quoted 6 lines
drivers/staging/media/davinci_vpfe/dm365_ipipe.c +1 -1
@@ -1264,7 +1264,7 @@ static int ipipe_s_config(struct v4l2_subdev *sd, struct vpfe_ipipe_config *cfg)
 		module_if = &ipipe_modules[i];
 		from = *(void **)((void *)cfg + module_if->config_offset);
 
-		params = kmalloc(sizeof(struct ipipe_module_params),
+		params = kmalloc(sizeof(*params),
 				 GFP_KERNEL);

Since the line is shorter, you don't need two lines for the kmalloc call anymore. Same in the next case.

julia

Quoted 21 lines
drivers/staging/media/davinci_vpfe/dm365_ipipe.c +1 -2
 		to = (void *)params + module_if->param_offset;
 		size = module_if->param_size;
@@ -1306,7 +1306,7 @@ static int ipipe_g_config(struct v4l2_subdev *sd, struct vpfe_ipipe_config *cfg)
 		module_if = &ipipe_modules[i];
 		to = *(void **)((void *)cfg + module_if->config_offset);
 
-		params = kmalloc(sizeof(struct ipipe_module_params),
+		params = kmalloc(sizeof(*params),
 				 GFP_KERNEL);
 		from = (void *)params + module_if->param_offset;
 		size = module_if->param_size;
--

2.17.1

--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20190322223431.8609-1-madhumithabiw%40gmail.com.
For more options, visit https://groups.google.com/d/optout.