hal: Branch 'master'

Danny Kukawka dkukawka at kemper.freedesktop.org
Tue Jan 15 05:03:21 PST 2008


 hald/create_cache.c                            |   14 ++++----------
 hald/hald.c                                    |    4 ++--
 hald/hald_dbus.c                               |    5 +++--
 hald/hald_runner.c                             |    2 +-
 hald/ids.c                                     |    8 ++++----
 hald/linux/addons/addon-cpufreq-userspace.c    |   13 +++++++------
 hald/linux/addons/addon-cpufreq.c              |   23 ++++++++++++-----------
 hald/linux/addons/addon-input.c                |    2 +-
 hald/linux/addons/addon-macbook-backlight.c    |    2 +-
 hald/linux/addons/addon-macbookpro-backlight.c |    6 ++++--
 hald/linux/apm.c                               |    2 +-
 hald/linux/hotplug.c                           |    4 ++--
 hald/linux/probing/probe-smbios.c              |    4 ++--
 hald/util_pm.c                                 |    2 +-
 libhal-storage/libhal-storage.c                |    4 ++--
 libhal/libhal.c                                |    6 +++---
 tools/hal-storage-mount.c                      |    8 +++++---
 tools/hal_get_property.c                       |    2 +-
 tools/lshal.c                                  |    4 ++--
 19 files changed, 58 insertions(+), 57 deletions(-)

New commits:
commit 51a0fc50a40acaee62d7eff8e484fed9a3650df0
Author: Danny Kukawka <danny.kukawka at web.de>
Date:   Tue Jan 15 14:03:00 2008 +0100

    fix compiler warning from cgcc/sparse
    
    This fixes several compiler warnings from cgcc/spase.

diff --git a/hald/create_cache.c b/hald/create_cache.c
index 882de1b..3a6c99e 100644
--- a/hald/create_cache.c
+++ b/hald/create_cache.c
@@ -540,7 +540,7 @@ rules_search_and_add_fdi_files (const char *dir, int fd)
 
 	num_skipped_fdi_files = 0;
 
-	num_entries = scandir (dir, &name_list, 0, _alphasort);
+	num_entries = scandir (dir, &name_list, NULL, _alphasort);
 	if (num_entries == -1) {
 		HAL_ERROR (("Cannot scan '%s': %s", dir, strerror (errno)));
 		goto error;
@@ -604,8 +604,6 @@ error:
 }
 
 
-int haldc_force_recreate = 0;
-
 /* returns number of skipped fdi files or -1 on unrecoverable errors */
 static int
 di_rules_init (void)
@@ -717,15 +715,14 @@ error:
  *
  */
 static void
