From cc4d6614b5922c1104125b1f4d0850a88a551882 Mon Sep 17 00:00:00 2001 From: Qihao Chencao Date: Tue, 28 Jun 2022 16:57:55 +0800 Subject: Use uintptr_t instead of performing pointer subtraction with a null pointer Signed-off-by: Qihao Chencao Reviewed-by: Adhemerval Zanella --- nss/nss_files/files-alias.c | 2 +- nss/nss_files/files-parse.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'nss') diff --git a/nss/nss_files/files-alias.c b/nss/nss_files/files-alias.c index 1c32884fe7..4601cb6ce9 100644 --- a/nss/nss_files/files-alias.c +++ b/nss/nss_files/files-alias.c @@ -281,7 +281,7 @@ get_next_alias (FILE *stream, const char *match, struct aliasent *result, /* Adjust the pointer so it is aligned for storing pointers. */ first_unused += __alignof__ (char *) - 1; - first_unused -= ((first_unused - (char *) 0) + first_unused -= (((uintptr_t) first_unused) % __alignof__ (char *)); result->alias_members = (char **) first_unused; diff --git a/nss/nss_files/files-parse.c b/nss/nss_files/files-parse.c index 632ba0a880..77333b18fe 100644 --- a/nss/nss_files/files-parse.c +++ b/nss/nss_files/files-parse.c @@ -239,7 +239,7 @@ parse_list (char **linep, char *eol, char *buf_end, int terminator_c, /* Adjust the pointer so it is aligned for storing pointers. */ eol += __alignof__ (char *) - 1; - eol -= (eol - (char *) 0) % __alignof__ (char *); + eol -= ((uintptr_t) eol) % __alignof__ (char *); /* We will start the storage here for the vector of pointers. */ list = (char **) eol; -- cgit 1.4.1