From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1944) id C8DD73851529; Thu, 27 Oct 2022 13:49:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C8DD73851529 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1666878575; bh=pLHrUeJPr4ulG82TM6RSk/6bPh5ExKpfW8NS9cWbXyY=; h=From:To:Subject:Date:From; b=oQTcVjL+d0GutfgFnY5iXSse5Bl2w5ILAOofZnmQ3VEN4Bb59+GO3aQGjMG/sdVz4 tweywawPpiNg69/AzdJPPuNHtEpCNfD7bIiKoqAXoJWZyMWKwt9uWrDsqczWlRTOg+ XJBV5GM60+XCB3wRVGgc+4MT7STO9fVoPHAExCGI= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Szabolcs Nagy To: glibc-cvs@sourceware.org Subject: [glibc/arm/morello/main] Use uintptr_t in string/tester for pointer alignment X-Act-Checkin: glibc X-Git-Author: Szabolcs Nagy X-Git-Refname: refs/heads/arm/morello/main X-Git-Oldrev: 2c91d717c9fd2f3130100d69cd1fba73c5c7008b X-Git-Newrev: adeba2c19ae48a833cbf09267666e44c2375f2b4 Message-Id: <20221027134935.C8DD73851529@sourceware.org> Date: Thu, 27 Oct 2022 13:49:35 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=adeba2c19ae48a833cbf09267666e44c2375f2b4 commit adeba2c19ae48a833cbf09267666e44c2375f2b4 Author: Szabolcs Nagy Date: Mon Mar 21 12:36:16 2022 +0000 Use uintptr_t in string/tester for pointer alignment The code assumed unsigned long can represent pointers. Diff: --- string/tester.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/string/tester.c b/string/tester.c index 5a397055b1..8111cd12c3 100644 --- a/string/tester.c +++ b/string/tester.c @@ -27,6 +27,7 @@ #endif #include +#include #include #include #include @@ -529,7 +530,7 @@ test_strlen (void) char *p; for (i=0; i < 0x100; i++) { - p = (char *) ((unsigned long int)(buf + 0xff) & ~0xff) + i; + p = (char *) ((uintptr_t)(buf + 0xff) & ~0xff) + i; strcpy (p, "OK"); strcpy (p+3, "BAD/WRONG"); check (strlen (p) == 2, 4+i); @@ -554,7 +555,7 @@ test_strnlen (void) char buf[4096]; for (int i = 0; i < 0x100; ++i) { - char *p = (char *) ((unsigned long int)(buf + 0xff) & ~0xff) + i; + char *p = (char *) ((uintptr_t)(buf + 0xff) & ~0xff) + i; strcpy (p, "OK"); strcpy (p + 3, "BAD/WRONG"); check (strnlen (p, 100) == 2, 10 + i); @@ -582,7 +583,7 @@ test_strchr (void) char *p; for (i=0; i < 0x100; i++) { - p = (char *) ((unsigned long int) (buf + 0xff) & ~0xff) + i; + p = (char *) ((uintptr_t) (buf + 0xff) & ~0xff) + i; strcpy (p, "OK"); strcpy (p+3, "BAD/WRONG"); check (strchr (p, '/') == NULL, 9+i); @@ -614,7 +615,7 @@ test_strchrnul (void) char *p; for (i=0; i < 0x100; i++) { - p = (char *) ((unsigned long int) (buf + 0xff) & ~0xff) + i; + p = (char *) ((uintptr_t) (buf + 0xff) & ~0xff) + i; strcpy (p, "OK"); strcpy (p+3, "BAD/WRONG"); cp = strchrnul (p, '/'); @@ -643,7 +644,7 @@ test_rawmemchr (void) char *p; for (i=0; i < 0x100; i++) { - p = (char *) ((unsigned long int) (buf + 0xff) & ~0xff) + i; + p = (char *) ((uintptr_t) (buf + 0xff) & ~0xff) + i; strcpy (p, "OK"); strcpy (p+3, "BAD/WRONG"); check (rawmemchr (p, 'R') == p+8, 6+i); @@ -689,7 +690,7 @@ test_strrchr (void) char *p; for (i=0; i < 0x100; i++) { - p = (char *) ((unsigned long int) (buf + 0xff) & ~0xff) + i; + p = (char *) ((uintptr_t) (buf + 0xff) & ~0xff) + i; strcpy (p, "OK"); strcpy (p+3, "BAD/WRONG"); check (strrchr (p, '/') == NULL, 9+i);