Ævar Arnfjörð Bjarmason <avarab@xxxxxxxxx> writes: > +static int userdiff_find_by_namelen_cb(struct userdiff_driver *driver, > + enum userdiff_driver_type type, void *priv) > { > - int i; > - for (i = 0; i < ndrivers; i++) { > - struct userdiff_driver *drv = drivers + i; > - if (!strncmp(drv->name, k, len) && !drv->name[len]) > - return drv; > - } > - for (i = 0; i < ARRAY_SIZE(builtin_drivers); i++) { > - struct userdiff_driver *drv = builtin_drivers + i; > - if (!strncmp(drv->name, k, len) && !drv->name[len]) > - return drv; > + struct find_by_namelen_data *cb_data = priv; > + > + if (!strncmp(driver->name, cb_data->name, cb_data->len) && > + !driver->name[cb_data->len]) { > + cb_data->driver = driver; > + return 1; /* tell the caller to stop iterating */ > } > - return NULL; > + return 0; > +} > ... > +enum userdiff_driver_type { > + USERDIFF_DRIVER_TYPE_BUILTIN = 1<<0, > + USERDIFF_DRIVER_TYPE_CUSTOM = 1<<1, > +}; > +typedef int (*each_userdiff_driver_fn)(struct userdiff_driver *, > + enum userdiff_driver_type, void *); Makes sense.