From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1944) id A9FD9385DC33; Wed, 26 Oct 2022 15:10:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A9FD9385DC33 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1666797025; bh=z7KQr7iX93E162Ox664Z8JdXnKoG+aA3mXnAZ7N6YUw=; h=From:To:Subject:Date:From; b=M3TELUstwwuGZ9hRu0t+V48vs2uXOW7IxpBjwlVb7O0fe5QCPy7py20KsRTTP1Bfr tCJXueMkmonvt3FyiaDAdTaR1vTg8Pq643gL6KU4X+hJziFFq9WtP321IWtxN8bmFf 47NLHMP1FsdRYHyFvi9Zq0fgAVAqmBS49yKd5qWU= 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: 6935c2749248508e63b7eeda0007a3d455218eb7 X-Git-Newrev: df278f143c91af125d548f16814ba09d7c7ef99c Message-Id: <20221026151025.A9FD9385DC33@sourceware.org> Date: Wed, 26 Oct 2022 15:10:22 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=df278f143c91af125d548f16814ba09d7c7ef99c commit df278f143c91af125d548f16814ba09d7c7ef99c 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);