Re: [PATCH 01/12] net: ks8851: Replace malloc()+memset() with calloc()

2020-04-16 Thread Joe Hershberger
On Wed, Mar 25, 2020 at 1:45 PM Marek Vasut  wrote:
>
> Replace combination of malloc()+memset() with calloc() as the behavior
> is exactly the same and the amount of code is reduced. Moreover, remove
> printf() in the fail path, as it is useless, and return proper -ENOMEM
> return code.
>
> Signed-off-by: Marek Vasut 
> Cc: Eugen Hristev 
> Cc: Joe Hershberger 

Acked-by: Joe Hershberger 


Re: [PATCH 01/12] net: ks8851: Replace malloc()+memset() with calloc()

2020-04-16 Thread Marek Vasut
On 3/25/20 7:44 PM, Marek Vasut wrote:
> Replace combination of malloc()+memset() with calloc() as the behavior
> is exactly the same and the amount of code is reduced. Moreover, remove
> printf() in the fail path, as it is useless, and return proper -ENOMEM
> return code.
> 
> Signed-off-by: Marek Vasut 
> Cc: Eugen Hristev 
> Cc: Joe Hershberger 

Joe, bump ?


[PATCH 01/12] net: ks8851: Replace malloc()+memset() with calloc()

2020-03-25 Thread Marek Vasut
Replace combination of malloc()+memset() with calloc() as the behavior
is exactly the same and the amount of code is reduced. Moreover, remove
printf() in the fail path, as it is useless, and return proper -ENOMEM
return code.

Signed-off-by: Marek Vasut 
Cc: Eugen Hristev 
Cc: Joe Hershberger 
---
 drivers/net/ks8851_mll.c | 9 +++--
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ks8851_mll.c b/drivers/net/ks8851_mll.c
index 718a7dd019..4386763bac 100644
--- a/drivers/net/ks8851_mll.c
+++ b/drivers/net/ks8851_mll.c
@@ -602,12 +602,9 @@ int ks8851_mll_initialize(u8 dev_num, int base_addr)
 {
struct eth_device *dev;
 
-   dev = malloc(sizeof(*dev));
-   if (!dev) {
-   printf("Error: Failed to allocate memory\n");
-   return -1;
-   }
-   memset(dev, 0, sizeof(*dev));
+   dev = calloc(1, sizeof(*dev));
+   if (!dev)
+   return -ENOMEM;
 
dev->iobase = base_addr;
 
-- 
2.25.1