[libdmapsharing] Fix some compiler warnings



commit 6b4779d006f2fe8c259ad16dac68442408b5a776
Author: W. Michael Petullo <mike flyn org>
Date:   Sat Jan 20 21:09:30 2018 -0500

    Fix some compiler warnings
    
    Signed-off-by: W. Michael Petullo <mike flyn org>

 doc/serviceaddedcb.xml           |    2 +-
 libdmapsharing/dmap-av-share.c   |   11 ++---------
 libdmapsharing/dmap-connection.c |   14 +++++++++-----
 libdmapsharing/dmap-structure.c  |   16 +++++++---------
 libdmapsharing/dmap-structure.h  |    2 +-
 5 files changed, 20 insertions(+), 25 deletions(-)
---
diff --git a/doc/serviceaddedcb.xml b/doc/serviceaddedcb.xml
index 80e06bc..5f8fcd0 100644
--- a/doc/serviceaddedcb.xml
+++ b/doc/serviceaddedcb.xml
@@ -43,7 +43,7 @@ service_added_cb (DMAPMdnsBrowser *browser,
                g_error ("Error creating DB");
        }
 
-       factory = DMAP_RECORD_FACTORY (my_daap_record_factory_new ());
+       factory = DMAP_RECORD_FACTORY (my_av_record_factory_new ());
        if (factory == NULL) {
                g_error ("Error creating record factory");
        }
diff --git a/libdmapsharing/dmap-av-share.c b/libdmapsharing/dmap-av-share.c
index 1cea7c1..bfbf3cf 100644
--- a/libdmapsharing/dmap-av-share.c
+++ b/libdmapsharing/dmap-av-share.c
@@ -1059,6 +1059,8 @@ START_TEST(dmap_av_share_message_add_standard_headers_test)
        header = soup_message_headers_get_one(headers, "DMAP-Server");
 
        ck_assert_str_eq("libdmapsharing" VERSION, header);
+
+       g_object_unref(share);
 }
 END_TEST
 
@@ -1243,9 +1245,6 @@ START_TEST(databases_items_xxx_test)
        SoupMessage *message;
        SoupMessageBody *body = NULL;
        SoupBuffer *buffer;
-       gsize length;
-       GNode *root;
-       DmapStructureItem *item;
        char path[PATH_MAX + 1];
        DmapDb *db = NULL;
        DmapRecord *record = NULL;
@@ -1311,12 +1310,6 @@ START_TEST(databases_items_xxx_test_bad_id)
        DmapShare *share;
        SoupServer *server;
        SoupMessage *message;
-       SoupMessageBody *body;
-       SoupBuffer *buffer;
-       const guint8 *data;
-       gsize length;
-       GNode *root;
-       DmapStructureItem *item;
        char path[PATH_MAX + 1];
 
        share   = _build_share(nameprop);
diff --git a/libdmapsharing/dmap-connection.c b/libdmapsharing/dmap-connection.c
index 82fbb83..c0dfa6d 100644
--- a/libdmapsharing/dmap-connection.c
+++ b/libdmapsharing/dmap-connection.c
@@ -613,18 +613,22 @@ actual_http_response_handler (DAAPResponseData * data)
 {
        DmapConnectionPrivate *priv;
        GNode *structure;
-       char *new_response = NULL;
-       const char *response;
+       guint8 *new_response = NULL;
+       const guint8 *response;
        const char *encoding_header;
        char *message_path;
-       int response_length;
+       gsize response_length;
        gboolean compatible_server = TRUE;
+       SoupMessageBody *body;
+       SoupBuffer *buffer;
 
        priv = data->connection->priv;
        structure = NULL;
        encoding_header = NULL;
-       response = data->message->response_body->data;
-       response_length = data->message->response_body->length;
+
+       g_object_get(data->message, "response-body", &body, NULL);
+       buffer = soup_message_body_flatten(body);
+       soup_buffer_get_data(buffer, &response, &response_length);
 
        message_path =
                soup_uri_to_string (soup_message_get_uri (data->message),
diff --git a/libdmapsharing/dmap-structure.c b/libdmapsharing/dmap-structure.c
index 2d3dddc..8907100 100644
--- a/libdmapsharing/dmap-structure.c
+++ b/libdmapsharing/dmap-structure.c
@@ -538,10 +538,10 @@ dmap_content_code_read_from_buffer (const gchar * buf)
 }
 
 static gchar *
-dmap_buffer_read_string (const gchar * buf, gssize size)
+dmap_buffer_read_string (const guint8 * buf, gsize size)
 {
-       if (g_utf8_validate (buf, size, NULL) == TRUE) {
-               return g_strndup (buf, size);
+       if (g_utf8_validate ((char *) buf, size, NULL) == TRUE) {
+               return g_strndup ((char *) buf, size);
        } else {
                return g_strdup ("");
        }
@@ -549,7 +549,7 @@ dmap_buffer_read_string (const gchar * buf, gssize size)
 
 static void
 dmap_structure_parse_container_buffer (GNode * parent,
-                                      const guchar * buf, gint buf_length)
+                                      const guint8 * buf, gsize buf_length)
 {
        gint l = 0;
 
@@ -603,7 +603,7 @@ dmap_structure_parse_container_buffer (GNode * parent,
                 * then get out before we start processing it
                 */
                if (codesize > buf_length - l - 4 || codesize < 0) {
-                       g_debug ("Invalid codesize %d received in buf_length %d\n", codesize, buf_length);
+                       g_debug ("Invalid codesize %d received in buf_length %zd\n", codesize, buf_length);
                        return;
                }
                l += 4;
@@ -670,9 +670,7 @@ dmap_structure_parse_container_buffer (GNode * parent,
                        }
                case DMAP_TYPE_STRING:{
                                gchar *s =
-                                       dmap_buffer_read_string ((const gchar
-                                                                 *)
-                                                                &(buf[l]),
+                                       dmap_buffer_read_string (&(buf[l]),
                                                                 codesize);
 
                                item->size = strlen (s);
@@ -737,7 +735,7 @@ done:
 }
 
 GNode *
-dmap_structure_parse (const gchar * buf, gint buf_length)
+dmap_structure_parse (const guint8 * buf, gsize buf_length)
 {
        GNode *root = NULL;
        GNode *child = NULL;
diff --git a/libdmapsharing/dmap-structure.h b/libdmapsharing/dmap-structure.h
index 2b17950..435758a 100644
--- a/libdmapsharing/dmap-structure.h
+++ b/libdmapsharing/dmap-structure.h
@@ -207,7 +207,7 @@ struct _DmapStructureItem
 
 GNode *dmap_structure_add (GNode * parent, DmapContentCode cc, ...);
 gchar *dmap_structure_serialize (GNode * structure, guint * length);
-GNode *dmap_structure_parse (const gchar * buf, gint buf_length);
+GNode *dmap_structure_parse (const guint8 * buf, gsize buf_length);
 DmapStructureItem *dmap_structure_find_item (GNode * structure,
                                             DmapContentCode code);
 GNode *dmap_structure_find_node (GNode * structure, DmapContentCode code);


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