* [PATCH v2] Staging: media: davinci_vpfe: Fix preferred form of passing a size
@ 2019-03-25 14:59 Madhumitha Prabakaran
2019-03-25 15:21 ` [Outreachy kernel] " Julia Lawall
0 siblings, 1 reply; 2+ messages in thread
From: Madhumitha Prabakaran @ 2019-03-25 14:59 UTC (permalink / raw
To: mchehab, gregkh, outreachy-kernel; +Cc: 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.
Signed-off-by: Madhumitha Prabakaran <madhumithabiw@gmail.com>
---
drivers/staging/media/davinci_vpfe/dm365_ipipe.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/staging/media/davinci_vpfe/dm365_ipipe.c b/drivers/staging/media/davinci_vpfe/dm365_ipipe.c
index 3d910b85905c..30e2edc0cec5 100644
--- a/drivers/staging/media/davinci_vpfe/dm365_ipipe.c
+++ b/drivers/staging/media/davinci_vpfe/dm365_ipipe.c
@@ -1264,8 +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),
- GFP_KERNEL);
+ params = kmalloc(sizeof(*params), GFP_KERNEL);
to = (void *)params + module_if->param_offset;
size = module_if->param_size;
@@ -1306,8 +1305,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),
- GFP_KERNEL);
+ params = kmalloc(sizeof(*params), GFP_KERNEL);
from = (void *)params + module_if->param_offset;
size = module_if->param_size;
--
2.17.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Outreachy kernel] [PATCH v2] Staging: media: davinci_vpfe: Fix preferred form of passing a size
2019-03-25 14:59 [PATCH v2] Staging: media: davinci_vpfe: Fix preferred form of passing a size Madhumitha Prabakaran
@ 2019-03-25 15:21 ` Julia Lawall
0 siblings, 0 replies; 2+ messages in thread
From: Julia Lawall @ 2019-03-25 15:21 UTC (permalink / raw
To: Madhumitha Prabakaran; +Cc: mchehab, gregkh, outreachy-kernel
On Mon, 25 Mar 2019, Madhumitha Prabakaran wrote:
> 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.
You need to say what is new in v2. You can make a v3 that explains that,
and also fix up the spelling of preferred.
julia
>
> Signed-off-by: Madhumitha Prabakaran <madhumithabiw@gmail.com>
> ---
> drivers/staging/media/davinci_vpfe/dm365_ipipe.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/staging/media/davinci_vpfe/dm365_ipipe.c b/drivers/staging/media/davinci_vpfe/dm365_ipipe.c
> index 3d910b85905c..30e2edc0cec5 100644
> --- a/drivers/staging/media/davinci_vpfe/dm365_ipipe.c
> +++ b/drivers/staging/media/davinci_vpfe/dm365_ipipe.c
> @@ -1264,8 +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),
> - GFP_KERNEL);
> + params = kmalloc(sizeof(*params), GFP_KERNEL);
> to = (void *)params + module_if->param_offset;
> size = module_if->param_size;
>
> @@ -1306,8 +1305,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),
> - GFP_KERNEL);
> + 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 outreachy-kernel+unsubscribe@googlegroups.com.
> To post to this group, send email to outreachy-kernel@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20190325145934.8467-1-madhumithabiw%40gmail.com.
> For more options, visit https://groups.google.com/d/optout.
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-03-25 15:21 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-03-25 14:59 [PATCH v2] Staging: media: davinci_vpfe: Fix preferred form of passing a size Madhumitha Prabakaran
2019-03-25 15:21 ` [Outreachy kernel] " Julia Lawall
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.