Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Remove useless comparison to NULL before freeing variables
Baptiste Daroussin committed 11 years ago
commit aed2ce730584438365bc3f0cb3a3460041863fc7
parent 71eb195
17 files changed +2 -35
modified libpkg/pkg.c
@@ -347,7 +347,6 @@ pkg_vset(struct pkg *pkg, va_list ap)
				    ucl_object_fromstring_common(data, strlen(data), 0),
				    pkg_keys[attr].name, strlen(pkg_keys[attr].name), false);

-
			if (buf != NULL)
				free(buf);

			break;
modified libpkg/pkg_audit.c
@@ -184,21 +184,16 @@ pkg_audit_free_entry(struct pkg_audit_entry *e)
			}

			LL_FOREACH_SAFE(ppkg->names, pname, pname_tmp) {
-
				if (pname->pkgname)
					free(pname->pkgname);
				free(pname);
			}
		}
		LL_FOREACH_SAFE(e->cve, cve, cve_tmp) {
-
			if (cve->cvename)
				free(cve->cvename);
			free(cve);
		}
-
		if (e->url)
			free(e->url);
-
		if (e->desc)
			free(e->desc);
-
		if (e->id)
			free(e->id);
	}
	free(e);
modified libpkg/pkg_cudf.c
@@ -518,7 +518,6 @@ pkg_jobs_cudf_parse_output(struct pkg_jobs *j, FILE *f)
		}
	}

-
	if (line != NULL)
		free(line);

	return (EPKG_OK);
