From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1944) id 5E7753857409; Fri, 5 Aug 2022 19:29:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5E7753857409 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] Fix string/tester alignment code X-Act-Checkin: glibc X-Git-Author: Szabolcs Nagy X-Git-Refname: refs/heads/arm/morello/main X-Git-Oldrev: d8ecbea3fcdef89fd80d8061f009cb33d40a83f9 X-Git-Newrev: db674b0d98a687a4f5fe7e54ad8ace0e6a7cb5f7 Message-Id: <20220805192935.5E7753857409@sourceware.org> Date: Fri, 5 Aug 2022 19:29:35 +0000 (GMT) X-BeenThere: glibc-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Glibc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Aug 2022 19:29:35 -0000 https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=db674b0d98a687a4f5fe7e54ad8ace0e6a7cb5f7 commit db674b0d98a687a4f5fe7e54ad8ace0e6a7cb5f7 Author: Szabolcs Nagy Date: Mon Mar 21 12:36:16 2022 +0000 Fix string/tester alignment code The code assumed pointers can be converted to unsigned long without loss of information. 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);