diff --git a/file.c b/file.c
index a39300519700606f932231848be853be2078fdb7..b55c9546e881978f3eb2f7a522f668d5308a5de4 100644
--- a/file.c
+++ b/file.c
@@ -132,7 +132,7 @@ int ast_format_unregister(const char *name)
 	AST_LIST_TRAVERSE_SAFE_END
 	AST_LIST_UNLOCK(&formats);
 
-	if (tmp) {
+	if (!res) {
 		if (option_verbose > 1)
 			ast_verbose( VERBOSE_PREFIX_2 "Unregistered format %s\n", name);
 	} else