socsvn commit: r255099 - in soc2013/mattbw/backend: . actions query

mattbw at FreeBSD.org mattbw at FreeBSD.org
Wed Jul 24 09:12:47 UTC 2013


Author: mattbw
Date: Wed Jul 24 09:12:46 2013
New Revision: 255099
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255099

Log:
  add some more null-assertions

Modified:
  soc2013/mattbw/backend/actions/get_details.c
  soc2013/mattbw/backend/actions/get_files.c
  soc2013/mattbw/backend/actions/get_repo_list.c
  soc2013/mattbw/backend/actions/install_packages.c
  soc2013/mattbw/backend/actions/remove_packages.c
  soc2013/mattbw/backend/event.h
  soc2013/mattbw/backend/pk-backend-pkgng.c
  soc2013/mattbw/backend/query/core.c
  soc2013/mattbw/backend/query/jobs.c

Modified: soc2013/mattbw/backend/actions/get_details.c
==============================================================================
--- soc2013/mattbw/backend/actions/get_details.c	Wed Jul 24 08:56:59 2013	(r255098)
+++ soc2013/mattbw/backend/actions/get_details.c	Wed Jul 24 09:12:46 2013	(r255099)
@@ -18,6 +18,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
+#include <assert.h>		/* assert */
 #include <glib.h>
 #include <stdbool.h>
 #include <stdint.h>
