socsvn commit: r255055 - in soc2013/mattbw/backend: . query

mattbw at FreeBSD.org mattbw at FreeBSD.org
Tue Jul 23 08:56:28 UTC 2013


Author: mattbw
Date: Tue Jul 23 08:56:27 2013
New Revision: 255055
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255055

Log:
  added assertions for pkgutils and query/jobs.

Modified:
  soc2013/mattbw/backend/pkgutils.c
  soc2013/mattbw/backend/query/jobs.c

Modified: soc2013/mattbw/backend/pkgutils.c
==============================================================================
--- soc2013/mattbw/backend/pkgutils.c	Tue Jul 23 05:11:22 2013	(r255054)
+++ soc2013/mattbw/backend/pkgutils.c	Tue Jul 23 08:56:27 2013	(r255055)
@@ -37,6 +37,8 @@
 {
 	PkInfoEnum	info;
 	
+	assert(pkg != NULL);
+
 	/* If the package is local, then it's installed.  If it is remote, then
 	 * it is installed if it is the same version as an installed package,
 	 * and available if it is not.
@@ -60,6 +62,8 @@
 	PkInfoEnum	info;
 	const char     *old;
 
+	assert(pkg != NULL);
+
 	/* Sane default */
 	info = PK_INFO_ENUM_INSTALLING;
 
@@ -107,6 +111,8 @@
 {
 	char	       *result;
 
+	assert(pkg != NULL);
+
 	result = NULL;
 	(void)pkg_asprintf(&result, "%n-%v", pkg, pkg);
 	return result;
@@ -120,6 +126,8 @@
 {
 	const char     *repo;
 
+	assert(pkg != NULL);
+
 	switch (pkg_type(pkg)) {
 	case PKG_OLD_FILE:
 	case PKG_FILE:
@@ -172,6 +180,9 @@
 pkgutils_pkg_to_id_through(struct pkg *pkg, const char **strv)
 {
 
+	assert(pkg != NULL);
+	assert(strv != NULL);
+
 	pkg_get(pkg,
 	    PKG_NAME, strv + PK_PACKAGE_ID_NAME,
 	    PKG_VERSION, strv + PK_PACKAGE_ID_VERSION,
@@ -197,6 +208,9 @@
 	const char     *origin;
 	struct pkg     *pkg2;
 
+	assert(db != NULL);
+	assert(pkg != NULL);
+
 	origin = NULL;
 	pkg_get(pkg, PKG_ORIGIN, &origin);
 
@@ -215,6 +229,7 @@
 		*old_p = pkg2;
 	else
 		pkg_free(pkg2);
+	assert (old_p == NULL || pkg2 == NULL || *old_p != NULL);
 }
 
 /*
@@ -226,6 +241,9 @@
 	char           *comment;
 	gchar          *id;
 
+	assert(pkg != NULL);
+	assert(backend != NULL);
+
 	comment = id = NULL;
 
 	pkg_get(pkg, PKG_COMMENT, &comment);
@@ -241,7 +259,10 @@
 pkgutils_emit_filtered(struct pkg *pkg, PkBackend *backend, PkBitfield filters,
     PkInfoEnum info)
 {
-	gboolean should_emit;
+	gboolean	should_emit;
+
+	assert(pkg != NULL);
+	assert(backend != NULL);
 
 	should_emit = TRUE;
 
@@ -272,6 +293,9 @@
 	const char     *repo_name;
 	struct pkg_repo *repo_struct;
 
+	assert(pkg != NULL);
+	assert(pkg_type(pkg) == PKG_REMOTE);
+
 	repo = repo_name = NULL;
 	repo_struct = NULL;
 

Modified: soc2013/mattbw/backend/query/jobs.c
==============================================================================
--- soc2013/mattbw/backend/query/jobs.c	Tue Jul 23 05:11:22 2013	(r255054)
+++ soc2013/mattbw/backend/query/jobs.c	Tue Jul 23 08:56:27 2013	(r255055)
@@ -42,8 +42,14 @@
 	bool		success;
 	PkBackend      *backend;
 
+	assert(jobs != NULL);
+	assert(q != NULL);
+
 	success = false;
+
 	backend = query_backend(q);
+	assert(backend != NULL);
+
 	query_set_percentage(q, 0);
 
 	pkg_event_register(event_cb, backend);
@@ -74,15 +80,16 @@
 	struct pkg_jobs *jobs;
 	PkBackend      *backend;
 
-	assert (q != NULL);
-	assert (pkg != NULL);
 	assert (f != NULL);
+	assert (pkg != NULL);
+	assert (q != NULL);
 
 	success = false;
 	jobs = NULL;
 	namever = NULL;
 
 	backend = query_backend(q);
+	assert(backend != NULL);
 
 	if (pkg_jobs_new(&jobs, type, query_db(q)) != EPKG_OK) {
 		ERR(backend,
@@ -134,7 +141,11 @@
 	PkBackend      *backend;
 	struct pkg     *pkg;
 
+	assert(jobs != NULL);
+	assert(q != NULL);
+
 	backend = query_backend(q);
+	assert (backend != NULL);
 	query_set_percentage(q, 0);
 
 	(void)pk_backend_set_status(backend, PK_STATUS_ENUM_RUNNING);
@@ -152,6 +163,9 @@
 {
 	const char     *repo;
 
+	assert(jobs != NULL);
+	assert(q != NULL);
+	
 	repo = query_repo(q);
 
 	return (repo == NULL ? EPKG_OK : pkg_jobs_set_repository(jobs, repo));


More information about the svn-soc-all mailing list