- char *buf = malloc(buflen);
- if (buf == NULL) {
- *errnop = ENOMEM;
- errno = old_errno;
- return NSS_STATUS_TRYAGAIN;
- }
-
- if (fct_start == NULL &&
- __nss_passwd_lookup(&startp, fct_name, &fct_start) != 0) {
- free(buf);
- return NSS_STATUS_UNAVAIL;
- }
- nip = startp;
- fct.ptr = fct_start;
- do {
- morebuf:
- if (fct.l == _nss_nonlocal_getpwuid_r)
- status = NSS_STATUS_NOTFOUND;
- else
- status = DL_CALL_FCT(fct.l, (uid, &pwbuf, buf, buflen, errnop));
- if (status == NSS_STATUS_TRYAGAIN && *errnop == ERANGE) {
- free(buf);
- buflen *= 2;
- buf = malloc(buflen);
- if (buf == NULL) {
- *errnop = ENOMEM;
- errno = old_errno;
- return NSS_STATUS_TRYAGAIN;
- }
- goto morebuf;
- }
- } while (__nss_next(&nip, fct_name, &fct.ptr, status, 0) == 0);
+ const struct walk_nss w = {
+ .lookup = &__nss_passwd_lookup, .fct_name = "getpwuid_r",
+ .status = &status, .errnop = errnop, .buf = &buf, .buflen = &buflen
+ };
+ const __typeof__(&_nss_nonlocal_getpwuid_r) self = &_nss_nonlocal_getpwuid_r;
+#define args (uid, &pwbuf, buf, buflen, errnop)
+#include "walk_nss.h"
+#undef args