[PATCH] Fix usage of CD_OBJECT_SCOPE_* enums



Disk-scope devices apparently haven't been working for a while!

I noticed also that disk-scope profiles are supposed to error out with
"persistent profiles are not yet supported" -- is this still the case?

Thanks,
-John Sheu

>From 91c46a4d68e236bff14c625abeb2b2ebc4cb9f0c Mon Sep 17 00:00:00 2001
From: John Sheu <john sheu gmail com>
Date: Sat, 24 Mar 2012 04:13:25 -0700
Subject: [PATCH] Fix usage of CD_OBJECT_SCOPE_* enums

Some usages of these were using bitmask tests -- bad since these are
defined numerically.
---
 src/cd-main.c |   14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/src/cd-main.c b/src/cd-main.c
index 2ef3613..aef3402 100644
--- a/src/cd-main.c
+++ b/src/cd-main.c
@@ -216,21 +216,25 @@ cd_main_create_profile (const gchar *sender,
 		goto out;

 	/* different persistent scope */
-	if (scope == CD_OBJECT_SCOPE_NORMAL) {
+	switch (scope) {
+	case CD_OBJECT_SCOPE_NORMAL:
 		g_debug ("CdMain: normal profile");
-	} else if ((scope & CD_OBJECT_SCOPE_TEMP) > 0) {
+		break;
+	case CD_OBJECT_SCOPE_TEMP:
 		g_debug ("CdMain: temporary profile");
 		/* setup DBus watcher */
 		cd_profile_watch_sender (profile_tmp, sender);
-	} else if ((scope & CD_OBJECT_SCOPE_DISK) > 0) {
+		break;
+	case CD_OBJECT_SCOPE_DISK:
 		g_debug ("CdMain: persistent profile");
 		g_set_error_literal (error,
 				     CD_MAIN_ERROR,
 				     CD_MAIN_ERROR_FAILED,
 				     "persistent profiles are no yet supported");
 		goto out;
-	} else {
+	default:
 		g_warning ("CdMain: Unsupported scope kind: %i", scope);
+		goto out;
 	}

 	/* success */
@@ -486,7 +490,7 @@ cd_main_create_device (const gchar *sender,
 		goto out;

 	/* setup DBus watcher */
-	if (sender != NULL && (scope & CD_OBJECT_SCOPE_TEMP) > 0) {
+	if (sender != NULL && scope == CD_OBJECT_SCOPE_TEMP) {
 		g_debug ("temporary device");
 		cd_device_watch_sender (device_tmp, sender);
 	}
-- 
1.7.3.4


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]