tools: Remove redundant NULL checks before free() (found by Smatch).

Michael Stefaniuc mstefani at redhat.de
Mon Sep 4 16:50:01 CDT 2006


---
 tools/widl/parser.y       |    2 +-
 tools/winedump/msmangle.c |    2 +-
 tools/winedump/search.c   |    7 ++-----
 tools/winedump/symbol.c   |   14 ++++----------
 tools/wmc/write.c         |    3 +--
 tools/wrc/parser.y        |    6 ++----
 6 files changed, 11 insertions(+), 23 deletions(-)

diff --git a/tools/widl/parser.y b/tools/widl/parser.y
index ead02cb..eec883b 100644
--- a/tools/widl/parser.y
+++ b/tools/widl/parser.y
@@ -1175,7 +1175,7 @@ static typeref_t *uniq_tref(typeref_t *r
 static type_t *type_ref(typeref_t *ref)
 {
   type_t *t = ref->ref;
-  if (ref->name) free(ref->name);
+  free(ref->name);
   free(ref);
   return t;
 }
diff --git a/tools/winedump/msmangle.c b/tools/winedump/msmangle.c
index 0857595..c330b8c 100644
--- a/tools/winedump/msmangle.c
+++ b/tools/winedump/msmangle.c
@@ -37,7 +37,7 @@ typedef struct _compound_type
 #define INIT_CT(ct) do { memset (&ct, 0, sizeof (ct)); } while (0)
 
 /* free the memory used by a compound structure */
-#define FREE_CT(ct) do { if (ct.expression) free (ct.expression); } while (0)
+#define FREE_CT(ct) free (ct.expression)
 
 /* Flags for data types */
 #define DATA_VTABLE   0x1
diff --git a/tools/winedump/search.c b/tools/winedump/search.c
index d9b15f2..8ae82de 100644
--- a/tools/winedump/search.c
+++ b/tools/winedump/search.c
@@ -348,10 +348,7 @@ #ifdef __GNUC__
 void search_cleanup (void) __attribute__ ((destructor));
 void search_cleanup (void)
 {
-  if (grep_buff)
-    free (grep_buff);
-
-  if (fgrep_buff)
-    free (fgrep_buff);
+  free (grep_buff);
+  free (fgrep_buff);
 }
 #endif
diff --git a/tools/winedump/symbol.c b/tools/winedump/symbol.c
index 7336ed7..c79442f 100644
--- a/tools/winedump/symbol.c
+++ b/tools/winedump/symbol.c
@@ -109,19 +109,13 @@ void symbol_clear(parsed_symbol *sym)
  assert (sym->symbol);
 
  free (sym->symbol);
-
- if (sym->return_text)
-   free (sym->return_text);
-
- if (sym->function_name)
-   free (sym->function_name);
+ free (sym->return_text);
+ free (sym->function_name);
 
  for (i = sym->argc - 1; i >= 0; i--)
  {
-   if (sym->arg_text [i])
-     free (sym->arg_text [i]);
-   if (sym->arg_name [i])
-     free (sym->arg_name [i]);
+   free (sym->arg_text [i]);
+   free (sym->arg_name [i]);
  }
  memset (sym, 0, sizeof (parsed_symbol));
 }
diff --git a/tools/wmc/write.c b/tools/wmc/write.c
index b6da9af..5a8cd71 100644
--- a/tools/wmc/write.c
+++ b/tools/wmc/write.c
@@ -274,8 +274,7 @@ void write_h_file(const char *fname)
 				internal_error(__FILE__, __LINE__, "Invalid base for number print");
 			}
 			free(cptr);
-			if(cast)
-				free(cast);
+			free(cast);
 			break;
 		default:
 			internal_error(__FILE__, __LINE__, "Invalid node type %d", ndp->type);
diff --git a/tools/wrc/parser.y b/tools/wrc/parser.y
index bc7409e..ff37dcf 100644
--- a/tools/wrc/parser.y
+++ b/tools/wrc/parser.y
@@ -2906,10 +2906,8 @@ #endif
 
 	free(lanfnt);
 clean:
-	if(fnt)
-		free(fnt);
-	if(fnd)
-		free(fnd);
+	free(fnt);
+	free(fnd);
 	free(str.str.cstr);
 	return lst;
 }
-- 
1.4.1


-- 
Michael Stefaniuc               Tel.: +49-711-96437-199
Sr. Network Engineer            Fax.: +49-711-96437-111
Red Hat GmbH                    Email: mstefani at redhat.com
Hauptstaetterstr. 58            http://www.redhat.de/
D-70178 Stuttgart
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://www.winehq.org/pipermail/wine-patches/attachments/20060904/378d613d/attachment.pgp


More information about the wine-patches mailing list