about summary refs log tree commit diff
path: root/nscd/nscd_gethst_r.c
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/nscd_gethst_r.c
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/nscd_gethst_r.c')
-rw-r--r--nscd/nscd_gethst_r.c5
1 files changed, 2 insertions, 3 deletions
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