stand: Use calloc instead of malloc for initialization of filesystem devsw

This change is required for https://reviews.freebsd.org/D49355, so that
we can check if d_dev is uninitialized by checking if it's NULL.

Reviewed by:		imp
Differential Revision:	https://reviews.freebsd.org/D49705
This commit is contained in:
null 2025-09-01 15:57:06 -06:00 committed by Warner Losh
parent 375527545c
commit dfafdbdfc3
6 changed files with 6 additions and 6 deletions

View file

@ -468,7 +468,7 @@ disk_parsedev(struct devdesc **idev, const char *devspec, const char **path)
if (*cp != '\0' && *cp != ':')
return (EINVAL);
dev = malloc(sizeof(*dev));
dev = calloc(sizeof(*dev), 1);
if (dev == NULL)
return (ENOMEM);
dev->dd.d_unit = unit;

View file

@ -465,7 +465,7 @@ hostdisk_parsedev(struct devdesc **idev, const char *devspec, const char **path)
return (EINVAL);
}
free(fn);
dev = malloc(sizeof(*dev));
dev = calloc(sizeof(*dev), 1);
if (dev == NULL)
return (ENOMEM);
dev->d_unit = 0;

View file

@ -98,7 +98,7 @@ ofw_common_parsedev(struct devdesc **dev, const char *devspec, const char **path
if (ofw_path_to_handle(devspec, ofwtype, &rem_path) == -1)
return (ENOENT);
idev = malloc(sizeof(struct ofw_devdesc));
idev = calloc(sizeof(struct ofw_devdesc), 1);
if (idev == NULL) {
printf("ofw_parsedev: malloc failed\n");
return (ENOMEM);

View file

@ -72,7 +72,7 @@ default_parsedev(struct devdesc **dev, const char *devspec,
int unit, err;
char *cp;
idev = malloc(sizeof(struct devdesc));
idev = calloc(sizeof(struct devdesc), 1);
if (idev == NULL)
return (ENOMEM);

View file

@ -1643,7 +1643,7 @@ zfs_parsedev(struct devdesc **idev, const char *devspec, const char **path)
spa = spa_find_by_name(poolname);
if (!spa)
return (ENXIO);
dev = malloc(sizeof(*dev));
dev = calloc(sizeof(*dev), 1);
if (dev == NULL)
return (ENOMEM);
dev->pool_guid = spa->spa_guid;

View file

@ -102,7 +102,7 @@ uboot_parsedev(struct uboot_devdesc **dev, const char *devspec,
}
if (dv == NULL)
return(ENOENT);
idev = malloc(sizeof(struct uboot_devdesc));
idev = calloc(sizeof(struct uboot_devdesc), 1);
err = 0;
np = (devspec + strlen(dv->dv_name));