From: Simon Ruderich <simon@ruderich.org>
Date: Mon, 10 Jun 2019 20:59:08 +0000 (+0200)
Subject: nss: gr/pw: re-used variable
X-Git-Tag: 0.1~70
X-Git-Url: https://ruderich.org/simon/gitweb/?a=commitdiff_plain;h=67fb8cb9a157931c94bb420f25c36d55c2876d02;p=nsscash%2Fnsscash.git

nss: gr/pw: re-used variable

Now that the key argument is const we can use this to reduces code
duplication.
---

diff --git a/nss/gr.c b/nss/gr.c
index cc7f9b0..d8d6d6a 100644
--- a/nss/gr.c
+++ b/nss/gr.c
@@ -165,7 +165,7 @@ static enum nss_status internal_getgr(struct search_key *key, struct group *resu
         return NSS_STATUS_NOTFOUND;
     }
 
-    const char *e = h->data + h->off_data + *off;
+    const char *e = key->data + *off;
     if (!entry_to_group((struct group_entry *)e, result, buffer, buflen)) {
         unmap_file(&f);
         errno = ERANGE;
diff --git a/nss/pw.c b/nss/pw.c
index c7e0566..c772bb1 100644
--- a/nss/pw.c
+++ b/nss/pw.c
@@ -151,7 +151,7 @@ static enum nss_status internal_getpw(struct search_key *key, struct passwd *res
         return NSS_STATUS_NOTFOUND;
     }
 
-    const char *e = h->data + h->off_data + *off;
+    const char *e = key->data + *off;
     if (!entry_to_passwd((struct passwd_entry *)e, result, buffer, buflen)) {
         unmap_file(&f);
         errno = ERANGE;