All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] staging: ccree: remove unnecessary cast on kmalloc
@ 2017-07-09  5:43 ` Gustavo A. R. Silva
  0 siblings, 0 replies; 5+ messages in thread
From: Gustavo A. R. Silva @ 2017-07-09  5:43 UTC (permalink / raw)
  To: Gilad Ben-Yossef, Greg Kroah-Hartman
  Cc: linux-crypto, driverdev-devel, devel, linux-kernel, Gustavo A. R. Silva

The assignment operator implicitly converts a void pointer to the type of the
pointer it is assigned to.

This issue was detected using Coccinelle and the following semantic patch:

@@
expression * e;
expression arg1, arg2;
type T;
@@

- e=(T*)
+ e=
kmalloc(arg1, arg2);

Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
---
 drivers/staging/ccree/ssi_buffer_mgr.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/ccree/ssi_buffer_mgr.c b/drivers/staging/ccree/ssi_buffer_mgr.c
index b35871e..18a8694 100644
--- a/drivers/staging/ccree/ssi_buffer_mgr.c
+++ b/drivers/staging/ccree/ssi_buffer_mgr.c
@@ -1725,8 +1725,7 @@ int ssi_buffer_mgr_init(struct ssi_drvdata *drvdata)
 	struct buff_mgr_handle *buff_mgr_handle;
 	struct device *dev = &drvdata->plat_dev->dev;
 
-	buff_mgr_handle = (struct buff_mgr_handle *)
-		kmalloc(sizeof(struct buff_mgr_handle), GFP_KERNEL);
+	buff_mgr_handle = kmalloc(sizeof(struct buff_mgr_handle), GFP_KERNEL);
 	if (!buff_mgr_handle)
 		return -ENOMEM;
 
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 1/2] staging: ccree: remove unnecessary cast on kmalloc
@ 2017-07-09  5:43 ` Gustavo A. R. Silva
  0 siblings, 0 replies; 5+ messages in thread
From: Gustavo A. R. Silva @ 2017-07-09  5:43 UTC (permalink / raw)
  To: Gilad Ben-Yossef, Greg Kroah-Hartman
  Cc: linux-crypto, driverdev-devel, devel, linux-kernel, Gustavo A. R. Silva

The assignment operator implicitly converts a void pointer to the type of the
pointer it is assigned to.

This issue was detected using Coccinelle and the following semantic patch:

@@
expression * e;
expression arg1, arg2;
type T;
@@

- e=(T*)
+ e=
kmalloc(arg1, arg2);

Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
Acked-by: Gilad Ben-Yossef <gilad@benyossef.com>
---
 drivers/staging/ccree/ssi_buffer_mgr.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/ccree/ssi_buffer_mgr.c b/drivers/staging/ccree/ssi_buffer_mgr.c
index b35871e..18a8694 100644
--- a/drivers/staging/ccree/ssi_buffer_mgr.c
+++ b/drivers/staging/ccree/ssi_buffer_mgr.c
@@ -1725,8 +1725,7 @@ int ssi_buffer_mgr_init(struct ssi_drvdata *drvdata)
 	struct buff_mgr_handle *buff_mgr_handle;
 	struct device *dev = &drvdata->plat_dev->dev;
 
-	buff_mgr_handle = (struct buff_mgr_handle *)
-		kmalloc(sizeof(struct buff_mgr_handle), GFP_KERNEL);
+	buff_mgr_handle = kmalloc(sizeof(struct buff_mgr_handle), GFP_KERNEL);
 	if (!buff_mgr_handle)
 		return -ENOMEM;
 
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] staging: ccree: use sizeof(*var) in kmalloc
  2017-07-09  5:43 ` Gustavo A. R. Silva
@ 2017-07-09  5:45   ` Gustavo A. R. Silva
  -1 siblings, 0 replies; 5+ messages in thread
From: Gustavo A. R. Silva @ 2017-07-09  5:45 UTC (permalink / raw)
  To: Gilad Ben-Yossef, Greg Kroah-Hartman
  Cc: linux-crypto, driverdev-devel, devel, linux-kernel, Gustavo A. R. Silva

Fix the following checkpatch warning:

CHECK: Prefer kmalloc(sizeof(*buff_mgr_handle)...)
over kmalloc(sizeof(struct buff_mgr_handle)...)

Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
---
 drivers/staging/ccree/ssi_buffer_mgr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/ccree/ssi_buffer_mgr.c b/drivers/staging/ccree/ssi_buffer_mgr.c
index 18a8694..9caff9b 100644
--- a/drivers/staging/ccree/ssi_buffer_mgr.c
+++ b/drivers/staging/ccree/ssi_buffer_mgr.c
@@ -1725,7 +1725,7 @@ int ssi_buffer_mgr_init(struct ssi_drvdata *drvdata)
 	struct buff_mgr_handle *buff_mgr_handle;
 	struct device *dev = &drvdata->plat_dev->dev;
 
