[libdmapsharing] Fix gint vs. guint / atoi vs. strtoul issues Signed-off-by: W. Michael Petullo <mike flyn org>



commit 7473ac298c30d71213b2c73231faac5fccc176e7
Author: W. Michael Petullo <mike flyn org>
Date:   Sat Sep 11 22:24:56 2010 -0500

    Fix gint vs. guint / atoi vs. strtoul issues
    Signed-off-by: W. Michael Petullo <mike flyn org>

 libdmapsharing/daap-share.c |    4 ++--
 libdmapsharing/dmap-db.c    |    4 ++--
 libdmapsharing/dmap-share.c |    5 +++--
 3 files changed, 7 insertions(+), 6 deletions(-)
---
diff --git a/libdmapsharing/daap-share.c b/libdmapsharing/daap-share.c
index 0e39f9e..e24ac53 100644
--- a/libdmapsharing/daap-share.c
+++ b/libdmapsharing/daap-share.c
@@ -839,7 +839,7 @@ databases_items_xxx (DMAPShare *share,
 	const gchar *transcode_mimetype;
 	const gchar *rest_of_path;
 	const gchar *id_str;
-	gint id;
+	guint id;
 	const gchar *range_header;
 	guint64 filesize;
 	guint64 offset = 0;
@@ -847,7 +847,7 @@ databases_items_xxx (DMAPShare *share,
 
 	rest_of_path = strchr (path + 1, '/');
 	id_str = rest_of_path + 9;
-	id = atoi (id_str);
+	id = strtoul (id_str, NULL, 10);
 
 	g_object_get (share, "db", &db, NULL);
 	record = DAAP_RECORD (dmap_db_lookup_by_id (db, id));
diff --git a/libdmapsharing/dmap-db.c b/libdmapsharing/dmap-db.c
index 1286efe..310b836 100644
--- a/libdmapsharing/dmap-db.c
+++ b/libdmapsharing/dmap-db.c
@@ -186,7 +186,7 @@ compare_record_property (DMAPRecord *record, const gchar *property_name, const g
 			g_value_unset (&value);
 			return FALSE;
 		}
-		accept = (g_value_get_long (&dest) == atoi (property_value));
+		accept = (g_value_get_long (&dest) == strtol (property_value, NULL, 10));
 		g_value_unset (&value);
 		return accept;
 	} else if (g_value_type_transformable (G_VALUE_TYPE (&value), G_TYPE_STRING)) {
@@ -254,7 +254,7 @@ apply_filter (gpointer id, DMAPRecord *record, gpointer data)
 			query_value = def->value;
 
 			if (g_strcmp0 (query_key, "dmap.itemid") == 0) {
-				if (GPOINTER_TO_UINT (id) == atoi (query_value)) {
+				if (GPOINTER_TO_UINT (id) == strtoul (query_value, NULL, 10)) {
 					accept = TRUE;
 					break;
 				}
diff --git a/libdmapsharing/dmap-share.c b/libdmapsharing/dmap-share.c
index 392e1e3..49f5c7b 100644
--- a/libdmapsharing/dmap-share.c
+++ b/libdmapsharing/dmap-share.c
@@ -1684,7 +1684,7 @@ _dmap_share_databases (DMAPShare *share,
 		GNode *apso;
 		struct DMAPMetaDataMap *map;
 		struct MLCL_Bits mb = {NULL,0};
-		gint pl_id;
+		guint pl_id;
 		gchar *record_query;
 		GSList *filter_def;
 		GHashTable *records;
@@ -1726,7 +1726,7 @@ _dmap_share_databases (DMAPShare *share,
 			g_list_free (keys);
 			g_hash_table_destroy (records);
 		} else {
-			pl_id = atoi (rest_of_path + 14);
+			pl_id = strtoul (rest_of_path + 14, NULL, 10);
 			if (pl_id == 1) {
 				gint32 num_songs = dmap_db_count (share->priv->db);
 				dmap_structure_add (apso, DMAP_CC_MTCO, (gint32) num_songs);
@@ -1741,6 +1741,7 @@ _dmap_share_databases (DMAPShare *share,
 			
 				record = dmap_container_db_lookup_by_id (share->priv->container_db, pl_id);
 				entries = dmap_container_record_get_entries (record);
+				/* FIXME: what if entries is NULL (handled in dmapd but should be [also] handled here)? */
 				num_songs = dmap_db_count (entries);
 			
 				dmap_structure_add (apso, DMAP_CC_MTCO, (gint32) num_songs);



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