modified libpkg/pkg_jobs.c
@@ -120,9 +120,7 @@ pkg_jobs_destdir(struct pkg_jobs *j)
static void
pkg_jobs_pattern_free(struct job_pattern *jp)
{
-
	if (jp->pattern != NULL)
		free(jp->pattern);
-
	if (jp->path != NULL)
		free(jp->path);

	free(jp);
@@ -659,7 +657,6 @@ pkg_jobs_try_remote_candidate(struct pkg_jobs *j, const char *pattern,
	}


-
	if (p != NULL)
		pkg_free(p);

	sbuf_free(qmsg);
modified libpkg/pkg_ports.c
@@ -460,7 +460,6 @@ setmod(struct plist *p, char *line, struct file_attr *a)
static int
setowner(struct plist *p, char *line, struct file_attr *a)
{
-
	if (p->uname != NULL)
		free(p->uname);
	if (line[0] == '\0')
		p->uname = strdup("root");
@@ -475,7 +474,6 @@ setowner(struct plist *p, char *line, struct file_attr *a)
static int
setgroup(struct plist *p, char *line, struct file_attr *a)
{
-
	if (p->gname != NULL)
		free(p->gname);
	if (line[0] == '\0')
		p->gname = strdup("wheel");
@@ -1126,11 +1124,8 @@ ports_parse_plist(struct pkg *pkg, const char *plist, const char *stage)

	HASH_FREE(pplist.keywords, keyword_free);

-
	if (pplist.pkgdep != NULL)
		free(pplist.pkgdep);
-
	if (pplist.uname != NULL)
		free(pplist.uname);
-
	if (pplist.gname != NULL)
		free(pplist.gname);
	free(pplist.post_patterns.buf);
	free(pplist.post_patterns.patterns);
modified libpkg/pkg_repo.c
@@ -606,7 +606,6 @@ pkg_repo_archive_extract_archive(int fd, const char *file,
		cbdata.need_sig = false;
		if (pkg_emit_sandbox_get_string(pkg_repo_meta_extract_signature_pubkey,
			&cbdata, (char **)&sig, &siglen) == EPKG_OK) {
-
			if (sig)
				free(sig);
		}
		else {
modified libpkg/pkg_repo_create.c
@@ -417,7 +417,6 @@ cleanup:
	close(mfd);
	if (read_files)
		close(ffd);
-
	if (mdigest)
		free(mdigest);

	pkg_debug(1, "worker done");
@@ -1094,7 +1093,6 @@ cleanup:
	pkg_emit_progress_tick(files_to_pack, files_to_pack);
	pkg_repo_meta_free(meta);

-
	if (rsa)
		rsa_free(rsa);

	return (ret);
modified libpkg/pkg_repo_meta.c
@@ -168,8 +168,7 @@ pkg_repo_meta_parse_cert(const ucl_object_t *obj)
#define META_EXTRACT_STRING(field) do { 						\
	obj = ucl_object_find_key(top, (#field)); 					\
	if (obj != NULL && obj->type == UCL_STRING) { 				\
-
	    if (meta->field != NULL) 								\
-
	    	free(meta->field);									\
+
	    free(meta->field);									\
	    meta->field = strdup(ucl_object_tostring(obj));			\
	}															\
} while (0)
modified libpkg/pkg_solve.c
@@ -932,7 +932,6 @@ pkg_solve_parse_sat_output(FILE *f, struct pkg_solve_problem *problem, struct pk
	}

	HASH_FREE(ordered_variables, free);
-
	if (line != NULL)
		free(line);
	return (ret);
}
modified libpkg/repo/binary/update.c
@@ -527,7 +527,6 @@ pkg_repo_binary_parse_conflicts(FILE *f, sqlite3 *sqlite)
		free(deps);
	}

-
	if (linebuf != NULL)
		free(linebuf);
}

modified src/annotate.c
@@ -382,9 +382,7 @@ exec_annotate(int argc, char **argv)
	}

cleanup:
-
	if (pkg != NULL)
		pkg_free(pkg);
-
	if (it != NULL)
		pkgdb_it_free(it);

	pkgdb_release_lock(db, PKGDB_LOCK_EXCLUSIVE);
modified src/check.c
@@ -186,7 +186,6 @@ fix_deps(struct pkgdb *db, struct deps_head *dh, int nbpkgs, bool yes)
	}

cleanup:
-
	if (pkgs != NULL)
		free(pkgs);
	if (jobs != NULL)
		pkg_jobs_free(jobs);
modified src/event.c
@@ -353,10 +353,8 @@ event_sandboxed_get_string(pkg_sandbox_cb func, char **result, int64_t *len,
void
progressbar_start(const char *pmsg)
{
-
	if (progress_message != NULL) {
-
		free(progress_message);
+
	free(progress_message);
		progress_message = NULL;
-
	}
	if (quiet)
		return;
	if (pmsg != NULL)
modified src/info.c
@@ -514,7 +514,6 @@ exec_info(int argc, char **argv)
	} while (i < argc);

cleanup:
-
	if (pkg != NULL)
		pkg_free(pkg);

	pkgdb_release_lock(db, PKGDB_LOCK_READONLY);
modified src/lock.c
@@ -245,9 +245,7 @@ exec_lock_unlock(int argc, char **argv, enum action action)
		exitcode = EX_IOERR;

cleanup:
-
	if (pkg != NULL)
		pkg_free(pkg);
-
	if (it != NULL)
		pkgdb_it_free(it);

	pkgdb_release_lock(db, PKGDB_LOCK_EXCLUSIVE);
modified src/query.c
@@ -998,7 +998,6 @@ exec_query(int argc, char **argv)
	}

cleanup:
-
	if (pkg != NULL)
		pkg_free(pkg);

	pkgdb_release_lock(db, PKGDB_LOCK_READONLY);
modified src/set.c
@@ -128,7 +128,6 @@ exec_set(int argc, char **argv)
			yes = true;
			break;
		default:
-
			if (oldorigin != NULL)
				free(oldorigin);
			
			usage_set();
@@ -250,10 +249,8 @@ exec_set(int argc, char **argv)
	} while (i < argc);

cleanup:
-
	if (oldorigin)
		free(oldorigin);

-
	if (pkg != NULL)
		pkg_free(pkg);

	pkgdb_release_lock(db, PKGDB_LOCK_EXCLUSIVE);