Subject: bug#6727: closed (Re: bug#6727: [PATCH] sort: omit unnecessary casts)

From: [email-masked] (GNU bug Tracking System)
Date: Mon, 26 Jul 2010 09:38:02 +0000

Your bug report

#6727: [PATCH] sort: omit unnecessary casts

which was filed against the coreutils package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
6727: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=6727
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#6727: [PATCH] sort: omit unnecessary casts
From: Pádraig Brady <[email-masked]>
To: Paul Eggert <[email-masked]>
Cc: [email-masked]
Date: Mon, 26 Jul 2010 10:36:39 +0100
List-Id: <debbugs-submit.debbugs.gnu.org>

On 26/07/10 04:01, Paul Eggert wrote:
> * src/sort.c (inittables, general_numcompare, compare_nodes):
> (queue_init, queue_pop): Omit casts that are not needed, typically
> because they are between void * and some other pointer type.

Looks good. Closing...

Subject: [PATCH] sort: omit unnecessary casts
From: Paul Eggert <[email-masked]>
To: Bug Coreutils <[email-masked]>
Date: Sun, 25 Jul 2010 20:01:09 -0700
List-Id: <debbugs-submit.debbugs.gnu.org>

These casts aren't needed.  Perhaps the qsort and nl_langinfo
casts were needed in the distant past, but surely not any more
(as similar casts are not present in other uses of these functions).

* src/sort.c (inittables, general_numcompare, compare_nodes):
(queue_init, queue_pop): Omit casts that are not needed, typically
because they are between void * and some other pointer type.
---
 src/sort.c |   15 +++++++--------
 1 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/src/sort.c b/src/sort.c
index c7c8b46..ca1d95c 100644
--- a/src/sort.c
+++ b/src/sort.c
@@ -1236,7 +1236,7 @@ inittables (void)
           size_t j, k;
           char *name;
 
-          s = (char *) nl_langinfo (ABMON_1 + i);
+          s = nl_langinfo (ABMON_1 + i);
           s_len = strlen (s);
           monthtab[i].name = name = xmalloc (s_len + 1);
           monthtab[i].val = i + 1;
@@ -1246,8 +1246,7 @@ inittables (void)
               name[k++] = fold_toupper[to_uchar (s[j])];
           name[k] = '\0';
         }
-      qsort ((void *) monthtab, MONTHS_PER_YEAR,
-             sizeof *monthtab, struct_month_cmp);
+      qsort (monthtab, MONTHS_PER_YEAR, sizeof *monthtab, struct_month_cmp);
     }
 #endif
 }
@@ -1961,7 +1960,7 @@ general_numcompare (char const *sa, char const *sb, char const **ea)
           : a == b ? 0
           : b == b ? -1
           : a == a ? 1
-          : memcmp ((char *) &a, (char *) &b, sizeof a));
+          : memcmp (&a, &b, sizeof a));
 }
 
 /* Return an integer in 1..12 of the month name MONTH with length LEN.
@@ -3107,8 +3106,8 @@ sequential_sort (struct line *restrict lines, size_t nlines,
 static int
 compare_nodes (void const *a, void const *b)
 {
-  struct merge_node const *nodea = (struct merge_node const *) a;
-  struct merge_node const *nodeb = (struct merge_node const *) b;
+  struct merge_node const *nodea = a;
+  struct merge_node const *nodeb = b;
   if (nodea->level == nodeb->level)
       return (nodea->nlo + nodea->nhi) < (nodeb->nlo + nodeb->nhi);
   return nodea->level < nodeb->level;
@@ -3151,7 +3150,7 @@ queue_destroy (struct merge_node_queue *restrict queue)
 static inline void
 queue_init (struct merge_node_queue *restrict queue, size_t reserve)
 {
-  queue->priority_queue = (struct heap *) heap_alloc (compare_nodes, reserve);
+  queue->priority_queue = heap_alloc (compare_nodes, reserve);
   pthread_mutex_init (&queue->mutex, NULL);
   pthread_cond_init (&queue->cond, NULL);
 }
@@ -3181,7 +3180,7 @@ queue_pop (struct merge_node_queue *restrict queue)
     {
       pthread_mutex_lock (&queue->mutex);
       if (queue->priority_queue->count)
-        node = (struct merge_node *) heap_remove_top (queue->priority_queue);
+        node = heap_remove_top (queue->priority_queue);
       else
         {
           /* Go into conditional wait if no NODE is immediately available.  */
-- 
1.7.1