[gnome-color-manager] Add some fixes to the DDC code for my HP DreamColor display



commit 7dab066ead41eb7b5b0bb15e06f6134df21d2ab8
Author: Richard Hughes <richard hughsie com>
Date:   Wed Aug 11 15:17:16 2010 +0100

    Add some fixes to the DDC code for my HP DreamColor display

 libcolor-glib/gcm-ddc-control.c |    1 +
 libcolor-glib/gcm-ddc-device.c  |   13 ++++++++++++-
 2 files changed, 13 insertions(+), 1 deletions(-)
---
diff --git a/libcolor-glib/gcm-ddc-control.c b/libcolor-glib/gcm-ddc-control.c
index 680b834..784c47e 100644
--- a/libcolor-glib/gcm-ddc-control.c
+++ b/libcolor-glib/gcm-ddc-control.c
@@ -78,6 +78,7 @@ const gchar *
 gcm_ddc_control_get_description (GcmDdcControl *control)
 {
 	g_return_val_if_fail (GCM_IS_DDC_CONTROL(control), NULL);
+	g_return_val_if_fail (control->priv->id != GCM_VCP_ID_INVALID, NULL);
 
 	return gcm_get_vcp_description_from_index (control->priv->id);
 }
diff --git a/libcolor-glib/gcm-ddc-device.c b/libcolor-glib/gcm-ddc-device.c
index 6d8d59b..1d11dc0 100644
--- a/libcolor-glib/gcm-ddc-device.c
+++ b/libcolor-glib/gcm-ddc-device.c
@@ -452,10 +452,17 @@ static gboolean
 gcm_ddc_device_add_control (GcmDdcDevice *device, const gchar *index_str, const gchar *controls_str)
 {
 	GcmDdcControl *control;
+	guint id;
+
+	/* convert hex to number */
+	id = strtoul (index_str, NULL, 16);
+	if (id == GCM_VCP_ID_INVALID)
+		return FALSE;
+
 	control = gcm_ddc_control_new ();
 	gcm_ddc_control_set_verbose (control, device->priv->verbose);
 	gcm_ddc_control_set_device (control, device);
-	gcm_ddc_control_parse (control, strtoul (index_str, NULL, 16), controls_str);
+	gcm_ddc_control_parse (control, id, controls_str);
 	g_ptr_array_add (device->priv->controls, control);
 	return TRUE;
 }
@@ -616,6 +623,10 @@ gcm_ddc_device_ensure_controls (GcmDdcDevice *device, GError **error)
 		goto out;
 	}
 
+	/* model not set */
+	if (device->priv->model == NULL)
+		device->priv->model = g_strdup ("<unknown>");
+
 	/* success */
 	device->priv->has_controls = TRUE;
 out:



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