chiark / gitweb /
nss: remove dead code
authorThomas Hindoe Paaboel Andersen <phomes@gmail.com>
Thu, 18 Sep 2014 21:55:46 +0000 (23:55 +0200)
committerThomas Hindoe Paaboel Andersen <phomes@gmail.com>
Thu, 18 Sep 2014 22:15:39 +0000 (00:15 +0200)
c > 0 is already guaranteed from earlier checks.

We go from

ms = ALIGN(l+1) +
        sizeof(char*) +
        (c > 0 ? c : 1) * ALIGN(alen) +
        (c > 0 ? c+1 : 2) * sizeof(char*);

to

ms = ALIGN(l+1) +
        sizeof(char*) +
        c * ALIGN(alen) +
        (c+1) * sizeof(char*);

to

ms = ALIGN(l+1) + c * ALIGN(alen) + (c+2) * sizeof(char*);

Found by coverity. Fixes: CID#1237570 and CID#1237610

src/nss-mymachines/nss-mymachines.c
src/nss-resolve/nss-resolve.c

index abeb8253c3c2fa4781e8e8ac1f6901160f27f17b..9476ad1694f2be8d52a6613e46692786c5541b6b 100644 (file)
@@ -289,10 +289,7 @@ enum nss_status _nss_mymachines_gethostbyname3_r(
         alen = FAMILY_ADDRESS_SIZE(af);
         l = strlen(name);
 
-        ms = ALIGN(l+1) +
-                sizeof(char*) +
-                (c > 0 ? c : 1) * ALIGN(alen) +
-                (c > 0 ? c+1 : 2) * sizeof(char*);
+        ms = ALIGN(l+1) + c * ALIGN(alen) + (c+2) * sizeof(char*);
 
         if (buflen < ms) {
                 *errnop = ENOMEM;
index 39b73203d26afbc351f1e9d60c15233a595ada1f..6a029a331bd05d7c59ffc7da5fdc6841a6302252 100644 (file)
@@ -404,10 +404,7 @@ enum nss_status _nss_resolve_gethostbyname3_r(
         alen = FAMILY_ADDRESS_SIZE(af);
         l = strlen(canonical);
 
-        ms = ALIGN(l+1) +
-                sizeof(char*) +
-                (c > 0 ? c : 1) * ALIGN(alen) +
-                (c > 0 ? c+1 : 2) * sizeof(char*);
+        ms = ALIGN(l+1) + c * ALIGN(alen) + (c+2) * sizeof(char*);
 
         if (buflen < ms) {
                 *errnop = ENOMEM;