aboutsummaryrefslogtreecommitdiff
path: root/misc
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 /misc
parentdab63442791e334d592ce91827ffa9d14ca92ea9 (diff)
downloadglibc-cc4d6614b5922c1104125b1f4d0850a88a551882.tar
glibc-cc4d6614b5922c1104125b1f4d0850a88a551882.tar.gz
glibc-cc4d6614b5922c1104125b1f4d0850a88a551882.tar.bz2
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 'misc')
-rw-r--r--misc/regexp.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/misc/regexp.c b/misc/regexp.c
index 5ffdfb35e6..85ff41e909 100644
--- a/misc/regexp.c
+++ b/misc/regexp.c
@@ -23,6 +23,7 @@
argument to 'step' and 'advance' was defined only in regexp.h,
as its definition depended on macros defined by the user. */
+#include <stdint.h>
#include <regex.h>
#include <shlib-compat.h>
@@ -50,7 +51,7 @@ step (const char *string, const char *expbuf)
regmatch_t match; /* We only need info about the full match. */
expbuf += __alignof (regex_t *);
- expbuf -= (expbuf - ((const char *) 0)) % __alignof__ (regex_t *);
+ expbuf -= ((uintptr_t) expbuf) % __alignof__ (regex_t *);
if (__regexec ((const regex_t *) expbuf, string, 1, &match, REG_NOTEOL)
== REG_NOMATCH)
@@ -73,7 +74,7 @@ advance (const char *string, const char *expbuf)
regmatch_t match; /* We only need info about the full match. */
expbuf += __alignof__ (regex_t *);
- expbuf -= (expbuf - ((const char *) 0)) % __alignof__ (regex_t *);
+ expbuf -= ((uintptr_t) expbuf) % __alignof__ (regex_t *);
if (__regexec ((const regex_t *) expbuf, string, 1, &match, REG_NOTEOL)
== REG_NOMATCH