From: Jan Kratochvil Date: Wed, 22 Sep 2010 20:00:53 +0000 (+0000) Subject: gdb/ X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=d31d2fc374b0523049655a0038cbdf1b43827edf;p=binutils-gdb.git gdb/ 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. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 8505e8b4432..9f959c176da 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,16 @@ +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. + 2010-09-22 Jan Kratochvil * main.c: Include objfiles.h. diff --git a/gdb/objfiles.c b/gdb/objfiles.c index 7d5186f1788..076827619c8 100644 --- 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) diff --git a/gdb/objfiles.h b/gdb/objfiles.h index ec4870b27a7..b3e2e26faac 100644 --- 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; diff --git a/gdb/python/py-auto-load.c b/gdb/python/py-auto-load.c index 044d968b575..538e06d7bcd 100644 --- 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); } diff --git a/gdb/python/py-objfile.c b/gdb/python/py-objfile.c index 1aa6a4dabca..14735038864 100644 --- 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; diff --git a/gdb/python/py-progspace.c b/gdb/python/py-progspace.c index 87245328c83..2c8a677b709 100644 --- 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); }