@@ -42,6 +43,8 @@
 {
 	bool		success;
 
+	assert(backend != NULL);
+
 	success = query_match_id_to_emitter(backend, LOAD_FLAGS, emit);
 	(void)pk_backend_finished(backend);
 	return success ? TRUE : FALSE;
@@ -50,7 +53,7 @@
 /*
  * Emits the given package's details. To be used as an iterating function.
  */
-static		bool
+static bool
 emit(struct pkg *pkg, const gchar *id, struct query *q)
 {
 	bool		success;
@@ -59,6 +62,10 @@
 	int64_t		flatsize;
 	guint		flatsize_u;
 
+	assert(pkg != NULL);
+	assert(id != NULL);
+	assert(q != NULL);
+
 	query_set_percentage(q, 0);
 
 	/* Information not already part of the PackageID */

Modified: soc2013/mattbw/backend/actions/get_files.c
==============================================================================
--- soc2013/mattbw/backend/actions/get_files.c	Wed Jul 24 08:56:59 2013	(r255098)
+++ soc2013/mattbw/backend/actions/get_files.c	Wed Jul 24 09:12:46 2013	(r255099)
@@ -18,16 +18,15 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
-#include <stdbool.h>
+#include <assert.h>		/* assert */
 #include <glib.h>
+#include <stdbool.h>
 #include <sys/sbuf.h>
-
 #include "../pk-backend.h"
 #include "pkg.h"
 
-#include "../query.h"		/* query_... */
-
 #include "../actions.h"		/* get_files_thread prototype */
+#include "../query.h"		/* query_... */
 
 static const unsigned int LOAD_FLAGS = PKG_LOAD_BASIC | PKG_LOAD_FILES;
 
@@ -42,6 +41,8 @@
 {
 	gboolean success;
 
+	assert(backend != NULL);
+
 	(void)pk_backend_set_status(backend, PK_STATUS_ENUM_QUERY);
 	success = query_match_id_to_emitter(backend, LOAD_FLAGS, emit);
 
@@ -59,6 +60,10 @@
 	struct pkg_file *file;
 	struct sbuf    *sb;
 
+	assert(pkg != NULL);
+	assert(id != NULL);
+	assert(q != NULL);
+
 	query_set_percentage(q, 0);
 
 	success = false;
@@ -69,6 +74,8 @@
 	 * rid of the initial ; later.
 	 */
 	sb = sbuf_new_auto();
+	assert(sb != NULL);
+
 	while (pkg_files(pkg, &file) == EPKG_OK)
 		sbuf_printf(sb, ";%s", pkg_file_path(file));
 

Modified: soc2013/mattbw/backend/actions/get_repo_list.c
==============================================================================
--- soc2013/mattbw/backend/actions/get_repo_list.c	Wed Jul 24 08:56:59 2013	(r255098)
+++ soc2013/mattbw/backend/actions/get_repo_list.c	Wed Jul 24 09:12:46 2013	(r255099)
@@ -18,6 +18,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
+#include <assert.h>		/* assert */
 #include <glib.h>
 #include "../pk-backend.h"
 #include "pkg.h"
@@ -33,15 +34,19 @@
 {
 	struct pkg_repo *repo;
 
+	assert(backend != NULL);
+
 	(void)pk_backend_set_status(backend, PK_STATUS_ENUM_QUERY);
 	(void)pk_backend_set_percentage(backend, 0);
 
 	repo = NULL;
-	while (pkg_repos(&repo) == EPKG_OK)
+	while (pkg_repos(&repo) == EPKG_OK) {
+		assert(backend != NULL);
 		(void)pk_backend_repo_detail(backend,
 		    pkg_repo_ident(repo),
 		    pkg_repo_name(repo),
 		    pkg_repo_enabled(repo));
+	}
 
 	(void)pk_backend_set_percentage(backend, 100);
 	(void)pk_backend_finished(backend);

Modified: soc2013/mattbw/backend/actions/install_packages.c
==============================================================================
--- soc2013/mattbw/backend/actions/install_packages.c	Wed Jul 24 08:56:59 2013	(r255098)
+++ soc2013/mattbw/backend/actions/install_packages.c	Wed Jul 24 09:12:46 2013	(r255099)
@@ -18,6 +18,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
+#include <assert.h>		/* assert */
 #include <glib.h>		/* gboolean */
 #include <stdbool.h>		/* bool, true, false */
 #include "../pk-backend.h"	/* pk..., Pk... */
@@ -39,6 +40,8 @@
 {
 	bool		success;
 
+	assert(backend != NULL);
+
 	(void)pk_backend_set_status(backend, PK_STATUS_ENUM_QUERY);
 	success = query_match_id_to_job(backend, PKG_JOBS_INSTALL, job);
 
@@ -55,6 +58,8 @@
 {
 	bool		success;
 
+	assert(backend != NULL);
+
 	(void)pk_backend_set_status(backend, PK_STATUS_ENUM_QUERY);
 	success = query_match_id_to_job(backend, PKG_JOBS_INSTALL, sim_job);
 
@@ -69,6 +74,9 @@
 job(struct pkg_jobs *jobs, struct query *q)
 {
 
+	assert(jobs != NULL);
+	assert(q != NULL);
+
 	return query_jobs_apply_emitter(jobs,
 	    q,
 	    PK_STATUS_ENUM_INSTALL,
@@ -83,6 +91,9 @@
 sim_job(struct pkg_jobs *jobs, struct query *q)
 {
 
+	assert(jobs != NULL);
+	assert(q != NULL);
+
 	return query_jobs_simulate_emitter(jobs,
 	    q,
 	    pkgutils_pkg_install_state);

Modified: soc2013/mattbw/backend/actions/remove_packages.c
==============================================================================
--- soc2013/mattbw/backend/actions/remove_packages.c	Wed Jul 24 08:56:59 2013	(r255098)
+++ soc2013/mattbw/backend/actions/remove_packages.c	Wed Jul 24 09:12:46 2013	(r255099)
@@ -18,6 +18,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
+#include <assert.h>		/* assert */
 #include <glib.h>		/* gboolean */
 #include <stdbool.h>		/* bool, true, false */
 #include "../pk-backend.h"	/* pk..., Pk... */

Modified: soc2013/mattbw/backend/event.h
==============================================================================
--- soc2013/mattbw/backend/event.h	Wed Jul 24 08:56:59 2013	(r255098)
+++ soc2013/mattbw/backend/event.h	Wed Jul 24 09:12:46 2013	(r255099)
@@ -1,5 +1,4 @@
 /*-
- *
  * Copyright (C) 2013 Matt Windsor <mattbw at FreeBSD.org>
  *
  * Licensed under the GNU General Public License Version 2

Modified: soc2013/mattbw/backend/pk-backend-pkgng.c
==============================================================================
--- soc2013/mattbw/backend/pk-backend-pkgng.c	Wed Jul 24 08:56:59 2013	(r255098)
+++ soc2013/mattbw/backend/pk-backend-pkgng.c	Wed Jul 24 09:12:46 2013	(r255099)
@@ -19,7 +19,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
-#include <gmodule.h>
+#include <assert.h>		/* assert */
 #include <glib.h>
 #include <string.h>
 #include <stdlib.h>
@@ -38,11 +38,12 @@
 {
 	int		err;
 
+	assert(backend != NULL);
 	err = EPKG_OK;
 
 	if (!pkg_initialized())
 		err = pkg_init(NULL);
-	if (err)
+	if (err != EPKG_OK)
 		ERR(backend, PK_ERROR_ENUM_INTERNAL_ERROR, "couldn't init pkg");
 }
 
@@ -90,6 +91,7 @@
 {
 
 	INTENTIONALLY_IGNORE(package_ids);	/* retrieved from backend */
+	assert(backend != NULL);
 	THREAD(backend, get_details_thread);
 }
 
@@ -98,6 +100,7 @@
 {
 
 	INTENTIONALLY_IGNORE(package_ids);	/* retrieved from backend */
+	assert(backend != NULL);
 	THREAD(backend, get_files_thread);
 }
 
@@ -142,6 +145,7 @@
 {
 
 	INTENTIONALLY_IGNORE(filters);	/* not yet supported */
+	assert(backend != NULL);
 	THREAD(backend, get_repo_list_thread);
 }
 
@@ -150,6 +154,7 @@
 {
 
 	INTENTIONALLY_IGNORE(package_ids);	/* retrieved from backend */
+	assert(backend != NULL);
 	THREAD(backend, get_update_detail_thread);
 }
 
@@ -160,6 +165,7 @@
 
 	INTENTIONALLY_IGNORE(only_trusted);	/* not yet supported */
 	INTENTIONALLY_IGNORE(full_paths);	/* retrieved from backend */
+	assert(backend != NULL);
 	THREAD(backend, install_files_thread);
 }
 
@@ -170,6 +176,7 @@
 
 	INTENTIONALLY_IGNORE(only_trusted);	/* not yet supported */
 	INTENTIONALLY_IGNORE(package_ids);	/* retrieved from backend */
+	assert(backend != NULL);
 	THREAD(backend, install_packages_thread);
 }
 
@@ -177,7 +184,8 @@
 pk_backend_refresh_cache(PkBackend *backend, gboolean force)
 {
 
-	(void)pk_backend_set_bool(backend, "force", force);
+	INTENTIONALLY_IGNORE(force);		/* retrieved from backend */
+	assert(backend != NULL);
 	THREAD(backend, refresh_cache_thread);
 }
 
@@ -189,6 +197,7 @@
 	INTENTIONALLY_IGNORE(package_ids);	/* retrieved from backend */
 	INTENTIONALLY_IGNORE(allow_deps);	/* not yet supported */
 	INTENTIONALLY_IGNORE(autoremove);	/* not yet supported */
+	assert(backend != NULL);
 	THREAD(backend, remove_packages_thread);
 }
 
@@ -198,6 +207,7 @@
 
 	INTENTIONALLY_IGNORE(filters);		/* retrieved from backend */
 	INTENTIONALLY_IGNORE(package_ids);	/* retrieved from backend */
+	assert(backend != NULL);
 	THREAD(backend, resolve_thread);
 }
 
@@ -207,6 +217,7 @@
 
 	INTENTIONALLY_IGNORE(filters);		/* retrieved from backend */
 	INTENTIONALLY_IGNORE(search);		/* retrieved from backend */
+	assert(backend != NULL);
 	THREAD(backend, search_files_thread);
 }
 
@@ -216,6 +227,7 @@
 
 	INTENTIONALLY_IGNORE(filters);		/* retrieved from backend */
 	INTENTIONALLY_IGNORE(search);		/* retrieved from backend */
+	assert(backend != NULL);
 	THREAD(backend, search_groups_thread);
 }
 
@@ -225,6 +237,7 @@
 
 	INTENTIONALLY_IGNORE(filters);		/* retrieved from backend */
 	INTENTIONALLY_IGNORE(search);		/* retrieved from backend */
+	assert(backend != NULL);
 	THREAD(backend, search_names_thread);
 }
 
@@ -233,6 +246,7 @@
 {
 
 	INTENTIONALLY_IGNORE(full_paths);	/* retrieved from backend */
+	assert(backend != NULL);
 	THREAD(backend, simulate_install_files_thread);
 }
 

Modified: soc2013/mattbw/backend/query/core.c
==============================================================================
--- soc2013/mattbw/backend/query/core.c	Wed Jul 24 08:56:59 2013	(r255098)
+++ soc2013/mattbw/backend/query/core.c	Wed Jul 24 09:12:46 2013	(r255099)
@@ -150,6 +150,7 @@
 const char *
 query_repo(struct query *q)
 {
+	
 	assert(q != NULL);
 
 	return (q->rtype == REPO_REMOTE ?
@@ -426,6 +427,9 @@
 {
 	gchar         **id_strv;
 
+	assert(backend != NULL);
+	assert(s != NULL);
+
 	id_strv = NULL;
 	if (s->type == QUERY_SINGLE_NAME) {
 		/*

Modified: soc2013/mattbw/backend/query/jobs.c
==============================================================================
--- soc2013/mattbw/backend/query/jobs.c	Wed Jul 24 08:56:59 2013	(r255098)
+++ soc2013/mattbw/backend/query/jobs.c	Wed Jul 24 09:12:46 2013	(r255099)
@@ -150,8 +150,10 @@
 
 	(void)pk_backend_set_status(backend, PK_STATUS_ENUM_RUNNING);
 	pkg = NULL;
-	while (pkg_jobs(jobs, &pkg) == EPKG_OK)
+	while (pkg_jobs(jobs, &pkg) == EPKG_OK) {
+		assert(pkg != NULL);
 		pkgutils_emit(pkg, backend, info(pkg));
+	}
 
 	query_set_percentage(q, 100);
 	return true;    	
@@ -165,7 +167,7 @@
 
 	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