]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
log.c:__lxc_log_set_file: fname cannot be null
authorSerge Hallyn <serge.hallyn@ubuntu.com>
Mon, 15 Feb 2016 20:15:10 +0000 (12:15 -0800)
committerSerge Hallyn <serge.hallyn@ubuntu.com>
Mon, 15 Feb 2016 20:15:10 +0000 (12:15 -0800)
fname cannot be passed in as NULL by any of its current callers.  If it
could, then build_dir() would crash as it doesn't check for it.  So make
sure we are warned if in the future we pass in NULL.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
src/lxc/log.c

index 20be5ac07b2599321adbecbd8d10d610cde4ed2a..babaebc84f27c0008a0d88e6d2d4f1fc23a8257f 100644 (file)
@@ -20,6 +20,7 @@
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
+#include <assert.h>
 #include <stdio.h>
 #include <errno.h>
 #include <limits.h>
@@ -268,7 +269,9 @@ static int __lxc_log_set_file(const char *fname, int create_dirs)
                free(log_fname);
        }
 
-       if (!fname || strlen(fname) == 0) {
+       assert(fname != NULL);
+
+       if (strlen(fname) == 0) {
                log_fname = NULL;
                return 0;
        }