From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1994 invoked by alias); 17 Apr 2011 00:55:55 -0000 Received: (qmail 1965 invoked by uid 22791); 17 Apr 2011 00:55:54 -0000 X-SWARE-Spam-Status: No, hits=-1.5 required=5.0 tests=AWL,BAYES_00,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from fencepost.gnu.org (HELO fencepost.gnu.org) (140.186.70.10) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 17 Apr 2011 00:55:38 +0000 Received: from eggs.gnu.org ([140.186.70.92]:41956) by fencepost.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1QBGH3-0004Ik-FW for gcc-patches@gnu.org; Sat, 16 Apr 2011 20:55:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QBGH2-0006uL-Co for gcc-patches@gnu.org; Sat, 16 Apr 2011 20:55:37 -0400 Received: from smtp171.iad.emailsrvr.com ([207.97.245.171]:57637) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QBGH2-0006u3-92 for gcc-patches@gnu.org; Sat, 16 Apr 2011 20:55:36 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp37.relay.iad1a.emailsrvr.com (SMTP Server) with ESMTP id 84D343B0442 for ; Sat, 16 Apr 2011 20:55:33 -0400 (EDT) Received: from dynamic3.wm-web.iad.mlsrvr.com (dynamic3.wm-web.iad1a.rsapps.net [192.168.2.152]) by smtp37.relay.iad1a.emailsrvr.com (SMTP Server) with ESMTP id 7347F3B043C for ; Sat, 16 Apr 2011 20:55:33 -0400 (EDT) Received: from meta-innovation.com (localhost [127.0.0.1]) by dynamic3.wm-web.iad.mlsrvr.com (Postfix) with ESMTP id 54A1A3320078 for ; Sat, 16 Apr 2011 20:55:33 -0400 (EDT) Received: by www2.webmail.us (Authenticated sender: nicola.pero@meta-innovation.com, from: nicola.pero@meta-innovation.com) with HTTP; Sun, 17 Apr 2011 02:55:33 +0200 (CEST) Date: Sun, 17 Apr 2011 07:27:00 -0000 Subject: Fix gengtype-state string hashtable From: "Nicola Pero" To: "gcc-patches@gnu.org" MIME-Version: 1.0 Content-Type: text/plain;charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Type: plain Message-ID: <1303001733.34455839@www2.webmail.us> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 207.97.245.171 X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2011-04/txt/msg01292.txt.bz2 While reading GCC code, I noticed that in gengtype-state.c the equality function in a string hashtable is set to strcmp. But that returns 0 (ie, false for hashtable.c) when the strings are equal! I can't see how that hashtable would ever work. Do we have any tests for gengtype-state ? Am I missing something ? :-) Else, Ok to commit the following patch ? Thanks Index: gengtype-state.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- gengtype-state.c (revision 172522) +++ gengtype-state.c (working copy) @@ -2385,7 +2385,16 @@ equals_type_number (const void *ty1, const void *t return type1->state_number =3D=3D type2->state_number; } =20 +static int +string_eq (const void *a, const void *b) +{ + const char *a0 =3D (const char *)a; + const char *b0 =3D (const char *)b; =20 + return (strcmp (a0, b0) =3D=3D 0); +} + + /* The function reading the state, called by main from gengtype.c. */ void read_state (const char *path) @@ -2408,7 +2417,7 @@ read_state (const char *path) state_seen_types =3D htab_create (2017, hash_type_number, equals_type_number, NULL); state_ident_tab =3D - htab_create (4027, htab_hash_string, (htab_eq) strcmp, NULL); + htab_create (4027, htab_hash_string, string_eq, NULL); read_state_version (version_string); read_state_srcdir (); read_state_languages (); Index: ChangeLog =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- ChangeLog (revision 172522) +++ ChangeLog (working copy) @@ -1,3 +1,9 @@ +2011-04-17 Nicola Pero + + * gengtype-state.c (string_eq): New. + (read_state): Use string_eq instead of strcmp when creating the + state_ident_tab. + 2011-04-15 Pat Haugen =20 * config/rs6000/rs6000.c (call_ABI_of_interest): Call