From 046957830e176ad16fdef39bc7f1cd44d8fbc3b7 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Wed, 20 Apr 2011 18:19:03 +0000 Subject: remove useless if-before-free tests Change "if (E) free (E);" to "free (E);" everywhere except in the libgo/, intl/, zlib/ and classpath/ directories. Also transform equivalent variants like "if (E != NULL) free (E);" and allow an extra cast on the argument to free. Otherwise, the tested and freed "E" expressions must be identical, modulo white space. From-SVN: r172785 --- libgfortran/io/fbuf.c | 3 +-- libgfortran/io/format.c | 3 +-- libgfortran/io/open.c | 3 +-- libgfortran/io/unit.c | 9 +++------ libgfortran/io/unix.c | 3 +-- 5 files changed, 7 insertions(+), 14 deletions(-) (limited to 'libgfortran/io') diff --git a/libgfortran/io/fbuf.c b/libgfortran/io/fbuf.c index 82b3f6b..353e5ae 100644 --- a/libgfortran/io/fbuf.c +++ b/libgfortran/io/fbuf.c @@ -51,8 +51,7 @@ fbuf_destroy (gfc_unit * u) { if (u->fbuf == NULL) return; - if (u->fbuf->buf) - free (u->fbuf->buf); + free (u->fbuf->buf); free (u->fbuf); u->fbuf = NULL; } diff --git a/libgfortran/io/format.c b/libgfortran/io/format.c index 5760e0c..518dc80 100644 --- a/libgfortran/io/format.c +++ b/libgfortran/io/format.c @@ -149,8 +149,7 @@ save_parsed_format (st_parameter_dt *dtp) free_format_data (u->format_hash_table[hash].hashed_fmt); u->format_hash_table[hash].hashed_fmt = NULL; - if (u->format_hash_table[hash].key != NULL) - free (u->format_hash_table[hash].key); + free (u->format_hash_table[hash].key); u->format_hash_table[hash].key = get_mem (dtp->format_len); memcpy (u->format_hash_table[hash].key, dtp->format, dtp->format_len); diff --git a/libgfortran/io/open.c b/libgfortran/io/open.c index bcf7941..b26d14d 100644 --- a/libgfortran/io/open.c +++ b/libgfortran/io/open.c @@ -688,8 +688,7 @@ already_open (st_parameter_open *opp, gfc_unit * u, unit_flags * flags) } u->s = NULL; - if (u->file) - free (u->file); + free (u->file); u->file = NULL; u->file_len = 0; diff --git a/libgfortran/io/unit.c b/libgfortran/io/unit.c index 1d52217..e8a9b84 100644 --- a/libgfortran/io/unit.c +++ b/libgfortran/io/unit.c @@ -483,11 +483,9 @@ free_internal_unit (st_parameter_dt *dtp) if (dtp->u.p.current_unit != NULL) { - if (dtp->u.p.current_unit->ls != NULL) - free (dtp->u.p.current_unit->ls); + free (dtp->u.p.current_unit->ls); - if (dtp->u.p.current_unit->s) - free (dtp->u.p.current_unit->s); + free (dtp->u.p.current_unit->s); destroy_unit_mutex (dtp->u.p.current_unit); } @@ -652,8 +650,7 @@ close_unit_1 (gfc_unit *u, int locked) delete_unit (u); - if (u->file) - free (u->file); + free (u->file); u->file = NULL; u->file_len = 0; diff --git a/libgfortran/io/unix.c b/libgfortran/io/unix.c index 4295071..ee2fd17 100644 --- a/libgfortran/io/unix.c +++ b/libgfortran/io/unix.c @@ -850,8 +850,7 @@ mem_flush (unix_stream * s __attribute__ ((unused))) static int mem_close (unix_stream * s) { - if (s != NULL) - free (s); + free (s); return 0; } -- cgit v1.1