diff options
author | Jim Meyering <meyering@redhat.com> | 2009-12-04 09:07:29 +0100 |
---|---|---|
committer | Jim Meyering <meyering@redhat.com> | 2009-12-04 09:20:39 +0100 |
commit | ac30aea14477c4b9e73e78987418ef5faf3526dd (patch) | |
tree | 1881897bd9ca2998a56e093bd28206f92ed58584 /src | |
parent | 196b828887ae5a92e695b8a75501aacdd5370122 (diff) | |
download | grep-ac30aea14477c4b9e73e78987418ef5faf3526dd.tar.gz |
maint: enable useless-if-before-free check
* cfg.mk (local-checks-to-skip): Enable sc_avoid_if_before_free.
* .x-sc_avoid_if_before_free: New file. Exempt regex.c and dfa.c,
in case anyone ever tries to merge their contents with other versions.
* src/grep.c (print_line_middle, grepdir): Remove useless if-before-free.
* src/search.c (IF_BK, EXECUTE_FCT): Likewise.
Diffstat (limited to 'src')
-rw-r--r-- | src/grep.c | 6 | ||||
-rw-r--r-- | src/search.c | 13 |
2 files changed, 7 insertions, 12 deletions
@@ -854,8 +854,7 @@ print_line_middle (const char *beg, const char *lim, cur = b + match_size; } - if (buf) - free(buf); /* XXX */ + free (buf); /* XXX */ if (only_matching) cur = lim; @@ -1388,8 +1387,7 @@ grepdir (char const *dir, struct stats const *stats) status &= grepfile (file, &child); } out_file -= !no_filenames; - if (file) - free (file); + free (file); free (name_space); } diff --git a/src/search.c b/src/search.c index b011cc77..f4a9598c 100644 --- a/src/search.c +++ b/src/search.c @@ -273,8 +273,7 @@ GEAcompile (char const *pattern, size_t size, reg_syntax_t syntax_bits) dfacomp (pattern, size, &dfa, 1); kwsmusts (); - if (motif) - free((char *) motif); + free((char *) motif); } #ifndef EGREP_PROGRAM @@ -479,9 +478,8 @@ EXECUTE_FCT(EGexecute) if (MB_CUR_MAX > 1) { if (match_icase) - free((char*)buf); - if (mb_properties) - free(mb_properties); + free ((char *) buf); + free (mb_properties); } #endif /* MBS_SUPPORT */ return ret_val; @@ -595,9 +593,8 @@ EXECUTE_FCT(Fexecute) if (MB_CUR_MAX > 1) { if (match_icase) - free((char*)buf); - if (mb_properties) - free(mb_properties); + free ((char *) buf); + free (mb_properties); } #endif /* MBS_SUPPORT */ return ret_val; |