aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/pthread/tst-tsd1.c
diff options
context:
space:
mode:
authorMartin Sebor <msebor@redhat.com>2021-04-27 19:05:30 -0600
committerMartin Sebor <msebor@redhat.com>2021-04-27 19:07:49 -0600
commitb25b06749179d8d9a891381466e323a9dd2215f9 (patch)
treed97d85f31a972340e39525545b4670ca184aacca /sysdeps/pthread/tst-tsd1.c
parenta1561c3bbe8e72c6e44280d1eb5e529d2da4ecd0 (diff)
downloadglibc-b25b06749179d8d9a891381466e323a9dd2215f9.zip
glibc-b25b06749179d8d9a891381466e323a9dd2215f9.tar.gz
glibc-b25b06749179d8d9a891381466e323a9dd2215f9.tar.bz2
Pass a valid pointer to pthread_setspecific to avoid GCC 11 warning.
Diffstat (limited to 'sysdeps/pthread/tst-tsd1.c')
-rw-r--r--sysdeps/pthread/tst-tsd1.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/sysdeps/pthread/tst-tsd1.c b/sysdeps/pthread/tst-tsd1.c
index eeabfb9..37b4aef 100644
--- a/sysdeps/pthread/tst-tsd1.c
+++ b/sysdeps/pthread/tst-tsd1.c
@@ -27,6 +27,9 @@ do_test (void)
pthread_key_t key1;
pthread_key_t key2;
void *value;
+ /* Addresses of val1 and val2 are used as arbitrary but valid pointers
+ in calls to pthread_setspecific to avoid GCC warnings. */
+ char val1 = 0, val2 = 0;
int result = 0;
int err;
@@ -45,7 +48,7 @@ do_test (void)
result = 1;
}
- err = pthread_setspecific (key1, (void *) -2l);
+ err = pthread_setspecific (key1, (void *) &val1);
if (err != 0)
{
printf ("1st setspecific failed: %s\n", strerror (err));
@@ -58,13 +61,13 @@ do_test (void)
puts ("2nd getspecific == NULL\n");
result = 1;
}
- else if (value != (void *) -2l)
+ else if (value != (void *) &val1)
{
- puts ("2nd getspecific != -2l\n");
+ puts ("2nd getspecific != &val1l\n");
result = 1;
}
- err = pthread_setspecific (key1, (void *) -3l);
+ err = pthread_setspecific (key1, (void *) &val2);
if (err != 0)
{
printf ("2nd setspecific failed: %s\n", strerror (err));
@@ -77,9 +80,9 @@ do_test (void)
puts ("3rd getspecific == NULL\n");
result = 1;
}
- else if (value != (void *) -3l)
+ else if (value != (void *) &val2)
{
- puts ("3rd getspecific != -2l\n");
+ puts ("3rd getspecific != &val2\n");
result = 1;
}