krb5 commit: Free unconditionally in plugins.c

Greg Hudson ghudson at MIT.EDU
Fri Mar 29 11:41:37 EDT 2013


https://github.com/krb5/krb5/commit/f3de02250cdf2b912629b5420f83b937a62401be
commit f3de02250cdf2b912629b5420f83b937a62401be
Author: Greg Hudson <ghudson at mit.edu>
Date:   Fri Mar 29 02:53:27 2013 -0400

    Free unconditionally in plugins.c
    
    Get rid of unnecessary null checks before freeing values in
    libkrb5support's plugin code.

 src/util/support/plugins.c |   16 ++++++++--------
 1 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/util/support/plugins.c b/src/util/support/plugins.c
index 608d03c..a04dfc3 100644
--- a/src/util/support/plugins.c
+++ b/src/util/support/plugins.c
@@ -155,8 +155,8 @@ int closedir(DIR *dp)
 {
     if (!dp) return 0;
     _findclose(dp->handle);
-    if (dp->dir) free(dp->dir);
-    if (dp) free(dp);
+    free(dp->dir);
+    free(dp);
 
     return 0;
 }
@@ -317,7 +317,7 @@ krb5int_open_plugin (const char *filepath, struct plugin_file_handle **h, struct
         htmp = NULL;  /* h takes ownership */
     }
 
-    if (htmp != NULL) { free (htmp); }
+    free(htmp);
 
     return err;
 }
@@ -551,7 +551,7 @@ krb5int_get_plugin_filenames (const char * const *filebases, char ***filenames)
         tempnames = NULL;
     }
 
-    if (tempnames) { krb5int_free_plugin_filenames (tempnames); }
+    krb5int_free_plugin_filenames(tempnames);
 
     return err;
 }
@@ -602,7 +602,7 @@ krb5int_open_plugin_dirs (const char * const *dirnames,
                     if (!err) { handle = NULL; }  /* h takes ownership */
                 }
 
-                if (filepath != NULL) { free (filepath); }
+                free(filepath);
                 if (handle   != NULL) { krb5int_close_plugin (handle); }
             }
         } else {
@@ -637,7 +637,7 @@ krb5int_open_plugin_dirs (const char * const *dirnames,
                     }
                 }
 
-                if (filepath  != NULL) { free (filepath); }
+                free(filepath);
                 if (handle    != NULL) { krb5int_close_plugin (handle); }
             }
 
@@ -727,7 +727,7 @@ krb5int_get_plugin_dir_data (struct plugin_dir_handle *dirhandle,
         p = NULL; /* ptrs takes ownership */
     }
 
-    if (p != NULL) { free (p); }
+    free(p);
 
     return err;
 }
@@ -786,7 +786,7 @@ krb5int_get_plugin_dir_func (struct plugin_dir_handle *dirhandle,
         p = NULL; /* ptrs takes ownership */
     }
 
-    if (p != NULL) { free (p); }
+    free(p);
 
     return err;
 }


More information about the cvs-krb5 mailing list