-usage ()
+usage (void)
 {
 	fprintf (stderr, "\n" "usage : hald-generate-fdi-cache [OPTION]\n");
 	fprintf (stderr,
 		 "\n"
-		 "	--force	       Force regeneration of cache.\n"
 		 "	--help		Show this information and exit.\n"
-		 "	--verbose	     Show verbose rule processing output.\n"
-		 "	--version	     Output version information and exit.\n"
+		 "	--verbose	Show verbose rule processing output.\n"
+		 "	--version	Output version information and exit.\n"
 		 "\n"
 		 "hald-generate-fdi-cache is a tool to generate binary cache from FDI files.\n"
 		 "\n"
@@ -746,7 +743,6 @@ int main(int argc, char * argv[])
 		static struct option long_options[] = {
 			{"help", 0, NULL, 0},
 			{"version", 0, NULL, 0},
-			{"force", 0, NULL, 0},
 			{"verbose", 0, NULL, 0},
 			{NULL, 0, NULL, 0}
 		};
@@ -768,8 +764,6 @@ int main(int argc, char * argv[])
 				return 0;
 			} else if (strcmp (opt, "verbose") == 0) {
 				haldc_verbose = 1;
-			} else if (strcmp (opt, "force") == 0) {
-				haldc_force_recreate = 1;
 			}
 			break;
 
diff --git a/hald/hald.c b/hald/hald.c
index 438f02b..4cec63c 100644
--- a/hald/hald.c
+++ b/hald/hald.c
@@ -260,7 +260,7 @@ hald_get_tdl (void)
  * Print out program usage.
  */
 static void
-usage ()
+usage (void)
 {
 	fprintf (stderr, "\n" "usage : hald [--daemon=yes|no] [--verbose=yes|no] [--help]\n");
 	fprintf (stderr,
@@ -293,7 +293,7 @@ static dbus_bool_t opt_retain_privileges = FALSE;
 /** If #TRUE, we will spew out debug */
 dbus_bool_t hald_is_verbose = FALSE;
 dbus_bool_t hald_use_syslog = FALSE;
-dbus_bool_t hald_debug_exit_after_probing = FALSE;
+static dbus_bool_t hald_debug_exit_after_probing = FALSE;
 
 #ifdef HAVE_POLKIT
 PolKitContext *pk_context;
diff --git a/hald/hald_dbus.c b/hald/hald_dbus.c
index 2498368..558ae9e 100644
--- a/hald/hald_dbus.c
+++ b/hald/hald_dbus.c
@@ -3127,6 +3127,7 @@ device_claim_interface (DBusConnection * connection, DBusMessage * message, dbus
 	DBusError error;
 	const char *interface_name;
 	const char *introspection_xml;
+	HelperInterfaceHandler *hih;
 	dbus_bool_t res;
 	
 	HAL_TRACE (("entering"));
@@ -3167,7 +3168,7 @@ device_claim_interface (DBusConnection * connection, DBusMessage * message, dbus
 
 	hal_device_property_strlist_add (device, "info.interfaces", interface_name);
 
-	HelperInterfaceHandler *hih = g_new0 (HelperInterfaceHandler, 1);
+	hih = g_new0 (HelperInterfaceHandler, 1);
 	hih->connection = connection;
 	hih->interface_name = g_strdup (interface_name);
 	hih->introspection_xml = g_strdup (introspection_xml);
@@ -4381,6 +4382,7 @@ do_introspect (DBusConnection  *connection,
 				       "  </interface>\n");
 	} else {
 		HalDevice *d;
+		HalDeviceStrListIter if_iter;
 
 		d = hal_device_store_find (hald_get_gdl (), path);
 		if (d == NULL)
@@ -4552,7 +4554,6 @@ do_introspect (DBusConnection  *connection,
 				       "    </signal>\n"
 
 				       "  </interface>\n");
-			HalDeviceStrListIter if_iter;
 
 			for (hal_device_property_strlist_iter_init (d, "info.interfaces", &if_iter);
 			     hal_device_property_strlist_iter_is_valid (&if_iter);
diff --git a/hald/hald_runner.c b/hald/hald_runner.c
index db708e4..f74dea1 100644
--- a/hald/hald_runner.c
+++ b/hald/hald_runner.c
@@ -938,7 +938,7 @@ hald_runner_kill_device (HalDevice * device)
 }
 
 void
-hald_runner_kill_all ()
+hald_runner_kill_all (void)
 {
 	DBusMessage *msg, *reply;
 	DBusError err;
diff --git a/hald/ids.c b/hald/ids.c
index 9949eab..b29df3b 100644
--- a/hald/ids.c
+++ b/hald/ids.c
@@ -56,7 +56,7 @@ static size_t pci_ids_iter_pos;
 
 /** Initialize the pci.ids line iterator to the beginning of the file */
 static void
-pci_ids_line_iter_init ()
+pci_ids_line_iter_init (void)
 {
 	pci_ids_iter_pos = 0;
 }
@@ -103,7 +103,7 @@ pci_ids_line_iter_get_line (unsigned int *line_len)
  *  See if there are more lines to process in pci.ids 
  */
 static dbus_bool_t
-pci_ids_line_iter_has_more ()
+pci_ids_line_iter_has_more (void)
 {
 	return pci_ids_iter_pos < pci_ids_len;
 }
@@ -339,7 +339,7 @@ static size_t usb_ids_iter_pos;
 
 /** Initialize the usb.ids line iterator to the beginning of the file */
 static void
-usb_ids_line_iter_init ()
+usb_ids_line_iter_init (void)
 {
 	usb_ids_iter_pos = 0;
 }
@@ -386,7 +386,7 @@ usb_ids_line_iter_get_line (unsigned int *line_len)
  *  See if there are more lines to process in usb.ids
  */
 static dbus_bool_t
-usb_ids_line_iter_has_more ()
+usb_ids_line_iter_has_more (void)
 {
 	return usb_ids_iter_pos < usb_ids_len;
 }
diff --git a/hald/linux/addons/addon-cpufreq-userspace.c b/hald/linux/addons/addon-cpufreq-userspace.c
index af1ef73..ab1680f 100644
--- a/hald/linux/addons/addon-cpufreq-userspace.c
+++ b/hald/linux/addons/addon-cpufreq-userspace.c
@@ -46,10 +46,10 @@
 #define DEFAULT_CONSIDER_NICE		FALSE
 #define PROC_STAT_FILE			"/proc/stat"
 
-const char SYSFS_SCALING_SETSPEED_FILE[] =
+static const char SYSFS_SCALING_SETSPEED_FILE[] =
      "/sys/devices/system/cpu/cpu%u/cpufreq/scaling_setspeed";
 
-const char SYSFS_SCALING_AVAILABLE_FREQS_FILE[] =
+static const char SYSFS_SCALING_AVAILABLE_FREQS_FILE[] =
      "/sys/devices/system/cpu/cpu%u/cpufreq/scaling_available_frequencies";
 
 /* shortcut for g_array_index */
@@ -115,7 +115,7 @@ static int calc_cpu_load(const int consider_nice)
 	char		line[256];
 	char		cpu_string[7];
 	FILE		*fp;
-	int		new_num_cpus;
+	int		new_num_cpus, i;
 
 	new_num_cpus = sysconf(_SC_NPROCESSORS_CONF);
 	if (new_num_cpus == -1 || new_num_cpus != cpuload.num_cpus) {
@@ -141,8 +141,9 @@ static int calc_cpu_load(const int consider_nice)
 	/* start with the first line, "overall" cpu load */
 	/* if cpuload.num_cpus == 1, we do not need to evaluate "overall" and "per-cpu" load */
 	sprintf(cpu_string, "cpu ");
-	int i;
+
 	for (i = 0; i <= cpuload.num_cpus - (cpuload.num_cpus == 1); i++) {
+		unsigned long working_time;
 		
 		if (fgets(line,255,fp) == NULL) {
 			HAL_WARNING(("%s too short (%s)", PROC_STAT_FILE, cpu_string));
@@ -166,7 +167,6 @@ static int calc_cpu_load(const int consider_nice)
 			return -1;
 		}
 
-		unsigned long working_time;
 		if (consider_nice) {
 			working_time = user_time + system_time + nice_time;
 			idle_time += iowait_time;
@@ -403,10 +403,11 @@ static gboolean adjust_speed(struct userspace_interface *iface)
 /* create the hysteresis array */
 static void create_hysteresis_array(struct userspace_interface *iface)
 {
+	int i;
+	
 	g_array_free(iface->demotion, TRUE);
 	iface->demotion = g_array_new(TRUE, TRUE, sizeof(unsigned));
 
-	int i;
 	if (iface->last_step > 0) {
 		for (i = 0; i < iface->last_step; i++) {
 			int demotion = (config.up_threshold - HYSTERESIS) *
diff --git a/hald/linux/addons/addon-cpufreq.c b/hald/linux/addons/addon-cpufreq.c
index f9690e1..04021df 100644
--- a/hald/linux/addons/addon-cpufreq.c
+++ b/hald/linux/addons/addon-cpufreq.c
@@ -49,22 +49,22 @@
 #define CPUFREQ_ERROR_NO_SUITABLE_GOVERNOR	"NoSuitableGovernor"
 #define CPUFREQ_ERROR_GOVERNOR_INIT_FAILED	"GovernorInitFailed"
 
-const char SYSFS_GOVERNOR_FILE[] =
+static const char SYSFS_GOVERNOR_FILE[] =
      "/sys/devices/system/cpu/cpu%u/cpufreq/scaling_governor";
 
-const char SYSFS_AVAILABLE_GOVERNORS_FILE[] =
+static const char SYSFS_AVAILABLE_GOVERNORS_FILE[] =
      "/sys/devices/system/cpu/cpu%u/cpufreq/scaling_available_governors";
 
-const char ONDEMAND_UP_THRESHOLD_FILE[] =
+static const char ONDEMAND_UP_THRESHOLD_FILE[] =
      "/sys/devices/system/cpu/cpu%u/cpufreq/ondemand/up_threshold";
 
-const char SYSFS_AFFECTED_CPUS_FILE[] =
+static const char SYSFS_AFFECTED_CPUS_FILE[] =
      "/sys/devices/system/cpu/cpu%u/cpufreq/affected_cpus";
 
-const char SYSFS_CPU_ONLINE_FILE[] =
+static const char SYSFS_CPU_ONLINE_FILE[] =
      "/sys/devices/system/cpu/cpu%u/online";
 
-const char ONDEMAND_IGNORE_NICE_LOAD_FILE[] =
+static const char ONDEMAND_IGNORE_NICE_LOAD_FILE[] =
      "/sys/devices/system/cpu/cpu%u/cpufreq/ondemand/ignore_nice_load";
 
 static gboolean dbus_raise_error(DBusConnection *connection, DBusMessage *message,
@@ -223,11 +223,12 @@ static void cpu_list_unique(gpointer data, gpointer whole_list)
 
 	for (it = *list; it != NULL; it = g_slist_next(it)) {
 		gboolean equal = TRUE;
+		GSList *list_it = NULL;
+		GSList *current_it = NULL;
+		
 		if (current == it->data)
 			continue;
 
-		GSList *list_it = NULL;
-		GSList *current_it = NULL;
 		for (list_it = it->data, current_it = current;
 		     list_it != NULL && current_it != NULL;
 		     list_it = g_slist_next(list_it), current_it = g_slist_next(current_it)) {
@@ -1315,9 +1316,9 @@ int main(int argc, char *argv[])
 	sigaddset(&signal_action.sa_mask, SIGTERM);
 	signal_action.sa_flags = SA_RESTART || SA_NOCLDSTOP;
 	signal_action.sa_handler = exit_handler;
-	sigaction(SIGINT, &signal_action, 0);
-	sigaction(SIGQUIT, &signal_action, 0);
-	sigaction(SIGTERM, &signal_action, 0);
+	sigaction(SIGINT, &signal_action, NULL);
+	sigaction(SIGQUIT, &signal_action, NULL);
+	sigaction(SIGTERM, &signal_action, NULL);
 
 	if (!is_supported()) {
 		HAL_WARNING(("CPUFreq not supported. Exiting..."));
diff --git a/hald/linux/addons/addon-input.c b/hald/linux/addons/addon-input.c
index 525cd76..0474802 100644
--- a/hald/linux/addons/addon-input.c
+++ b/hald/linux/addons/addon-input.c
@@ -311,7 +311,7 @@ destroy_data (InputData *data)
 
 
 static void
-update_proc_title ()
+update_proc_title (void)
 {
 	GList *lp;
 	gchar *new_command_line, *p;
diff --git a/hald/linux/addons/addon-macbook-backlight.c b/hald/linux/addons/addon-macbook-backlight.c
index 3f51b3f..f18ba05 100644
--- a/hald/linux/addons/addon-macbook-backlight.c
+++ b/hald/linux/addons/addon-macbook-backlight.c
@@ -72,7 +72,7 @@
 #define ACCESS_OFFSET         (REGISTER_OFFSET & PAGE_MASK)
 #define ACCESS_INDEX          (ACCESS_OFFSET >> 2)
 
-unsigned int *register_page;
+static unsigned int *register_page;
 
 static unsigned long
 determine_video_base_address (void)
diff --git a/hald/linux/addons/addon-macbookpro-backlight.c b/hald/linux/addons/addon-macbookpro-backlight.c
index a72024c..534f4f9 100644
--- a/hald/linux/addons/addon-macbookpro-backlight.c
+++ b/hald/linux/addons/addon-macbookpro-backlight.c
@@ -477,6 +477,9 @@ main (int argc, char *argv[])
  	size_t length = 0;
  	int fd;
  	int state;
+	struct pci_access *pacc;
+ 	struct pci_dev *dev;
+
 	DBusError err;
 
 	setup_logger ();
@@ -511,10 +514,9 @@ main (int argc, char *argv[])
  	/* address = 0x90300000; */
  	/* length = 0x20000; */
 
- 	struct pci_access *pacc = pci_alloc();
+ 	pacc = pci_alloc();
  	pci_init(pacc);
  	pci_scan_bus(pacc);
- 	struct pci_dev *dev;
  	for(dev=pacc->devices; dev; dev=dev->next) {	/* Iterate over all devices */
  		pci_fill_info(dev, PCI_FILL_IDENT | PCI_FILL_BASES);
  		if ((dev->vendor_id == 0x1002) && (dev->device_id == 0x71c5)) { // ATI X1600
diff --git a/hald/linux/apm.c b/hald/linux/apm.c
index 79c54ad..32a831a 100644
--- a/hald/linux/apm.c
+++ b/hald/linux/apm.c
@@ -41,7 +41,7 @@ enum {
 	APM_TYPE_AC_ADAPTER
 };
 
-int interval_poll_round = 0;
+static int interval_poll_round = 0;
 
 typedef struct APMDevHandler_s
 {
diff --git a/hald/linux/hotplug.c b/hald/linux/hotplug.c
index 56db041..239ac31 100644
--- a/hald/linux/hotplug.c
+++ b/hald/linux/hotplug.c
@@ -50,10 +50,10 @@
 #include "hotplug.h"
 
 /** Queue of ordered hotplug events */
-GQueue *hotplug_event_queue;
+static GQueue *hotplug_event_queue;
 
 /** List of HotplugEvent objects we are currently processing */
-GSList *hotplug_events_in_progress = NULL;
+static GSList *hotplug_events_in_progress = NULL;
 
 void
 hotplug_event_end (void *end_token)
diff --git a/hald/linux/probing/probe-smbios.c b/hald/linux/probing/probe-smbios.c
index 2fffd23..addbde6 100644
--- a/hald/linux/probing/probe-smbios.c
+++ b/hald/linux/probing/probe-smbios.c
@@ -48,8 +48,8 @@
 #define strbegin(buf, str) (strncmp (buf, str, strlen (str)) == 0)
 
 /* global */
-char *udi = NULL;
-LibHalContext *ctx = NULL;
+static char *udi = NULL;
+static LibHalContext *ctx = NULL;
 
 /** 
  *  setstr:
diff --git a/hald/util_pm.c b/hald/util_pm.c
index a5a0e12..72fa9f5 100644
--- a/hald/util_pm.c
+++ b/hald/util_pm.c
@@ -43,7 +43,7 @@ typedef struct {
 	time_t last_time;
 } batteryInfo;
 
-GHashTable *saved_battery_info = NULL;
+static GHashTable *saved_battery_info = NULL;
 
 /**  
  *  util_get_battery_technology_
diff --git a/libhal-storage/libhal-storage.c b/libhal-storage/libhal-storage.c
index 4da5564..19394ad 100644
--- a/libhal-storage/libhal-storage.c
+++ b/libhal-storage/libhal-storage.c
@@ -68,7 +68,7 @@ struct LibHalStoragePolicy_s {
 };
 
 LibHalStoragePolicy *
-libhal_storage_policy_new ()
+libhal_storage_policy_new (void)
 {
 	LibHalStoragePolicy *p;
 
@@ -1984,7 +1984,7 @@ mopts_collect (LibHalContext *hal_ctx, const char *namespace, int namespace_len,
 	LibHalPropertySetIterator it;
 	DBusError error;
 
-	if(hal_ctx == 0) {
+	if(hal_ctx == NULL) {
 		fprintf (stderr,"%s %d : LibHalContext *ctx is NULL\n",__FILE__, __LINE__);
 		return;
 	}
diff --git a/libhal/libhal.c b/libhal/libhal.c
index 8ad8d49..75a431b 100644
--- a/libhal/libhal.c
+++ b/libhal/libhal.c
@@ -3150,7 +3150,7 @@ libhal_find_device_by_capability (LibHalContext *ctx,
 	DBusError _error;
 
 	LIBHAL_CHECK_LIBHALCONTEXT(ctx, NULL);
-	LIBHAL_CHECK_PARAM_VALID(capability, "*capability", FALSE);
+	LIBHAL_CHECK_PARAM_VALID(capability, "*capability", NULL);
 
 	message = dbus_message_new_method_call ("org.freedesktop.Hal",
 						"/org/freedesktop/Hal/Manager",
@@ -3369,7 +3369,7 @@ libhal_ctx_set_dbus_connection (LibHalContext *ctx, DBusConnection *conn)
 DBusConnection *
 libhal_ctx_get_dbus_connection (LibHalContext *ctx)
 {
-	LIBHAL_CHECK_LIBHALCONTEXT(ctx, FALSE);
+	LIBHAL_CHECK_LIBHALCONTEXT(ctx, NULL);
 
 	return ctx->connection;
 }
@@ -4123,7 +4123,7 @@ libhal_device_new_changeset (const char *udi)
 {
 	LibHalChangeSet *changeset;
 
-	LIBHAL_CHECK_UDI_VALID(udi, FALSE);
+	LIBHAL_CHECK_UDI_VALID(udi, NULL);
 
 	changeset = calloc (1, sizeof (LibHalChangeSet));
 	if (changeset == NULL)
diff --git a/tools/hal-storage-mount.c b/tools/hal-storage-mount.c
index bfe14a9..3220734 100644
--- a/tools/hal-storage-mount.c
+++ b/tools/hal-storage-mount.c
@@ -458,6 +458,8 @@ handle_mount (LibHalContext *hal_ctx,
 	GError *err = NULL;
 	char *sout = NULL;
 	char *serr = NULL;
+	char *mount_option_commasep = NULL;
+	char *mount_do_fstype = NULL;
 	int exit_status;
 	char *args[10];
 	int na;
@@ -732,11 +734,9 @@ handle_mount (LibHalContext *hal_ctx,
 	}
 
 
-	char *mount_option_commasep = NULL;
-	char *mount_do_fstype = "auto";
-
 	/* construct arguments to mount */
 	na = 0;
+	
 	args[na++] = MOUNT;
 	if (strlen (mount_fstype) > 0) {
 		mount_do_fstype = (char *) map_fstype (mount_fstype);
@@ -745,6 +745,8 @@ handle_mount (LibHalContext *hal_ctx,
 		mount_do_fstype = "auto";
 	} else if (libhal_volume_get_fstype (volume) != NULL && strlen (libhal_volume_get_fstype (volume)) > 0) {
 		mount_do_fstype = (char *) map_fstype (libhal_volume_get_fstype (volume));
+	} else {
+		mount_do_fstype = "auto";
 	}
 	args[na++] = MOUNT_TYPE_OPT;
 	args[na++] = mount_do_fstype;
diff --git a/tools/hal_get_property.c b/tools/hal_get_property.c
index 0160924..ecaa6ce 100644
--- a/tools/hal_get_property.c
+++ b/tools/hal_get_property.c
@@ -217,7 +217,7 @@ main (int argc, char *argv[])
 		
 		if ((strlist = libhal_device_get_property_strlist (hal_ctx, udi, key, &error)) != NULL) {
 			
-			for (i = 0; strlist[i] != 0; i++) {
+			for (i = 0; strlist[i] != NULL; i++) {
 				printf ("%s", strlist[i]);
 				if (strlist[i+1] != NULL)
 					printf (" ");
diff --git a/tools/lshal.c b/tools/lshal.c
index 78cd0e6..3bd3990 100644
--- a/tools/lshal.c
+++ b/tools/lshal.c
@@ -171,7 +171,7 @@ print_props (const char *udi)
 			printf ("  %s = {", libhal_psi_get_key (&it));
 
 			strlist = libhal_psi_get_strlist (&it);
-			for (i = 0; strlist[i] != 0; i++) {
+			for (i = 0; strlist[i] != NULL; i++) {
 				printf ("'%s'", strlist[i]);
 				if (strlist[i+1] != NULL)
 					printf (", ");
@@ -482,7 +482,7 @@ print_property (const char *udi, const char *key)
 		strlist = libhal_device_get_property_strlist (hal_ctx, udi, key, &error);
                 /* may be NULL because property may have been removed */
                 if (strlist != NULL) {
-                        for (i = 0; strlist[i] != 0; i++) {
+                        for (i = 0; strlist[i] != NULL; i++) {
                                 printf ("'%s'", strlist[i]);
                                 if (strlist[i+1] != NULL)
                                         printf (", ");


More information about the hal-commit mailing list