Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 7 Apr 2019 11:55:11 +0000 (UTC)
From:      Toomas Soome <tsoome@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r346000 - head/stand/common
Message-ID:  <201904071155.x37BtBQL089709@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: tsoome
Date: Sun Apr  7 11:55:11 2019
New Revision: 346000
URL: https://svnweb.freebsd.org/changeset/base/346000

Log:
  loader: remove pointer checks before free() in module.c
  
  free() does check for NULL argument, remove duplicate checks.
  
  MFC after:	1w

Modified:
  head/stand/common/module.c

Modified: head/stand/common/module.c
==============================================================================
--- head/stand/common/module.c	Sun Apr  7 11:50:41 2019	(r345999)
+++ head/stand/common/module.c	Sun Apr  7 11:55:11 2019	(r346000)
@@ -534,8 +534,7 @@ mod_load(char *modname, struct mod_depend *verinfo, in
 	mp = file_findmodule(NULL, modname, verinfo);
 	if (mp) {
 #ifdef moduleargs
-		if (mp->m_args)
-			free(mp->m_args);
+		free(mp->m_args);
 		mp->m_args = unargv(argc, argv);
 #endif
 		snprintf(command_errbuf, sizeof(command_errbuf),
@@ -961,18 +960,14 @@ file_discard(struct preloaded_file *fp)
 	}
 	mp = fp->f_modules;
 	while (mp) {
-		if (mp->m_name)
-			free(mp->m_name);
+		free(mp->m_name);
 		mp1 = mp;
 		mp = mp->m_next;
 		free(mp1);
 	}
-	if (fp->f_name != NULL)
-		free(fp->f_name);
-	if (fp->f_type != NULL)
-		free(fp->f_type);
-	if (fp->f_args != NULL)
-		free(fp->f_args);
+	free(fp->f_name);
+	free(fp->f_type);
+	free(fp->f_args);
 	free(fp);
 }
 
@@ -1055,10 +1050,8 @@ moduledir_readhints(struct moduledir *mdp)
 	return;
 bad:
 	close(fd);
-	if (mdp->d_hints) {
-		free(mdp->d_hints);
-		mdp->d_hints = NULL;
-	}
+	free(mdp->d_hints);
+	mdp->d_hints = NULL;
 	mdp->d_flags |= MDIR_NOHINTS;
 	return;
 }
@@ -1119,8 +1112,7 @@ moduledir_rebuild(void)
 		if ((mdp->d_flags & MDIR_REMOVED) == 0) {
 			mdp = STAILQ_NEXT(mdp, d_link);
 		} else {
-			if (mdp->d_hints)
-				free(mdp->d_hints);
+			free(mdp->d_hints);
 			mtmp = mdp;
 			mdp = STAILQ_NEXT(mdp, d_link);
 			STAILQ_REMOVE(&moduledir_list, mtmp, moduledir, d_link);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201904071155.x37BtBQL089709>