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 <ofour...@redhat.com> > Date: Thu, 29 Nov 2012 18:52:36 +0100 > Subject: [PATCH] lib: constify parameters in API > > Signed-off-by: Olivier Fourdan <ofour...@redhat.com> > --- > 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) > { > char *leds_name[] = { > "Ring", > @@ -620,7 +620,7 @@ static void print_supported_leds (int fd, WacomDevice > *device) > dprintf(fd, "\n"); > } > > -static void print_button_flag_if(int fd, WacomDevice *device, const char > *label, int flag) > +static void print_button_flag_if(int fd, const WacomDevice *device, const > char *label, int flag) > { > int nbuttons = libwacom_get_num_buttons(device); > char b; > @@ -631,7 +631,7 @@ static void print_button_flag_if(int fd, WacomDevice > *device, const char *label, > dprintf(fd, "\n"); > } > > -static void print_buttons_for_device (int fd, WacomDevice *device) > +static void print_buttons_for_device (int fd, const WacomDevice *device) > { > int nbuttons = libwacom_get_num_buttons(device); > > @@ -656,7 +656,7 @@ static void print_buttons_for_device (int fd, WacomDevice > *device) > dprintf(fd, "\n"); > } > > -static void print_integrated_flags_for_device (int fd, WacomDevice *device) > +static void print_integrated_flags_for_device (int fd, const WacomDevice > *device) > { > /* > * If flag is WACOM_DEVICE_INTEGRATED_UNSET, the info is not provided > @@ -675,7 +675,7 @@ static void print_integrated_flags_for_device (int fd, > WacomDevice *device) > > > void > -libwacom_print_device_description(int fd, WacomDevice *device) > +libwacom_print_device_description(int fd, const WacomDevice *device) > { > const WacomMatch **match; > WacomClass class; > @@ -795,109 +795,109 @@ libwacom_update_match(WacomDevice *device, > WacomBusType bus, int vendor_id, int > g_free(newmatch); > } > > -int libwacom_get_vendor_id(WacomDevice *device) > +int libwacom_get_vendor_id(const WacomDevice *device) > { > g_return_val_if_fail(device->match >= 0, -1); > g_return_val_if_fail(device->match < device->nmatches, -1); > return device->matches[device->match]->vendor_id; > } > > -const char* libwacom_get_name(WacomDevice *device) > +const char* libwacom_get_name(const WacomDevice *device) > { > return device->name; > } > > -const char* libwacom_get_layout_filename(WacomDevice *device) > +const char* libwacom_get_layout_filename(const WacomDevice *device) > { > return device->layout; > } > > -int libwacom_get_product_id(WacomDevice *device) > +int libwacom_get_product_id(const WacomDevice *device) > { > g_return_val_if_fail(device->match >= 0, -1); > g_return_val_if_fail(device->match < device->nmatches, -1); > return device->matches[device->match]->product_id; > } > > -const char* libwacom_get_match(WacomDevice *device) > +const char* libwacom_get_match(const WacomDevice *device) > { > g_return_val_if_fail(device->match >= 0, NULL); > g_return_val_if_fail(device->match < device->nmatches, NULL); > return device->matches[device->match]->match; > } > > -const WacomMatch** libwacom_get_matches(WacomDevice *device) > +const WacomMatch** libwacom_get_matches(const WacomDevice *device) > { > return (const WacomMatch**)device->matches; > } > > -int libwacom_get_width(WacomDevice *device) > +int libwacom_get_width(const WacomDevice *device) > { > return device->width; > } > > -int libwacom_get_height(WacomDevice *device) > +int libwacom_get_height(const WacomDevice *device) > { > return device->height; > } > > -WacomClass libwacom_get_class(WacomDevice *device) > +WacomClass libwacom_get_class(const WacomDevice *device) > { > return device->cls; > } > > -int libwacom_has_stylus(WacomDevice *device) > +int libwacom_has_stylus(const WacomDevice *device) > { > return !!(device->features & FEATURE_STYLUS); > } > > -int libwacom_has_touch(WacomDevice *device) > +int libwacom_has_touch(const WacomDevice *device) > { > return !!(device->features & FEATURE_TOUCH); > } > > -int libwacom_get_num_buttons(WacomDevice *device) > +int libwacom_get_num_buttons(const WacomDevice *device) > { > return device->num_buttons; > } > > -const int *libwacom_get_supported_styli(WacomDevice *device, int *num_styli) > +const int *libwacom_get_supported_styli(const WacomDevice *device, int > *num_styli) > { > *num_styli = device->num_styli; > return device->supported_styli; > } > > -int libwacom_has_ring(WacomDevice *device) > +int libwacom_has_ring(const WacomDevice *device) > { > return !!(device->features & FEATURE_RING); > } > > -int libwacom_has_ring2(WacomDevice *device) > +int libwacom_has_ring2(const WacomDevice *device) > { > return !!(device->features & FEATURE_RING2); > } > > -int libwacom_get_ring_num_modes(WacomDevice *device) > +int libwacom_get_ring_num_modes(const WacomDevice *device) > { > return device->ring_num_modes; > } > > -int libwacom_get_ring2_num_modes(WacomDevice *device) > +int libwacom_get_ring2_num_modes(const WacomDevice *device) > { > return device->ring2_num_modes; > } > > -int libwacom_get_num_strips(WacomDevice *device) > +int libwacom_get_num_strips(const WacomDevice *device) > { > return device->num_strips; > } > > -int libwacom_get_strips_num_modes(WacomDevice *device) > +int libwacom_get_strips_num_modes(const WacomDevice *device) > { > return device->strips_num_modes; > } > > -const WacomStatusLEDs *libwacom_get_status_leds(WacomDevice *device, int > *num_leds) > +const WacomStatusLEDs *libwacom_get_status_leds(const WacomDevice *device, > int *num_leds) > { > *num_leds = device->num_leds; > return device->status_leds; > @@ -913,8 +913,7 @@ struct { > { WACOM_BUTTON_TOUCHSTRIP2_MODESWITCH, WACOM_STATUS_LED_TOUCHSTRIP2 } > }; > > -int libwacom_get_button_led_group (WacomDevice *device, > - char button) > +int libwacom_get_button_led_group (const WacomDevice *device, char button) > { > int button_index, led_index; > WacomButtonFlags button_flags; > @@ -943,17 +942,17 @@ int libwacom_get_button_led_group (WacomDevice *device, > return WACOM_STATUS_LED_UNAVAILABLE; > } > > -int libwacom_is_builtin(WacomDevice *device) > +int libwacom_is_builtin(const WacomDevice *device) > { > return !!(libwacom_get_integration_flags (device) & > WACOM_DEVICE_INTEGRATED_DISPLAY); > } > > -int libwacom_is_reversible(WacomDevice *device) > +int libwacom_is_reversible(const WacomDevice *device) > { > return !!(device->features & FEATURE_REVERSIBLE); > } > > -WacomIntegrationFlags libwacom_get_integration_flags (WacomDevice *device) > +WacomIntegrationFlags libwacom_get_integration_flags (const WacomDevice > *device) > { > /* "unset" is for internal use only */ > if (device->integration_flags == WACOM_DEVICE_INTEGRATED_UNSET) > @@ -962,7 +961,7 @@ WacomIntegrationFlags libwacom_get_integration_flags > (WacomDevice *device) > return device->integration_flags; > } > > -WacomBusType libwacom_get_bustype(WacomDevice *device) > +WacomBusType libwacom_get_bustype(const WacomDevice *device) > { > g_return_val_if_fail(device->match >= 0, -1); > g_return_val_if_fail(device->match < device->nmatches, -1); > @@ -970,8 +969,7 @@ WacomBusType libwacom_get_bustype(WacomDevice *device) > } > > WacomButtonFlags > -libwacom_get_button_flag(WacomDevice *device, > - char button) > +libwacom_get_button_flag(const WacomDevice *device, char button) > { > int index; > > @@ -984,7 +982,7 @@ libwacom_get_button_flag(WacomDevice *device, > return device->buttons[index]; > } > > -const WacomStylus *libwacom_stylus_get_for_id (WacomDeviceDatabase *db, int > id) > +const WacomStylus *libwacom_stylus_get_for_id (const WacomDeviceDatabase > *db, int id) > { > return g_hash_table_lookup (db->stylus_ht, GINT_TO_POINTER(id)); > } > diff --git a/libwacom/libwacom.h b/libwacom/libwacom.h > index a7bdba1..3fd0b90 100644 > --- a/libwacom/libwacom.h > +++ b/libwacom/libwacom.h > @@ -263,7 +263,7 @@ void libwacom_database_destroy(WacomDeviceDatabase *db); > * > * @return A new reference to this device or NULL on errror. > */ > -WacomDevice* libwacom_new_from_path(WacomDeviceDatabase *db, const char > *path, WacomFallbackFlags fallback, WacomError *error); > +WacomDevice* libwacom_new_from_path(const WacomDeviceDatabase *db, const > char *path, WacomFallbackFlags fallback, WacomError *error); > > /** > * Create a new device reference from the given vendor/product IDs. > @@ -277,7 +277,7 @@ WacomDevice* libwacom_new_from_path(WacomDeviceDatabase > *db, const char *path, W > * > * @return A new reference to this device or NULL on errror. > */ > -WacomDevice* libwacom_new_from_usbid(WacomDeviceDatabase *db, int vendor_id, > int product_id, WacomError *error); > +WacomDevice* libwacom_new_from_usbid(const WacomDeviceDatabase *db, int > vendor_id, int product_id, WacomError *error); > > /** > * Create a new device reference from the given name. > @@ -290,7 +290,7 @@ WacomDevice* libwacom_new_from_usbid(WacomDeviceDatabase > *db, int vendor_id, int > * > * @return A new reference to this device or NULL on error. > */ > -WacomDevice* libwacom_new_from_name(WacomDeviceDatabase *db, const char > *name, WacomError *error); > +WacomDevice* libwacom_new_from_name(const WacomDeviceDatabase *db, const > char *name, WacomError *error); > > /** > * Returns the list of devices in the given database. > @@ -303,7 +303,7 @@ WacomDevice* libwacom_new_from_name(WacomDeviceDatabase > *db, const char *name, W > * The content of the list is owned by the database and should not be > * modified of freed. Use free() to free the list. > */ > -WacomDevice** libwacom_list_devices_from_database(WacomDeviceDatabase *db, > WacomError *error); > +WacomDevice** libwacom_list_devices_from_database(const WacomDeviceDatabase > *db, WacomError *error); > > /** > * Print the description of this device to the given file. > @@ -311,7 +311,7 @@ WacomDevice** > libwacom_list_devices_from_database(WacomDeviceDatabase *db, Wacom > * @param fd The file descriptor to print to > * @param device The device to print the description for. > */ > -void libwacom_print_device_description (int fd, WacomDevice *device); > +void libwacom_print_device_description (int fd, const WacomDevice *device); > > > /** > @@ -330,52 +330,52 @@ void libwacom_destroy(WacomDevice *device); > * > * @return 0 if the devices are identical, nonzero otherwise > */ > -int libwacom_compare(WacomDevice *a, WacomDevice *b, WacomCompareFlags > flags); > +int libwacom_compare(const WacomDevice *a, const WacomDevice *b, > WacomCompareFlags flags); > > /** > * @param device The tablet to query > * @return The class of the device > */ > -WacomClass libwacom_get_class(WacomDevice *device); > +WacomClass libwacom_get_class(const WacomDevice *device); > > /** > * @param device The tablet to query > * @return The human-readable name for this device > */ > -const char* libwacom_get_name(WacomDevice *device); > +const char* libwacom_get_name(const WacomDevice *device); > > /** > * @param device The tablet to query > * @return The full filename including path to the SVG layout of the device > * if available, or NULL otherwise > */ > -const char* libwacom_get_layout_filename(WacomDevice *device); > +const char* libwacom_get_layout_filename(const WacomDevice *device); > > /** > * @param device The tablet to query > * @return The numeric vendor ID for this device > */ > -int libwacom_get_vendor_id(WacomDevice *device); > +int libwacom_get_vendor_id(const WacomDevice *device); > > /** > * @param device The tablet to query > * @return The current match string used for this device (if set) or the > first > * match string in the tablet definition. > */ > -const char* libwacom_get_match(WacomDevice *device); > +const char* libwacom_get_match(const WacomDevice *device); > > /** > * @param device The tablet to query > * @return A pointer to the null-terminated list of possible matches for > this device. Do not > * modify this pointer or any content! > */ > -const WacomMatch** libwacom_get_matches(WacomDevice *device); > +const WacomMatch** libwacom_get_matches(const WacomDevice *device); > > /** > * @param device The tablet to query > * @return The numeric product ID for this device > */ > -int libwacom_get_product_id(WacomDevice *device); > +int libwacom_get_product_id(const WacomDevice *device); > > /** > * Retrieve the width of the device. This is the width of the usable area as > @@ -385,7 +385,7 @@ int libwacom_get_product_id(WacomDevice *device); > * @param device The tablet to query > * @return The width of this device in inches > */ > -int libwacom_get_width(WacomDevice *device); > +int libwacom_get_width(const WacomDevice *device); > > /** > * Retrieve the height of the device. This is the height of the usable area > as > @@ -395,19 +395,19 @@ int libwacom_get_width(WacomDevice *device); > * @param device The tablet to query > * @return The width of this device in inches > */ > -int libwacom_get_height(WacomDevice *device); > +int libwacom_get_height(const WacomDevice *device); > > /** > * @param device The tablet to query > * @return non-zero if the device supports styli or zero otherwise > */ > -int libwacom_has_stylus(WacomDevice *device); > +int libwacom_has_stylus(const WacomDevice *device); > > /** > * @param device The tablet to query > * @return non-zero if the device supports touch or zero otherwise > */ > -int libwacom_has_touch(WacomDevice *device); > +int libwacom_has_touch(const WacomDevice *device); > > /** > * Tablet buttons are numbered 'A' through to 'A' + number of buttons. > @@ -415,58 +415,58 @@ int libwacom_has_touch(WacomDevice *device); > * @param device The tablet to query > * @return The number of buttons on the tablet > */ > -int libwacom_get_num_buttons(WacomDevice *device); > +int libwacom_get_num_buttons(const WacomDevice *device); > > /** > * @param device The tablet to query > * @param num_styli Return location for the number of listed styli > * @return an array of Styli IDs supported by the device > */ > -const int *libwacom_get_supported_styli(WacomDevice *device, int *num_styli); > +const int *libwacom_get_supported_styli(const WacomDevice *device, int > *num_styli); > > /** > * @param device The tablet to query > * @return non-zero if the device has a touch ring or zero otherwise > */ > -int libwacom_has_ring(WacomDevice *device); > +int libwacom_has_ring(const WacomDevice *device); > > /** > * @param device The tablet to query > * @return non-zero if the device has a second touch ring or zero otherwise > */ > -int libwacom_has_ring2(WacomDevice *device); > +int libwacom_has_ring2(const WacomDevice *device); > > /** > * @param device The tablet to query > * @return the number of modes for the touchring if it has a mode switch > */ > -int libwacom_get_ring_num_modes(WacomDevice *device); > +int libwacom_get_ring_num_modes(const WacomDevice *device); > > /** > * @param device The tablet to query > * @return the number of modes for the second touchring if it has a mode > switch > */ > -int libwacom_get_ring2_num_modes(WacomDevice *device); > +int libwacom_get_ring2_num_modes(const WacomDevice *device); > > /** > * @param device The tablet to query > * @return the number of touch strips on the tablet > * otherwise > */ > -int libwacom_get_num_strips(WacomDevice *device); > +int libwacom_get_num_strips(const WacomDevice *device); > > /** > * @param device The tablet to query > * @return the number of modes for each of the touchstrips if any > */ > -int libwacom_get_strips_num_modes(WacomDevice *device); > +int libwacom_get_strips_num_modes(const WacomDevice *device); > > /** > * @param device The tablet to query > * @param num_leds Return location for the number of supported status LEDs > * @return an array of status LEDs supported by the device > */ > -const WacomStatusLEDs *libwacom_get_status_leds(WacomDevice *device, int > *num_leds); > +const WacomStatusLEDs *libwacom_get_status_leds(const WacomDevice *device, > int *num_leds); > > /** > * @param device The tablet to query > @@ -474,8 +474,8 @@ const WacomStatusLEDs > *libwacom_get_status_leds(WacomDevice *device, int *num_le > * @return the status LED group id to use > * or -1 if no LED is available for the given tablet / button > */ > -int libwacom_get_button_led_group (WacomDevice *device, > - char button); > +int libwacom_get_button_led_group (const WacomDevice *device, > + char button); > > /** > * @param device The tablet to query > @@ -483,34 +483,34 @@ int libwacom_get_button_led_group (WacomDevice *device, > * or zero if the device is an external tablet > * @deprecated 0.7 Use libwacom_get_integration_flags() instead. > */ > -int libwacom_is_builtin(WacomDevice *device) LIBWACOM_DEPRECATED; > +int libwacom_is_builtin(const WacomDevice *device) LIBWACOM_DEPRECATED; > > /** > * @param device The tablet to query > * @return non-zero if the device can be used left-handed > * (rotated 180 degrees) > */ > -int libwacom_is_reversible(WacomDevice *device); > +int libwacom_is_reversible(const WacomDevice *device); > > /** > * @param device The tablet to query > * @return the integration flags for the device > */ > -WacomIntegrationFlags libwacom_get_integration_flags (WacomDevice *device); > +WacomIntegrationFlags libwacom_get_integration_flags (const WacomDevice > *device); > > /** > * @param device The tablet to query > * @return The bustype of this device. > */ > -WacomBusType libwacom_get_bustype(WacomDevice *device); > +WacomBusType libwacom_get_bustype(const WacomDevice *device); > > /* > * @param device The tablet to query > * @param button The ID of the button to check for, between 'A' and 'Z' > * @return a WacomButtonFlags with information about the button > */ > -WacomButtonFlags libwacom_get_button_flag(WacomDevice *device, > - char button); > +WacomButtonFlags libwacom_get_button_flag(const WacomDevice *device, > + char button); > > /** > * Get the WacomStylus for the given tool ID. > @@ -519,7 +519,7 @@ WacomButtonFlags libwacom_get_button_flag(WacomDevice > *device, > * @param id The Tool ID for this stylus > * @return A WacomStylus representing the stylus. Do not free. > */ > -const WacomStylus *libwacom_stylus_get_for_id (WacomDeviceDatabase *db, int > id); > +const WacomStylus *libwacom_stylus_get_for_id (const WacomDeviceDatabase > *db, int id); > > /** > * @param stylus The stylus to query > -- > 1.7.1 > ------------------------------------------------------------------------------ LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial Remotely access PCs and mobile devices and provide instant support Improve your efficiency, and focus on delivering more value-add services Discover what IT Professionals Know. Rescue delivers http://p.sf.net/sfu/logmein_12329d2d _______________________________________________ Linuxwacom-devel mailing list Linuxwacom-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel