Author: tsoome Date: Thu Sep 21 23:22:18 2017 New Revision: 323886 URL: https://svnweb.freebsd.org/changeset/base/323886
Log: libefi: efipart.c should use calloc() The device specific *_add functions are using malloc() + memset, should use calloc instead. Modified: head/sys/boot/efi/libefi/efipart.c Modified: head/sys/boot/efi/libefi/efipart.c ============================================================================== --- head/sys/boot/efi/libefi/efipart.c Thu Sep 21 23:14:07 2017 (r323885) +++ head/sys/boot/efi/libefi/efipart.c Thu Sep 21 23:22:18 2017 (r323886) @@ -198,12 +198,11 @@ efipart_fdinfo_add(EFI_HANDLE handle, uint32_t uid, EF { pdinfo_t *fd; - fd = malloc(sizeof(pdinfo_t)); + fd = calloc(1, sizeof(pdinfo_t)); if (fd == NULL) { printf("Failed to register floppy %d, out of memory\n", uid); return (ENOMEM); } - memset(fd, 0, sizeof(pdinfo_t)); STAILQ_INIT(&fd->pd_part); fd->pd_unit = uid; @@ -272,12 +271,11 @@ efipart_cdinfo_add(EFI_HANDLE handle, EFI_HANDLE alias unit++; } - cd = malloc(sizeof(pdinfo_t)); + cd = calloc(1, sizeof(pdinfo_t)); if (cd == NULL) { printf("Failed to add cd %d, out of memory\n", unit); return (ENOMEM); } - memset(cd, 0, sizeof(pdinfo_t)); STAILQ_INIT(&cd->pd_part); cd->pd_handle = handle; @@ -385,12 +383,11 @@ efipart_hdinfo_add(EFI_HANDLE disk_handle, EFI_HANDLE if (node == NULL) return (ENOENT); /* This should not happen. */ - pd = malloc(sizeof(pdinfo_t)); + pd = calloc(1, sizeof(pdinfo_t)); if (pd == NULL) { printf("Failed to add disk, out of memory\n"); return (ENOMEM); } - memset(pd, 0, sizeof(pdinfo_t)); STAILQ_INIT(&pd->pd_part); STAILQ_FOREACH(hd, &hdinfo, pd_link) { @@ -417,12 +414,11 @@ efipart_hdinfo_add(EFI_HANDLE disk_handle, EFI_HANDLE hd->pd_devpath = disk_devpath; STAILQ_INSERT_TAIL(&hdinfo, hd, pd_link); - pd = malloc(sizeof(pdinfo_t)); + pd = calloc(1, sizeof(pdinfo_t)); if (pd == NULL) { printf("Failed to add partition, out of memory\n"); return (ENOMEM); } - memset(pd, 0, sizeof(pdinfo_t)); STAILQ_INIT(&pd->pd_part); /* Add the partition. */ @@ -456,12 +452,11 @@ efipart_hdinfo_add_filepath(EFI_HANDLE disk_handle) if (node == NULL) return (ENOENT); /* This should not happen. */ - pd = malloc(sizeof(pdinfo_t)); + pd = calloc(1, sizeof(pdinfo_t)); if (pd == NULL) { printf("Failed to add disk, out of memory\n"); return (ENOMEM); } - memset(pd, 0, sizeof(pdinfo_t)); STAILQ_INIT(&pd->pd_part); last = STAILQ_LAST(&hdinfo, pdinfo, pd_link); if (last != NULL) _______________________________________________ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"