From: Simon Ruderich Date: Mon, 17 Jun 2019 18:43:42 +0000 (+0200) Subject: nss: remove pointer indirection in search_key's id member X-Git-Tag: 0.1~45 X-Git-Url: https://ruderich.org/simon/gitweb/?a=commitdiff_plain;h=5b9652f1dff167791209584273e181f932ea93b5;p=nsscash%2Fnsscash.git nss: remove pointer indirection in search_key's id member There's no reason to use a pointer here. Setting name to NULL already marks that an id is to be used. --- diff --git a/nss/gr.c b/nss/gr.c index 48e3a1b..544cc9d 100644 --- a/nss/gr.c +++ b/nss/gr.c @@ -180,9 +180,8 @@ static enum nss_status internal_getgr(struct search_key *key, struct group *resu } 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); diff --git a/nss/pw.c b/nss/pw.c index c612026..78a252f 100644 --- a/nss/pw.c +++ b/nss/pw.c @@ -163,9 +163,8 @@ static enum nss_status internal_getpw(struct search_key *key, struct passwd *res } 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); diff --git a/nss/search.c b/nss/search.c index 666d54c..62e8f43 100644 --- a/nss/search.c +++ b/nss/search.c @@ -35,18 +35,15 @@ static int bsearch_callback(const void *x, const void *y) { 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(); } } diff --git a/nss/search.h b/nss/search.h index f3fbc9a..3812791 100644 --- a/nss/search.h +++ b/nss/search.h @@ -25,7 +25,7 @@ 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