Remove nested functions from device iterators.
* include/grub/arc/arc.h (grub_arc_iterate_devs_hook_t): New type. (grub_arc_iterate_devs): Add hook_data argument. * include/grub/ata.h (grub_ata_dev_iterate_hook_t): New type. (struct grub_ata_dev.iterate): Add hook_data argument. * include/grub/device.h (grub_device_iterate_hook_t): New type. (grub_device_iterate): Add hook_data argument. * include/grub/disk.h (grub_disk_dev_iterate_hook_t): New type. (struct grub_disk_dev.iterate): Add hook_data argument. (grub_disk_dev_iterate): Likewise. * include/grub/gpt_partition.h (grub_gpt_partition_map_iterate): Likewise. * include/grub/msdos_partition.h (grub_partition_msdos_iterate): Likewise. * include/grub/partition.h (grub_partition_iterate_hook_t): New type. (struct grub_partition_map.iterate): Add hook_data argument. (grub_partition_iterate): Likewise. * include/grub/scsi.h (grub_scsi_dev_iterate_hook_t): New type. (struct grub_scsi_dev.iterate): Add hook_data argument. Update all callers.
This commit is contained in:
parent
6c0314d638
commit
25239370fd
50 changed files with 1455 additions and 1165 deletions
|
@ -48,8 +48,7 @@ const char *type_names[] = {
|
|||
|
||||
static int
|
||||
iterate_rec (const char *prefix, const struct grub_arc_component *parent,
|
||||
int (*hook) (const char *name,
|
||||
const struct grub_arc_component *comp),
|
||||
grub_arc_iterate_devs_hook_t hook, void *hook_data,
|
||||
int alt_names)
|
||||
{
|
||||
const struct grub_arc_component *comp;
|
||||
|
@ -67,12 +66,13 @@ iterate_rec (const char *prefix, const struct grub_arc_component *parent,
|
|||
name = grub_xasprintf ("%s%s(%lu)", prefix, cname, comp->key);
|
||||
if (!name)
|
||||
return 1;
|
||||
if (hook (name, comp))
|
||||
if (hook (name, comp, hook_data))
|
||||
{
|
||||
grub_free (name);
|
||||
return 1;
|
||||
}
|
||||
if (iterate_rec ((parent ? name : prefix), comp, hook, alt_names))
|
||||
if (iterate_rec ((parent ? name : prefix), comp, hook, hook_data,
|
||||
alt_names))
|
||||
{
|
||||
grub_free (name);
|
||||
return 1;
|
||||
|
@ -83,11 +83,11 @@ iterate_rec (const char *prefix, const struct grub_arc_component *parent,
|
|||
}
|
||||
|
||||
int
|
||||
grub_arc_iterate_devs (int (*hook) (const char *name,
|
||||
const struct grub_arc_component *comp),
|
||||
grub_arc_iterate_devs (grub_arc_iterate_devs_hook_t hook, void *hook_data,
|
||||
int alt_names)
|
||||
{
|
||||
return iterate_rec ((alt_names ? "arc" : ""), NULL, hook, alt_names);
|
||||
return iterate_rec ((alt_names ? "arc" : ""), NULL, hook, hook_data,
|
||||
alt_names);
|
||||
}
|
||||
|
||||
grub_err_t
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue