socsvn commit: r255056 - in soc2013/mattbw/backend: . actions

mattbw at FreeBSD.org mattbw at FreeBSD.org
Tue Jul 23 09:10:45 UTC 2013


Author: mattbw
Date: Tue Jul 23 09:10:44 2013
New Revision: 255056
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255056

Log:
  more null assertions; use 'search' instead of 'values' in searching actions so we don't need to store the search in the backend twice.

Modified:
  soc2013/mattbw/backend/actions/search_files.c
  soc2013/mattbw/backend/actions/search_groups.c
  soc2013/mattbw/backend/actions/search_names.c
  soc2013/mattbw/backend/event.c
  soc2013/mattbw/backend/group.c
  soc2013/mattbw/backend/pk-backend-pkgng.c
  soc2013/mattbw/backend/search.c

Modified: soc2013/mattbw/backend/actions/search_files.c
==============================================================================
--- soc2013/mattbw/backend/actions/search_files.c	Tue Jul 23 08:56:27 2013	(r255055)
+++ soc2013/mattbw/backend/actions/search_files.c	Tue Jul 23 09:10:44 2013	(r255056)
@@ -74,6 +74,8 @@
 		if (it != NULL) {
 			while (pkgdb_it_next(it, &pkg, PKG_LOAD_BASIC)
 			    == EPKG_OK) {
+			    	assert(pkg != NULL);
+
 				pkgutils_emit(pkg, backend,
 					pkgutils_pkg_current_state(pkg));
 				at_least_one = true;

Modified: soc2013/mattbw/backend/actions/search_groups.c
==============================================================================
--- soc2013/mattbw/backend/actions/search_groups.c	Tue Jul 23 08:56:27 2013	(r255055)
+++ soc2013/mattbw/backend/actions/search_groups.c	Tue Jul 23 09:10:44 2013	(r255056)
@@ -18,6 +18,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
+#include <assert.h>		/* assert */
 #include "../pk-backend.h"
 #include "pkg.h"
 
@@ -41,6 +42,8 @@
 	gchar         **values;
 	struct search	search;
 
+	assert(backend != NULL);
+
 	search.db = NULL;
 	groupv = NULL;
 	it = NULL;
@@ -55,7 +58,12 @@
 	if (search.db == NULL)
 		goto cleanup;
 
-	values = pk_backend_get_strv(backend, "values");
+	values = pk_backend_get_strv(backend, "search");
+	if (values == NULL) {
+		ERR(backend, PK_ERROR_ENUM_INTERNAL_ERROR, "search was NULL");
+		goto cleanup;
+	}
+
 	groupc = g_strv_length(values);
 	if (groupc == 0) {
 		ERR(backend, PK_ERROR_ENUM_INTERNAL_ERROR, "no values");

Modified: soc2013/mattbw/backend/actions/search_names.c
==============================================================================
--- soc2013/mattbw/backend/actions/search_names.c	Tue Jul 23 08:56:27 2013	(r255055)
+++ soc2013/mattbw/backend/actions/search_names.c	Tue Jul 23 09:10:44 2013	(r255056)
@@ -18,6 +18,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
+#include <assert.h>		/* assert */
 #include "../pk-backend.h"
 #include "pkg.h"
 
@@ -35,6 +36,8 @@
 	gboolean	success;
 	struct search	search;
 
+	assert(backend != NULL);
+
 	success = FALSE;
 	(void)pk_backend_set_status(backend, PK_STATUS_ENUM_QUERY);
 	(void)pk_backend_set_percentage(backend, 0);
@@ -54,7 +57,8 @@
 		guint		len;
 		gchar         **values;
 
-		values = pk_backend_get_strv(backend, "values");
+		values = pk_backend_get_strv(backend, "search");
+		assert(values != NULL);
 		len = g_strv_length(values);
 
 		success = TRUE;

Modified: soc2013/mattbw/backend/event.c
==============================================================================
--- soc2013/mattbw/backend/event.c	Tue Jul 23 08:56:27 2013	(r255055)
+++ soc2013/mattbw/backend/event.c	Tue Jul 23 09:10:44 2013	(r255056)
@@ -18,6 +18,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
+#include <assert.h>		/* assert */
 #include "pk-backend.h"		/* pk_..., Pk... */
 #include "pkg.h"		/* pkg... */
 
@@ -34,6 +35,9 @@
 {
 	PkBackend      *backend;
 
+	assert(backend_v != NULL);
+	assert(event != NULL);
+
 	backend = (PkBackend *)backend_v;
 
 	switch (event->type) {

Modified: soc2013/mattbw/backend/group.c
==============================================================================
--- soc2013/mattbw/backend/group.c	Tue Jul 23 08:56:27 2013	(r255055)
+++ soc2013/mattbw/backend/group.c	Tue Jul 23 09:10:44 2013	(r255056)
@@ -125,6 +125,8 @@
 	char           *regex;
 	struct sbuf    *sb;
 
+	assert(groupv != NULL);
+
 	regex = NULL;
 	sb = sbuf_new_auto();
 	if (sb != NULL) {
@@ -171,6 +173,10 @@
 static int
 map_compare(const void *key, const void *mapping)
 {
+
+	assert(key != NULL);
+	assert(mapping != NULL);
+
 	return strcmp((const char *)key,
 	    ((const struct group_mapping *)mapping)->key);
 }

Modified: soc2013/mattbw/backend/pk-backend-pkgng.c
==============================================================================
--- soc2013/mattbw/backend/pk-backend-pkgng.c	Tue Jul 23 08:56:27 2013	(r255055)
+++ soc2013/mattbw/backend/pk-backend-pkgng.c	Tue Jul 23 09:10:44 2013	(r255056)
@@ -211,20 +211,20 @@
 }
 
 void
-pk_backend_search_groups(PkBackend *backend, PkBitfield filters, gchar **values)
+pk_backend_search_groups(PkBackend *backend, PkBitfield filters, gchar **search)
 {
 
 	INTENTIONALLY_IGNORE(filters);		/* retrieved from backend */
-	(void)pk_backend_set_strv(backend, "values", values);
+	INTENTIONALLY_IGNORE(search);		/* retrieved from backend */
 	THREAD(backend, search_groups_thread);
 }
 
 void
-pk_backend_search_names(PkBackend *backend, PkBitfield filters, gchar **values)
+pk_backend_search_names(PkBackend *backend, PkBitfield filters, gchar **search)
 {
 
 	INTENTIONALLY_IGNORE(filters);		/* retrieved from backend */
-	(void)pk_backend_set_strv(backend, "values", values);
+	INTENTIONALLY_IGNORE(search);		/* retrieved from backend */
 	THREAD(backend, search_names_thread);
 }
 

Modified: soc2013/mattbw/backend/search.c
==============================================================================
--- soc2013/mattbw/backend/search.c	Tue Jul 23 08:56:27 2013	(r255055)
+++ soc2013/mattbw/backend/search.c	Tue Jul 23 09:10:44 2013	(r255056)
@@ -18,6 +18,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
+#include <assert.h>		/* assert */
 #include <stdbool.h>		/* bool */
 #include "pkg.h" 		/* pkg_... */
 
@@ -34,6 +35,8 @@
 	bool		success;
 	struct pkgdb_it *it;
 
+	assert(search != NULL);
+
 	success = false;
 	it = pkgdb_search(search->db,
 	    search->term,
@@ -47,6 +50,8 @@
 
 		pkg = NULL;
 		while (pkgdb_it_next(it, &pkg, PKG_LOAD_BASIC) == EPKG_OK) {
+			assert(pkg != NULL);
+
 			pkgutils_add_old_version(search->db, pkg, NULL);
 			pkgutils_emit_filtered(pkg,
 			    search->backend,


More information about the svn-soc-all mailing list