From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15941 invoked by alias); 22 Sep 2010 09:43:35 -0000 Received: (qmail 15930 invoked by uid 22791); 22 Sep 2010 09:43:34 -0000 X-SWARE-Spam-Status: No, hits=-6.1 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,TW_BJ,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 22 Sep 2010 09:43:28 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o8M9hQRt010402 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 22 Sep 2010 05:43:26 -0400 Received: from host1.dyn.jankratochvil.net (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o8M9hOxX029085 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 22 Sep 2010 05:43:26 -0400 Received: from host1.dyn.jankratochvil.net (localhost [127.0.0.1]) by host1.dyn.jankratochvil.net (8.14.4/8.14.4) with ESMTP id o8M9hOJA020945 for ; Wed, 22 Sep 2010 11:43:24 +0200 Received: (from jkratoch@localhost) by host1.dyn.jankratochvil.net (8.14.4/8.14.4/Submit) id o8M9hNR4020944 for gdb-patches@sourceware.org; Wed, 22 Sep 2010 11:43:23 +0200 Date: Wed, 22 Sep 2010 17:01:00 -0000 From: Jan Kratochvil To: gdb-patches@sourceware.org Subject: [patch] Code cleanup: objfile->name is never NULL Message-ID: <20100922094323.GA20792@host1.dyn.jankratochvil.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-12-10) X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2010-09/txt/msg00372.txt.bz2 Hi, there is some FUD in GDB code whether objfile->name can be NULL. I haven't found a way it could be. Also a lot of GDB code already assumes it is not NULL. No regressions on {x86_64,x86_64-m32,i686}-fedora13-linux-gnu. I will check it in later. Thanks, Jan gdb/ 2010-09-22 Jan Kratochvil Code cleanup. * objfiles.c (allocate_objfile) name != NULL>: Remove. (free_objfile) name != NULL>: Remove the conditional around xfree. * objfiles.h (struct objfile) : New comment it is never NULL. * python/py-auto-load.c (auto_load_new_objfile) name>: Remove. * python/py-objfile.c (objfpy_get_filename) objfile->name> Remove the conditional. * python/py-progspace.c (pspy_get_filename) name>: Likewise. --- a/gdb/objfiles.c +++ b/gdb/objfiles.c @@ -214,10 +214,6 @@ allocate_objfile (bfd *abfd, int flags) region. */ objfile->obfd = gdb_bfd_ref (abfd); - if (objfile->name != NULL) - { - xfree (objfile->name); - } if (abfd != NULL) { /* Look up the gdbarch associated with the BFD. */ @@ -649,10 +645,7 @@ free_objfile (struct objfile *objfile) /* The last thing we do is free the objfile struct itself. */ - if (objfile->name != NULL) - { - xfree (objfile->name); - } + xfree (objfile->name); if (objfile->global_psymbols.list) xfree (objfile->global_psymbols.list); if (objfile->static_psymbols.list) --- a/gdb/objfiles.h +++ b/gdb/objfiles.h @@ -188,8 +188,8 @@ struct objfile struct objfile *next; - /* The object file's name, tilde-expanded and absolute. - Malloc'd; free it if you free this struct. */ + /* The object file's name, tilde-expanded and absolute. Malloc'd; free it + if you free this struct. This pointer is never NULL. */ char *name; --- a/gdb/python/py-auto-load.c +++ b/gdb/python/py-auto-load.c @@ -395,8 +395,6 @@ auto_load_new_objfile (struct objfile *objfile) clear_section_scripts (); return; } - if (!objfile->name) - return; load_auto_scripts_for_objfile (objfile); } --- a/gdb/python/py-objfile.c +++ b/gdb/python/py-objfile.c @@ -46,7 +46,7 @@ objfpy_get_filename (PyObject *self, void *closure) { objfile_object *obj = (objfile_object *) self; - if (obj->objfile && obj->objfile->name) + if (obj->objfile) return PyString_Decode (obj->objfile->name, strlen (obj->objfile->name), host_charset (), NULL); Py_RETURN_NONE; --- a/gdb/python/py-progspace.c +++ b/gdb/python/py-progspace.c @@ -52,7 +52,7 @@ pspy_get_filename (PyObject *self, void *closure) { struct objfile *objfile = obj->pspace->symfile_object_file; - if (objfile && objfile->name) + if (objfile) return PyString_Decode (objfile->name, strlen (objfile->name), host_charset (), NULL); }