net: ks8851: Replace malloc()+memset() with calloc()
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 <marex@denx.de> Cc: Eugen Hristev <eugen.hristev@microchip.com> Cc: Joe Hershberger <joe.hershberger@ni.com>
This commit is contained in:
@@ -604,12 +604,9 @@ int ks8851_mll_initialize(u8 dev_num, int base_addr)
|
|||||||
{
|
{
|
||||||
struct eth_device *dev;
|
struct eth_device *dev;
|
||||||
|
|
||||||
dev = malloc(sizeof(*dev));
|
dev = calloc(1, sizeof(*dev));
|
||||||
if (!dev) {
|
if (!dev)
|
||||||
printf("Error: Failed to allocate memory\n");
|
return -ENOMEM;
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
memset(dev, 0, sizeof(*dev));
|
|
||||||
|
|
||||||
dev->iobase = base_addr;
|
dev->iobase = base_addr;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user