-	buff_mgr_handle = kmalloc(sizeof(struct buff_mgr_handle), GFP_KERNEL);
+	buff_mgr_handle = kmalloc(sizeof(*buff_mgr_handle), GFP_KERNEL);
 	if (!buff_mgr_handle)
 		return -ENOMEM;
 
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] staging: ccree: use sizeof(*var) in kmalloc
@ 2017-07-09  5:45   ` Gustavo A. R. Silva
  0 siblings, 0 replies; 5+ messages in thread
From: Gustavo A. R. Silva @ 2017-07-09  5:45 UTC (permalink / raw)
  To: Gilad Ben-Yossef, Greg Kroah-Hartman
  Cc: linux-crypto, driverdev-devel, devel, linux-kernel, Gustavo A. R. Silva

Fix the following checkpatch warning:

CHECK: Prefer kmalloc(sizeof(*buff_mgr_handle)...)
over kmalloc(sizeof(struct buff_mgr_handle)...)

Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
Acked-by: Gilad Ben-Yossef <gilad@benyossef.com>
---
 drivers/staging/ccree/ssi_buffer_mgr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/ccree/ssi_buffer_mgr.c b/drivers/staging/ccree/ssi_buffer_mgr.c
index 18a8694..9caff9b 100644
--- a/drivers/staging/ccree/ssi_buffer_mgr.c
+++ b/drivers/staging/ccree/ssi_buffer_mgr.c
@@ -1725,7 +1725,7 @@ int ssi_buffer_mgr_init(struct ssi_drvdata *drvdata)
 	struct buff_mgr_handle *buff_mgr_handle;
 	struct device *dev = &drvdata->plat_dev->dev;
 
-	buff_mgr_handle = kmalloc(sizeof(struct buff_mgr_handle), GFP_KERNEL);
+	buff_mgr_handle = kmalloc(sizeof(*buff_mgr_handle), GFP_KERNEL);
 	if (!buff_mgr_handle)
 		return -ENOMEM;
 
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] staging: ccree: remove unnecessary cast on kmalloc
  2017-07-09  5:43 ` Gustavo A. R. Silva
  (?)
  (?)
@ 2017-07-11 13:44 ` Gilad Ben-Yossef
  -1 siblings, 0 replies; 5+ messages in thread
From: Gilad Ben-Yossef @ 2017-07-11 13:44 UTC (permalink / raw)
  To: Gustavo A. R. Silva
  Cc: Greg Kroah-Hartman, linux-crypto, driverdev-devel, devel,
	Linux kernel mailing list

On Sun, Jul 9, 2017 at 8:43 AM, Gustavo A. R. Silva
<garsilva@embeddedor.com> wrote:
> The assignment operator implicitly converts a void pointer to the type of the
> pointer it is assigned to.
>
> This issue was detected using Coccinelle and the following semantic patch:
>
> @@
> expression * e;
> expression arg1, arg2;
> type T;
> @@
>
> - e=(T*)
> + e=
> kmalloc(arg1, arg2);
>
> Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>

For both patches:

Acked-by: Gilad Ben-Yossef <gilad@benyossef.com>

> ---
>  drivers/staging/ccree/ssi_buffer_mgr.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/staging/ccree/ssi_buffer_mgr.c b/drivers/staging/ccree/ssi_buffer_mgr.c
> index b35871e..18a8694 100644
> --- a/drivers/staging/ccree/ssi_buffer_mgr.c
> +++ b/drivers/staging/ccree/ssi_buffer_mgr.c
> @@ -1725,8 +1725,7 @@ int ssi_buffer_mgr_init(struct ssi_drvdata *drvdata)
>         struct buff_mgr_handle *buff_mgr_handle;
>         struct device *dev = &drvdata->plat_dev->dev;
>
> -       buff_mgr_handle = (struct buff_mgr_handle *)
> -               kmalloc(sizeof(struct buff_mgr_handle), GFP_KERNEL);
> +       buff_mgr_handle = kmalloc(sizeof(struct buff_mgr_handle), GFP_KERNEL);
>         if (!buff_mgr_handle)
>                 return -ENOMEM;
>
> --
> 2.5.0
>

Thanks,
Gilad



-- 
Gilad Ben-Yossef
Chief Coffee Drinker

"If you take a class in large-scale robotics, can you end up in a
situation where the homework eats your dog?"
 -- Jean-Baptiste Queru

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-07-11 13:44 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-09  5:43 [PATCH 1/2] staging: ccree: remove unnecessary cast on kmalloc Gustavo A. R. Silva
2017-07-09  5:43 ` Gustavo A. R. Silva
2017-07-09  5:45 ` [PATCH 2/2] staging: ccree: use sizeof(*var) in kmalloc Gustavo A. R. Silva
2017-07-09  5:45   ` Gustavo A. R. Silva
2017-07-11 13:44 ` [PATCH 1/2] staging: ccree: remove unnecessary cast on kmalloc Gilad Ben-Yossef

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.