public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc/arm/morello/main] Fix string/tester alignment code
@ 2022-08-05 19:29 Szabolcs Nagy
0 siblings, 0 replies; 2+ messages in thread
From: Szabolcs Nagy @ 2022-08-05 19:29 UTC (permalink / raw)
To: glibc-cvs
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=db674b0d98a687a4f5fe7e54ad8ace0e6a7cb5f7
commit db674b0d98a687a4f5fe7e54ad8ace0e6a7cb5f7
Author: Szabolcs Nagy <szabolcs.nagy@arm.com>
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 <errno.h>
+#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -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);
^ permalink raw reply [flat|nested] 2+ messages in thread
* [glibc/arm/morello/main] Fix string/tester alignment code
@ 2022-10-26 15:10 Szabolcs Nagy
0 siblings, 0 replies; 2+ messages in thread
From: Szabolcs Nagy @ 2022-10-26 15:10 UTC (permalink / raw)
To: glibc-cvs
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=df278f143c91af125d548f16814ba09d7c7ef99c
commit df278f143c91af125d548f16814ba09d7c7ef99c
Author: Szabolcs Nagy <szabolcs.nagy@arm.com>
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 <errno.h>
+#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -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);
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-10-26 15:10 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-05 19:29 [glibc/arm/morello/main] Fix string/tester alignment code Szabolcs Nagy
2022-10-26 15:10 Szabolcs Nagy
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).