diff options
author | Qihao Chencao <twose@qq.com> | 2022-06-28 16:57:55 +0800 |
---|---|---|
committer | Adhemerval Zanella <adhemerval.zanella@linaro.org> | 2023-02-17 17:07:44 -0300 |
commit | cc4d6614b5922c1104125b1f4d0850a88a551882 (patch) | |
tree | aade315fd79153cf930e8dfd15581dcbdffea0b8 /nscd | |
parent | dab63442791e334d592ce91827ffa9d14ca92ea9 (diff) | |
download | glibc-cc4d6614b5922c1104125b1f4d0850a88a551882.zip glibc-cc4d6614b5922c1104125b1f4d0850a88a551882.tar.gz glibc-cc4d6614b5922c1104125b1f4d0850a88a551882.tar.bz2 |
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.c | 2 | ||||
-rw-r--r-- | nscd/nscd_gethst_r.c | 5 | ||||
-rw-r--r-- | nscd/nscd_getserv_r.c | 7 |
3 files changed, 6 insertions, 8 deletions
diff --git a/nscd/nscd_getgr_r.c b/nscd/nscd_getgr_r.c index dab852e..f30d999 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 153194a..ab9c9d3 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 0ee83ff..6969fcb 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 |