Changeset View
Changeset View
Standalone View
Standalone View
sys/boot/efi/libefi/efipart.c
Show First 20 Lines • Show All 359 Lines • ▼ Show 20 Lines | efipart_hdinfo_add(EFI_HANDLE disk_handle, EFI_HANDLE part_handle) | ||||
pdinfo_t *hd, *pd, *last; | pdinfo_t *hd, *pd, *last; | ||||
disk_devpath = efi_lookup_devpath(disk_handle); | disk_devpath = efi_lookup_devpath(disk_handle); | ||||
part_devpath = efi_lookup_devpath(part_handle); | part_devpath = efi_lookup_devpath(part_handle); | ||||
if (disk_devpath == NULL || part_devpath == NULL) { | if (disk_devpath == NULL || part_devpath == NULL) { | ||||
return (ENOENT); | return (ENOENT); | ||||
} | } | ||||
node = (HARDDRIVE_DEVICE_PATH *)efi_devpath_last_node(part_devpath); | node = (HARDDRIVE_DEVICE_PATH *)efi_devpath_last_node(part_devpath); | ||||
if (node == NULL) | if (node == NULL) | ||||
allanjude: looks like you renamed 'node' to 'lastnode', but are checking 'node' for NULL, and it is never… | |||||
return (ENOENT); /* This should not happen. */ | return (ENOENT); /* This should not happen. */ | ||||
pd = malloc(sizeof(pdinfo_t)); | pd = malloc(sizeof(pdinfo_t)); | ||||
if (pd == NULL) { | if (pd == NULL) { | ||||
printf("Failed to add disk, out of memory\n"); | printf("Failed to add disk, out of memory\n"); | ||||
return (ENOMEM); | return (ENOMEM); | ||||
} | } | ||||
memset(pd, 0, sizeof(pdinfo_t)); | memset(pd, 0, sizeof(pdinfo_t)); | ||||
STAILQ_INIT(&pd->pd_part); | STAILQ_INIT(&pd->pd_part); | ||||
STAILQ_FOREACH(hd, &hdinfo, pd_link) { | STAILQ_FOREACH(hd, &hdinfo, pd_link) { | ||||
if (efi_devpath_match(hd->pd_devpath, disk_devpath) != 0) { | if (efi_devpath_match(hd->pd_devpath, disk_devpath) != 0) { | ||||
printf("Registering partition %p\n", part_handle); | |||||
/* Add the partition. */ | /* Add the partition. */ | ||||
pd->pd_handle = part_handle; | pd->pd_handle = part_handle; | ||||
pd->pd_unit = node->PartitionNumber; | pd->pd_unit = node->PartitionNumber; | ||||
pd->pd_devpath = part_devpath; | pd->pd_devpath = part_devpath; | ||||
STAILQ_INSERT_TAIL(&hd->pd_part, pd, pd_link); | STAILQ_INSERT_TAIL(&hd->pd_part, pd, pd_link); | ||||
return (0); | return (0); | ||||
} | } | ||||
} | } | ||||
last = STAILQ_LAST(&hdinfo, pdinfo, pd_link); | last = STAILQ_LAST(&hdinfo, pdinfo, pd_link); | ||||
if (last != NULL) | if (last != NULL) | ||||
unit = last->pd_unit + 1; | unit = last->pd_unit + 1; | ||||
else | else | ||||
unit = 0; | unit = 0; | ||||
/* Add the disk. */ | /* Add the disk. */ | ||||
hd = pd; | hd = pd; | ||||
hd->pd_handle = disk_handle; | hd->pd_handle = disk_handle; | ||||
hd->pd_unit = unit; | hd->pd_unit = unit; | ||||
hd->pd_devpath = disk_devpath; | hd->pd_devpath = disk_devpath; | ||||
STAILQ_INSERT_TAIL(&hdinfo, hd, pd_link); | STAILQ_INSERT_TAIL(&hdinfo, hd, pd_link); | ||||
printf("Registering disk %p\n", disk_handle); | |||||
pd = malloc(sizeof(pdinfo_t)); | pd = malloc(sizeof(pdinfo_t)); | ||||
if (pd == NULL) { | if (pd == NULL) { | ||||
printf("Failed to add partition, out of memory\n"); | printf("Failed to add partition, out of memory\n"); | ||||
return (ENOMEM); | return (ENOMEM); | ||||
} | } | ||||
memset(pd, 0, sizeof(pdinfo_t)); | memset(pd, 0, sizeof(pdinfo_t)); | ||||
STAILQ_INIT(&pd->pd_part); | STAILQ_INIT(&pd->pd_part); | ||||
▲ Show 20 Lines • Show All 559 Lines • Show Last 20 Lines |
looks like you renamed 'node' to 'lastnode', but are checking 'node' for NULL, and it is never set.