GNU bug report logs - #6727
[PATCH] sort: omit unnecessary casts

Previous Next

Package: coreutils;

Reported by: Paul Eggert <eggert <at> CS.UCLA.EDU>

Date: Mon, 26 Jul 2010 03:02:01 UTC

Severity: normal

Tags: patch

Done: Pádraig Brady <P <at> draigBrady.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 6727 in the body.
You can then email your comments to 6727 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to owner <at> debbugs.gnu.org, bug-coreutils <at> gnu.org:
bug#6727; Package coreutils. (Mon, 26 Jul 2010 03:02:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Paul Eggert <eggert <at> CS.UCLA.EDU>:
New bug report received and forwarded. Copy sent to bug-coreutils <at> gnu.org. (Mon, 26 Jul 2010 03:02:01 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Paul Eggert <eggert <at> CS.UCLA.EDU>
To: Bug Coreutils <bug-coreutils <at> gnu.org>
Subject: [PATCH] sort: omit unnecessary casts
Date: Sun, 25 Jul 2010 20:01:09 -0700
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





Reply sent to Pádraig Brady <P <at> draigBrady.com>:
You have taken responsibility. (Mon, 26 Jul 2010 09:38:01 GMT) Full text and rfc822 format available.

Notification sent to Paul Eggert <eggert <at> CS.UCLA.EDU>:
bug acknowledged by developer. (Mon, 26 Jul 2010 09:38:02 GMT) Full text and rfc822 format available.

Message #10 received at 6727-done <at> debbugs.gnu.org (full text, mbox):

From: Pádraig Brady <P <at> draigBrady.com>
To: Paul Eggert <eggert <at> CS.UCLA.EDU>
Cc: 6727-done <at> debbugs.gnu.org
Subject: Re: bug#6727: [PATCH] sort: omit unnecessary casts
Date: Mon, 26 Jul 2010 10:36:39 +0100
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...




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 23 Aug 2010 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 14 years and 308 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.