Re: [Linuxwacom-devel] libwacom: [PATCH] lib: constify parameters in API

2012-12-03 Thread Peter Hutterer
On Thu, Nov 29, 2012 at 07:07:18PM +0100, Olivier Fourdan wrote:
> [...]
> 
> Olivier Fourdan said the following on 11/29/2012 05:49 PM:
> >>sorry, I didn't spot this earlier, this should be const WacomDevice *device.
> >>>  (only noticed that when doing some printf testing on my device). Given 
> >>> that
> >>>  is_builtin, is_reversible, etc aren't const we should update all of them 
> >>> in
> >>>  a follow-up patch.
> >>>
> >Yes, I simply copy/pasted from one of the previous functions... I'll
> >send a separate global "constification" patch.
> 
> The /big/ constification patch... goes on top of the integration bits.

applied, thanks.

Cheers,
   Peter

> From 36a4afefcc4fcf89fa7c1e917c97926e3945a152 Mon Sep 17 00:00:00 2001
> From: Olivier Fourdan 
> Date: Thu, 29 Nov 2012 18:52:36 +0100
> Subject: [PATCH] lib: constify parameters in API
> 
> Signed-off-by: Olivier Fourdan 
> ---
>  libwacom/libwacom-database.c |2 +-
>  libwacom/libwacom.c  |   86 -
>  libwacom/libwacom.h  |   70 +-
>  3 files changed, 78 insertions(+), 80 deletions(-)
> 
> diff --git a/libwacom/libwacom-database.c b/libwacom/libwacom-database.c
> index e0ee52e..9813a4e 100644
> --- a/libwacom/libwacom-database.c
> +++ b/libwacom/libwacom-database.c
> @@ -622,7 +622,7 @@ libwacom_database_destroy(WacomDeviceDatabase *db)
>  }
>  
>  WacomDevice**
> -libwacom_list_devices_from_database(WacomDeviceDatabase *db, WacomError 
> *error)
> +libwacom_list_devices_from_database(const WacomDeviceDatabase *db, 
> WacomError *error)
>  {
>   GList *cur, *devices;
>   WacomDevice **list, **p;
> diff --git a/libwacom/libwacom.c b/libwacom/libwacom.c
> index 23f3b08..b03fe0b 100644
> --- a/libwacom/libwacom.c
> +++ b/libwacom/libwacom.c
> @@ -48,7 +48,7 @@
>  #endif
>  
>  static const WacomDevice *
> -libwacom_get_device(WacomDeviceDatabase *db, const char *match)
> +libwacom_get_device(const WacomDeviceDatabase *db, const char *match)
>  {
>   return (WacomDevice *) g_hash_table_lookup (db->device_ht, match);
>  }
> @@ -337,7 +337,7 @@ libwacom_copy(const WacomDevice *device)
>  
>  
>  static int
> -compare_matches(WacomDevice *a, WacomDevice *b)
> +compare_matches(const WacomDevice *a, const WacomDevice *b)
>  {
>   const WacomMatch **ma, **mb, **match_a, **match_b;
>  
> @@ -359,7 +359,7 @@ compare_matches(WacomDevice *a, WacomDevice *b)
>  
>  /* Compare layouts based on file name, stripping the full path */
>  static gboolean
> -libwacom_same_layouts (WacomDevice *a, WacomDevice *b)
> +libwacom_same_layouts (const WacomDevice *a, const WacomDevice *b)
>  {
>   gchar *file1, *file2;
>  
> @@ -378,7 +378,7 @@ libwacom_same_layouts (WacomDevice *a, WacomDevice *b)
>  }
>  
>  int
> -libwacom_compare(WacomDevice *a, WacomDevice *b, WacomCompareFlags flags)
> +libwacom_compare(const WacomDevice *a, const WacomDevice *b, 
> WacomCompareFlags flags)
>  {
>   g_return_val_if_fail(a || b, 0);
>  
> @@ -442,7 +442,7 @@ libwacom_compare(WacomDevice *a, WacomDevice *b, 
> WacomCompareFlags flags)
>  }
>  
>  static const WacomDevice *
> -libwacom_new (WacomDeviceDatabase *db, int vendor_id, int product_id, 
> WacomBusType bus, WacomError *error)
> +libwacom_new (const WacomDeviceDatabase *db, int vendor_id, int product_id, 
> WacomBusType bus, WacomError *error)
>  {
>   const WacomDevice *device;
>   char *match;
> @@ -460,7 +460,7 @@ libwacom_new (WacomDeviceDatabase *db, int vendor_id, int 
> product_id, WacomBusTy
>  }
>  
>  WacomDevice*
> -libwacom_new_from_path(WacomDeviceDatabase *db, const char *path, 
> WacomFallbackFlags fallback, WacomError *error)
> +libwacom_new_from_path(const WacomDeviceDatabase *db, const char *path, 
> WacomFallbackFlags fallback, WacomError *error)
>  {
>   int vendor_id, product_id;
>   WacomBusType bus;
> @@ -522,7 +522,7 @@ bail:
>  }
>  
>  WacomDevice*
> -libwacom_new_from_usbid(WacomDeviceDatabase *db, int vendor_id, int 
> product_id, WacomError *error)
> +libwacom_new_from_usbid(const WacomDeviceDatabase *db, int vendor_id, int 
> product_id, WacomError *error)
>  {
>   const WacomDevice *device;
>  
> @@ -541,7 +541,7 @@ libwacom_new_from_usbid(WacomDeviceDatabase *db, int 
> vendor_id, int product_id,
>  }
>  
>  WacomDevice*
> -libwacom_new_from_name(WacomDeviceDatabase *db, const char *name, WacomError 
> *error)
> +libwacom_new_from_name(const WacomDeviceDatabase *db, const char *name, 
> WacomError *error)
>  {
>   const WacomDevice *device;
>   GList *keys, *l;
> @@ -570,7 +570,7 @@ libwacom_new_from_name(WacomDeviceDatabase *db, const 
> char *name, WacomError *er
>   return NULL;
>  }
>  
> -static void print_styli_for_device (int fd, WacomDevice *device)
> +static void print_styli_for_device (int fd, const WacomDevice *device)
>  {
>   int nstyli;
>   const int *styli;
> @@ -587,7 +587,7 @@ static void print_styli_for_device (int fd, WacomDevice 
> 

[Linuxwacom-devel] libwacom: [PATCH] lib: constify parameters in API

2012-11-29 Thread Olivier Fourdan

[...]

Olivier Fourdan said the following on 11/29/2012 05:49 PM:

sorry, I didn't spot this earlier, this should be const WacomDevice *device.
>  (only noticed that when doing some printf testing on my device). Given that
>  is_builtin, is_reversible, etc aren't const we should update all of them in
>  a follow-up patch.
>

Yes, I simply copy/pasted from one of the previous functions... I'll
send a separate global "constification" patch.


The /big/ constification patch... goes on top of the integration bits.

Cheers,
Olivier.
>From 36a4afefcc4fcf89fa7c1e917c97926e3945a152 Mon Sep 17 00:00:00 2001
From: Olivier Fourdan 
Date: Thu, 29 Nov 2012 18:52:36 +0100
Subject: [PATCH] lib: constify parameters in API

Signed-off-by: Olivier Fourdan 
---
 libwacom/libwacom-database.c |2 +-
 libwacom/libwacom.c  |   86 -
 libwacom/libwacom.h  |   70 +-
 3 files changed, 78 insertions(+), 80 deletions(-)

diff --git a/libwacom/libwacom-database.c b/libwacom/libwacom-database.c
index e0ee52e..9813a4e 100644
--- a/libwacom/libwacom-database.c
+++ b/libwacom/libwacom-database.c
@@ -622,7 +622,7 @@ libwacom_database_destroy(WacomDeviceDatabase *db)
 }
 
 WacomDevice**
-libwacom_list_devices_from_database(WacomDeviceDatabase *db, WacomError *error)
+libwacom_list_devices_from_database(const WacomDeviceDatabase *db, WacomError *error)
 {
 	GList *cur, *devices;
 	WacomDevice **list, **p;
diff --git a/libwacom/libwacom.c b/libwacom/libwacom.c
index 23f3b08..b03fe0b 100644
--- a/libwacom/libwacom.c
+++ b/libwacom/libwacom.c
@@ -48,7 +48,7 @@
 #endif
 
 static const WacomDevice *
-libwacom_get_device(WacomDeviceDatabase *db, const char *match)
+libwacom_get_device(const WacomDeviceDatabase *db, const char *match)
 {
 	return (WacomDevice *) g_hash_table_lookup (db->device_ht, match);
 }
@@ -337,7 +337,7 @@ libwacom_copy(const WacomDevice *device)
 
 
 static int
-compare_matches(WacomDevice *a, WacomDevice *b)
+compare_matches(const WacomDevice *a, const WacomDevice *b)
 {
 	const WacomMatch **ma, **mb, **match_a, **match_b;
 
@@ -359,7 +359,7 @@ compare_matches(WacomDevice *a, WacomDevice *b)
 
 /* Compare layouts based on file name, stripping the full path */
 static gboolean
-libwacom_same_layouts (WacomDevice *a, WacomDevice *b)
+libwacom_same_layouts (const WacomDevice *a, const WacomDevice *b)
 {
 	gchar *file1, *file2;
 
@@ -378,7 +378,7 @@ libwacom_same_layouts (WacomDevice *a, WacomDevice *b)
 }
 
 int
-libwacom_compare(WacomDevice *a, WacomDevice *b, WacomCompareFlags flags)
+libwacom_compare(const WacomDevice *a, const WacomDevice *b, WacomCompareFlags flags)
 {
 	g_return_val_if_fail(a || b, 0);
 
@@ -442,7 +442,7 @@ libwacom_compare(WacomDevice *a, WacomDevice *b, WacomCompareFlags flags)
 }
 
 static const WacomDevice *
-libwacom_new (WacomDeviceDatabase *db, int vendor_id, int product_id, WacomBusType bus, WacomError *error)
+libwacom_new (const WacomDeviceDatabase *db, int vendor_id, int product_id, WacomBusType bus, WacomError *error)
 {
 	const WacomDevice *device;
 	char *match;
@@ -460,7 +460,7 @@ libwacom_new (WacomDeviceDatabase *db, int vendor_id, int product_id, WacomBusTy
 }
 
 WacomDevice*
-libwacom_new_from_path(WacomDeviceDatabase *db, const char *path, WacomFallbackFlags fallback, WacomError *error)
+libwacom_new_from_path(const WacomDeviceDatabase *db, const char *path, WacomFallbackFlags fallback, WacomError *error)
 {
 	int vendor_id, product_id;
 	WacomBusType bus;
@@ -522,7 +522,7 @@ bail:
 }
 
 WacomDevice*
-libwacom_new_from_usbid(WacomDeviceDatabase *db, int vendor_id, int product_id, WacomError *error)
+libwacom_new_from_usbid(const WacomDeviceDatabase *db, int vendor_id, int product_id, WacomError *error)
 {
 	const WacomDevice *device;
 
@@ -541,7 +541,7 @@ libwacom_new_from_usbid(WacomDeviceDatabase *db, int vendor_id, int product_id,
 }
 
 WacomDevice*
-libwacom_new_from_name(WacomDeviceDatabase *db, const char *name, WacomError *error)
+libwacom_new_from_name(const WacomDeviceDatabase *db, const char *name, WacomError *error)
 {
 	const WacomDevice *device;
 	GList *keys, *l;
@@ -570,7 +570,7 @@ libwacom_new_from_name(WacomDeviceDatabase *db, const char *name, WacomError *er
 	return NULL;
 }
 
-static void print_styli_for_device (int fd, WacomDevice *device)
+static void print_styli_for_device (int fd, const WacomDevice *device)
 {
 	int nstyli;
 	const int *styli;
@@ -587,7 +587,7 @@ static void print_styli_for_device (int fd, WacomDevice *device)
 	dprintf(fd, "\n");
 }
 
-static void print_layout_for_device (int fd, WacomDevice *device)
+static void print_layout_for_device (int fd, const WacomDevice *device)
 {
 	const char *layout_filename;
 	gchar  *base_name;
@@ -600,7 +600,7 @@ static void print_layout_for_device (int fd, WacomDevice *device)
 	}
 }
 
-static void print_supported_leds (int fd, WacomDevice *device)
+static void print_supported_leds (int fd, const WacomDevice *device)