about summary refs log tree commit diff
path: root/nscd
diff options
context:
space:
mode:
authorQihao Chencao <twose@qq.com>2022-06-28 16:57:55 +0800
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>2023-02-17 17:07:44 -0300
commitcc4d6614b5922c1104125b1f4d0850a88a551882 (patch)
treeaade315fd79153cf930e8dfd15581dcbdffea0b8 /nscd
parentdab63442791e334d592ce91827ffa9d14ca92ea9 (diff)
downloadglibc-cc4d6614b5922c1104125b1f4d0850a88a551882.tar.gz
glibc-cc4d6614b5922c1104125b1f4d0850a88a551882.tar.xz
glibc-cc4d6614b5922c1104125b1f4d0850a88a551882.zip
Use uintptr_t instead of performing pointer subtraction with a null pointer
Signed-off-by: Qihao Chencao <twose@qq.com>

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
Diffstat (limited to 'nscd')
-rw-r--r--nscd/nscd_getgr_r.c2
-rw-r--r--nscd/nscd_gethst_r.c5
-rw-r--r--nscd/nscd_getserv_r.c7
3 files changed, 6 insertions, 8 deletions
diff --git a/nscd/nscd_getgr_r.c b/nscd/nscd_getgr_r.c
index dab852e8f2..f30d99973d 100644
--- a/nscd/nscd_getgr_r.c
+++ b/nscd/nscd_getgr_r.c
@@ -159,7 +159,7 @@ nscd_getgr_r (const char *key, size_t keylen, request_type type,
 
       /* Now allocate the buffer the array for the group members.  We must
 	 align the pointer.  */
-      align = ((__alignof__ (char *) - (p - ((char *) 0)))
+      align = ((__alignof__ (char *) - ((uintptr_t) p))
 	       & (__alignof__ (char *) - 1));
       total_len = (align + (1 + gr_resp.gr_mem_cnt) * sizeof (char *)
 		   + gr_resp.gr_name_len + gr_resp.gr_passwd_len);
diff --git a/nscd/nscd_gethst_r.c b/nscd/nscd_gethst_r.c
index 153194ad04..ab9c9d311f 100644
--- a/nscd/nscd_gethst_r.c
+++ b/nscd/nscd_gethst_r.c
@@ -244,10 +244,9 @@ nscd_gethst_r (const char *key, size_t keylen, request_type type,
       /* A first check whether the buffer is sufficiently large is possible.  */
       /* Now allocate the buffer the array for the group members.  We must
 	 align the pointer and the base of the h_addr_list pointers.  */
-      align1 = ((__alignof__ (char *) - (cp - ((char *) 0)))
+      align1 = ((__alignof__ (char *) - ((uintptr_t) cp))
 		& (__alignof__ (char *) - 1));
-      align2 = ((__alignof__ (char *) - ((cp + align1 + hst_resp.h_name_len)
-					 - ((char *) 0)))
+      align2 = ((__alignof__ (char *) - ((uintptr_t) (cp + align1 + hst_resp.h_name_len)))
 		& (__alignof__ (char *) - 1));
       if (buflen < (align1 + hst_resp.h_name_len + align2
 		    + ((hst_resp.h_aliases_cnt + hst_resp.h_addr_list_cnt
diff --git a/nscd/nscd_getserv_r.c b/nscd/nscd_getserv_r.c
index 0ee83ff88c..6969fcb739 100644
--- a/nscd/nscd_getserv_r.c
+++ b/nscd/nscd_getserv_r.c
@@ -205,11 +205,10 @@ nscd_getserv_r (const char *crit, size_t critlen, const char *proto,
       /* A first check whether the buffer is sufficiently large is possible.  */
       /* Now allocate the buffer the array for the group members.  We must
 	 align the pointer and the base of the h_addr_list pointers.  */
-      align1 = ((__alignof__ (char *) - (cp - ((char *) 0)))
+      align1 = ((__alignof__ (char *) - ((uintptr_t) cp))
 		& (__alignof__ (char *) - 1));
-      align2 = ((__alignof__ (char *) - ((cp + align1 + serv_resp.s_name_len
-					  + serv_resp.s_proto_len)
-					 - ((char *) 0)))
+      align2 = ((__alignof__ (char *) - ((uintptr_t) (cp + align1 + serv_resp.s_name_len
+					  + serv_resp.s_proto_len)))
 		& (__alignof__ (char *) - 1));
       if (buflen < (align1 + serv_resp.s_name_len + serv_resp.s_proto_len
 		    + align2