From unknown Mon Jun 23 23:52:21 2025 X-Loop: help-debbugs@gnu.org Subject: bug#6727: [PATCH] sort: omit unnecessary casts Resent-From: Paul Eggert Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-coreutils@gnu.org Resent-Date: Mon, 26 Jul 2010 03:02:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 6727 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: patch To: 6727@debbugs.gnu.org X-Debbugs-Original-To: Bug Coreutils Received: via spool by submit@debbugs.gnu.org id=B.128011327523138 (code B ref -1); Mon, 26 Jul 2010 03:02:01 +0000 Received: (at submit) by debbugs.gnu.org; 26 Jul 2010 03:01:15 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OdDwI-000619-Eo for submit@debbugs.gnu.org; Sun, 25 Jul 2010 23:01:14 -0400 Received: from mx10.gnu.org ([199.232.76.166]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OdDwG-000613-0b for submit@debbugs.gnu.org; Sun, 25 Jul 2010 23:01:12 -0400 Received: from lists.gnu.org ([199.232.76.165]:48590) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1OdDwJ-0005JH-Uo for submit@debbugs.gnu.org; Sun, 25 Jul 2010 23:01:16 -0400 Received: from [140.186.70.92] (port=55978 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OdDwI-00069H-Cq for bug-coreutils@gnu.org; Sun, 25 Jul 2010 23:01:15 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,T_RP_MATCHES_RCVD autolearn=unavailable version=3.3.1 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OdDwH-0000aC-61 for bug-coreutils@gnu.org; Sun, 25 Jul 2010 23:01:14 -0400 Received: from kiwi.cs.ucla.edu ([131.179.128.19]:38677) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OdDwG-0000Zy-RH for bug-coreutils@gnu.org; Sun, 25 Jul 2010 23:01:13 -0400 Received: from [131.179.64.200] (Penguin.CS.UCLA.EDU [131.179.64.200]) by kiwi.cs.ucla.edu (8.13.8+Sun/8.13.8/UCLACS-6.0) with ESMTP id o6Q319St023713 for ; Sun, 25 Jul 2010 20:01:10 -0700 (PDT) Message-ID: <4C4CFA75.8020403@cs.ucla.edu> Date: Sun, 25 Jul 2010 20:01:09 -0700 From: Paul Eggert Organization: UCLA Computer Science Department User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.10) Gecko/20100527 Thunderbird/3.0.5 MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-detected-operating-system: by eggs.gnu.org: Solaris 10 (beta) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-Spam-Score: -5.1 (-----) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -5.1 (-----) 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 From unknown Mon Jun 23 23:52:21 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.427 (Entity 5.427) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Paul Eggert Subject: bug#6727: closed (Re: bug#6727: [PATCH] sort: omit unnecessary casts) Message-ID: References: <4C4D5727.2030303@draigBrady.com> <4C4CFA75.8020403@cs.ucla.edu> X-Gnu-PR-Message: they-closed 6727 X-Gnu-PR-Package: coreutils X-Gnu-PR-Keywords: patch Reply-To: 6727@debbugs.gnu.org Date: Mon, 26 Jul 2010 09:38:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1280137082-1906-1" This is a multi-part message in MIME format... ------------=_1280137082-1906-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 6727@debbugs.gnu.org. --=20 6727: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D6727 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1280137082-1906-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 6727-done) by debbugs.gnu.org; 26 Jul 2010 09:37:24 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OdK7g-0000UN-Hj for submit@debbugs.gnu.org; Mon, 26 Jul 2010 05:37:24 -0400 Received: from mail1.slb.deg.dub.stisp.net ([84.203.253.98]) by debbugs.gnu.org with smtp (Exim 4.69) (envelope-from ) id 1OdK7f-0000UE-4B for 6727-done@debbugs.gnu.org; Mon, 26 Jul 2010 05:37:23 -0400 Received: (qmail 12196 invoked from network); 26 Jul 2010 09:37:27 -0000 Received: from unknown (HELO ?192.168.2.25?) (84.203.137.218) by mail1.slb.deg.dub.stisp.net with SMTP; 26 Jul 2010 09:37:27 -0000 Message-ID: <4C4D5727.2030303@draigBrady.com> Date: Mon, 26 Jul 2010 10:36:39 +0100 From: =?ISO-8859-1?Q?P=E1draig_Brady?= User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.8) Gecko/20100227 Thunderbird/3.0.3 MIME-Version: 1.0 To: Paul Eggert Subject: Re: bug#6727: [PATCH] sort: omit unnecessary casts References: <4C4CFA75.8020403@cs.ucla.edu> In-Reply-To: <4C4CFA75.8020403@cs.ucla.edu> X-Enigmail-Version: 1.0.1 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Spam-Score: -2.7 (--) X-Debbugs-Envelope-To: 6727-done Cc: 6727-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.7 (--) 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... ------------=_1280137082-1906-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 26 Jul 2010 03:01:15 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OdDwI-000619-Eo for submit@debbugs.gnu.org; Sun, 25 Jul 2010 23:01:14 -0400 Received: from mx10.gnu.org ([199.232.76.166]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OdDwG-000613-0b for submit@debbugs.gnu.org; Sun, 25 Jul 2010 23:01:12 -0400 Received: from lists.gnu.org ([199.232.76.165]:48590) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1OdDwJ-0005JH-Uo for submit@debbugs.gnu.org; Sun, 25 Jul 2010 23:01:16 -0400 Received: from [140.186.70.92] (port=55978 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OdDwI-00069H-Cq for bug-coreutils@gnu.org; Sun, 25 Jul 2010 23:01:15 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,T_RP_MATCHES_RCVD autolearn=unavailable version=3.3.1 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OdDwH-0000aC-61 for bug-coreutils@gnu.org; Sun, 25 Jul 2010 23:01:14 -0400 Received: from kiwi.cs.ucla.edu ([131.179.128.19]:38677) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OdDwG-0000Zy-RH for bug-coreutils@gnu.org; Sun, 25 Jul 2010 23:01:13 -0400 Received: from [131.179.64.200] (Penguin.CS.UCLA.EDU [131.179.64.200]) by kiwi.cs.ucla.edu (8.13.8+Sun/8.13.8/UCLACS-6.0) with ESMTP id o6Q319St023713 for ; Sun, 25 Jul 2010 20:01:10 -0700 (PDT) Message-ID: <4C4CFA75.8020403@cs.ucla.edu> Date: Sun, 25 Jul 2010 20:01:09 -0700 From: Paul Eggert Organization: UCLA Computer Science Department User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.10) Gecko/20100527 Thunderbird/3.0.5 MIME-Version: 1.0 To: Bug Coreutils Subject: [PATCH] sort: omit unnecessary casts Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-detected-operating-system: by eggs.gnu.org: Solaris 10 (beta) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-Spam-Score: -5.1 (-----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -5.1 (-----) 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 ------------=_1280137082-1906-1--