Skip to contentSkip to conversation

tsearch.3: Remove unneeded cast

PATCH In review Alejandro Colomar 2 participants 2 messages Sep 5, 2020 Man-pages: manual pages for Linux -- Sections 2, 3, 4, 5, and 7

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tsearch.3: Remove unneeded cast

Casting int * to const void * is already done implicitly. Not only that, but the explicit cast to void * was slightly misleading.

---
 man3/tsearch.3 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
man3/tsearch.3 +1 -1
index 65fcadc52..05d0b2170 100644
@@ -329,7 +329,7 @@ main(void)
     for (i = 0; i < 12; i++) {
         ptr = xmalloc(sizeof(*ptr));
         *ptr = rand() & 0xff;
-        val = tsearch((void *) ptr, &root, compare);
+        val = tsearch(ptr, &root, compare);
         if (val == NULL)
             exit(EXIT_FAILURE);
         else if (*val != ptr)
Signature · 1 line
2.28.0
#1 lore raw
Quoted 14 lines · Alejandro Colomar

Casting int * to const void * is already done implicitly. Not only that, but the explicit cast to void * was slightly misleading.

---
 man3/tsearch.3 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
man3/tsearch.3 +0 -0
index 65fcadc52..05d0b2170 100644

man3/tsearch.3 main(void) · line 335

Quoted 8 lines
man3/tsearch.3 +1 -1
@@ -329,7 +329,7 @@ main(void)
     for (i = 0; i < 12; i++) {
         ptr = xmalloc(sizeof(*ptr));
         *ptr = rand() & 0xff;
-        val = tsearch((void *) ptr, &root, compare);
+        val = tsearch(ptr, &root, compare);
         if (val == NULL)
             exit(EXIT_FAILURE);
         else if (*val != ptr)

Thanks, Alex. Patch applied.

Cheers,

Michael

Signature · 3 lines
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/