]> ruderich.org/simon Gitweb - nsscash/nsscash.git/commitdiff
nss: gr/pw: re-used variable
authorSimon Ruderich <simon@ruderich.org>
Mon, 10 Jun 2019 20:59:08 +0000 (22:59 +0200)
committerSimon Ruderich <simon@ruderich.org>
Mon, 10 Jun 2019 20:59:08 +0000 (22:59 +0200)
Now that the key argument is const we can use this to reduces code
duplication.

nss/gr.c
nss/pw.c

index cc7f9b0d3b428a48ffafb11b48f626fb3ba91d6a..d8d6d6a1520109b9a94384e5098e816e1618c936 100644 (file)
--- 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;
     }
 
         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;
     if (!entry_to_group((struct group_entry *)e, result, buffer, buflen)) {
         unmap_file(&f);
         errno = ERANGE;
index c7e056666216c1cf7e3143dd5626583d1b22298d..c772bb10133e2d7c29feb4565f6327739cb2497e 100644 (file)
--- 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;
     }
 
         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;
     if (!entry_to_passwd((struct passwd_entry *)e, result, buffer, buflen)) {
         unmap_file(&f);
         errno = ERANGE;