}
enum nss_status _nss_cash_getgrgid_r(gid_t gid, struct group *result, char *buffer, size_t buflen, int *errnop) {
- uint64_t id = (uint64_t)gid;
struct search_key key = {
- .id = &id,
+ .id = (uint64_t)gid,
.offset = offsetof(struct group_entry, gid),
};
return internal_getgr(&key, result, buffer, buflen, errnop);
}
enum nss_status _nss_cash_getpwuid_r(uid_t uid, struct passwd *result, char *buffer, size_t buflen, int *errnop) {
- uint64_t id = (uint64_t)uid;
struct search_key key = {
- .id = &id,
+ .id = (uint64_t)uid,
.offset = offsetof(struct passwd_entry, uid),
};
return internal_getpw(&key, result, buffer, buflen, errnop);
return strcmp(key->name, name);
// Lookup by ID (uint64_t)
- } else if (key->id != NULL) {
+ } else {
const uint64_t *id = member;
- if (*key->id < *id) {
+ if (key->id < *id) {
return -1;
- } else if (*key->id == *id) {
+ } else if (key->id == *id) {
return 0;
} else {
return +1;
}
-
- } else {
- abort();
}
}
struct search_key {
const char *name; // if name != NULL search for a string
- const uint64_t *id; // if name == NULL search for an id
+ const uint64_t id; // if name == NULL search for an id
// The actual data with all entries; this is where the full entry
// including name/id is located (the index holds an offset into data for