]> ruderich.org/simon Gitweb - nsscash/nsscash.git/commitdiff
nss: remove pointer indirection in search_key's id member
authorSimon Ruderich <simon@ruderich.org>
Mon, 17 Jun 2019 18:43:42 +0000 (20:43 +0200)
committerSimon Ruderich <simon@ruderich.org>
Mon, 17 Jun 2019 18:43:42 +0000 (20:43 +0200)
There's no reason to use a pointer here. Setting name to NULL already
marks that an id is to be used.

nss/gr.c
nss/pw.c
nss/search.c
nss/search.h

index 48e3a1b6f2548bca4e8623d21b3877efd853da53..544cc9d911ade8cbb85ca9b4f673ce1419f58677 100644 (file)
--- 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) {
 }
 
 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 = {
     struct search_key key = {
-        .id = &id,
+        .id = (uint64_t)gid,
         .offset = offsetof(struct group_entry, gid),
     };
     return internal_getgr(&key, result, buffer, buflen, errnop);
         .offset = offsetof(struct group_entry, gid),
     };
     return internal_getgr(&key, result, buffer, buflen, errnop);
index c612026aa132a96cd7a6a303016e7bc7a27d5ad3..78a252f6db5a41edc02aead332670191eaa31ec7 100644 (file)
--- 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) {
 }
 
 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 = {
     struct search_key key = {
-        .id = &id,
+        .id = (uint64_t)uid,
         .offset = offsetof(struct passwd_entry, uid),
     };
     return internal_getpw(&key, result, buffer, buflen, errnop);
         .offset = offsetof(struct passwd_entry, uid),
     };
     return internal_getpw(&key, result, buffer, buflen, errnop);
index 666d54c7bdec3785c2477ba8376c088f5be70e79..62e8f431cb944ccfd3e36b5dc4db2c63cb9d3a71 100644 (file)
@@ -35,18 +35,15 @@ static int bsearch_callback(const void *x, const void *y) {
         return strcmp(key->name, name);
 
     // Lookup by ID (uint64_t)
         return strcmp(key->name, name);
 
     // Lookup by ID (uint64_t)
-    } else if (key->id != NULL) {
+    } else {
         const uint64_t *id = member;
         const uint64_t *id = member;
-        if (*key->id < *id) {
+        if (key->id < *id) {
             return -1;
             return -1;
-        } else if (*key->id == *id) {
+        } else if (key->id == *id) {
             return 0;
         } else {
             return +1;
         }
             return 0;
         } else {
             return +1;
         }
-
-    } else {
-        abort();
     }
 }
 
     }
 }
 
index f3fbc9a3af13924665791f7ac07014193eff1de2..3812791963d0789c42537e3ea3d86e684fa19aee 100644 (file)
@@ -25,7 +25,7 @@
 
 struct search_key {
     const char *name; // if name != NULL search for a string
 
 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
 
     // 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