[totem-pl-parser] core: Fix various compilation warnings
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [totem-pl-parser] core: Fix various compilation warnings
- Date: Wed, 21 Dec 2011 14:03:22 +0000 (UTC)
commit e5bc1d58bba7b018659f65615adf92506c0c15f0
Author: Philip Withnall <philip tecnocode co uk>
Date: Wed Dec 21 13:43:34 2011 +0000
core: Fix various compilation warnings
Mostly shadowed variable names and const-correctness.
lib/stub.c | 2 ++
plparse/tests/disc.c | 18 +++++++++---------
plparse/tests/parser.c | 4 +++-
plparse/totem-disc.c | 20 ++++++++++++--------
plparse/totem-pl-parser-lines.c | 2 +-
plparse/totem-pl-parser-media.c | 8 ++++----
plparse/totem-pl-parser-misc.c | 10 +++++-----
plparse/totem-pl-parser-pls.c | 16 ++++++++--------
plparse/totem-pl-parser-podcast.c | 12 ++++++------
plparse/totem-pl-parser-qt.c | 2 --
plparse/totem-pl-parser.c | 6 +-----
plparse/xmllexer.c | 17 +++++++++++------
plparse/xmllexer.h | 8 +++++++-
plparse/xmlparser.c | 8 +++++---
14 files changed, 74 insertions(+), 59 deletions(-)
---
diff --git a/lib/stub.c b/lib/stub.c
index 33d40fc..8309118 100644
--- a/lib/stub.c
+++ b/lib/stub.c
@@ -1,3 +1,5 @@
+int ___stub_so_lib_is_not_empty (void);
+
int ___stub_so_lib_is_not_empty (void)
{
return 0;
diff --git a/plparse/tests/disc.c b/plparse/tests/disc.c
index c1242d5..7541c08 100644
--- a/plparse/tests/disc.c
+++ b/plparse/tests/disc.c
@@ -44,10 +44,10 @@ test_disc (gconstpointer data)
mon = g_volume_monitor_get ();
for (or = list = g_volume_monitor_get_connected_drives (mon); list != NULL; list = list->next) {
- char *device;
- device = g_drive_get_identifier ((GDrive *) list->data, G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE);
- g_message ("\t%s", device);
- g_free (device);
+ char *device_id;
+ device_id = g_drive_get_identifier ((GDrive *) list->data, G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE);
+ g_message ("\t%s", device_id);
+ g_free (device_id);
g_object_unref (list->data);
}
if (or == NULL)
@@ -57,14 +57,14 @@ test_disc (gconstpointer data)
g_message ("List of volumes:");
for (or = list = g_volume_monitor_get_volumes (mon); list != NULL; list = list->next) {
- char *device;
+ char *device_id;
- device = g_volume_get_identifier ((GVolume *) list->data, G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE);
+ device_id = g_volume_get_identifier ((GVolume *) list->data, G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE);
if (g_volume_get_mount ((GVolume *) list->data) == NULL)
- g_message ("\t%s", device);
+ g_message ("\t%s", device_id);
else
- g_message ("\t%s (mounted)", device);
- g_free (device);
+ g_message ("\t%s (mounted)", device_id);
+ g_free (device_id);
g_object_unref (list->data);
}
diff --git a/plparse/tests/parser.c b/plparse/tests/parser.c
index 71fcb75..b8a31d3 100644
--- a/plparse/tests/parser.c
+++ b/plparse/tests/parser.c
@@ -199,7 +199,7 @@ static void
test_videosite (void)
{
#ifdef HAVE_QUVI
- char *uri = "http://www.youtube.com/watch?v=oMLCrzy9TEs";
+ const char *uri = "http://www.youtube.com/watch?v=oMLCrzy9TEs";
g_test_message ("Testing data parsing \"%s\"...", uri);
g_assert (totem_pl_parser_can_parse_from_uri (uri, TRUE));
@@ -892,6 +892,8 @@ test_parsing_real (TotemPlParser *pl, const char *uri)
case TOTEM_PL_PARSER_RESULT_IGNORED:
g_message ("Ignored URI \"%s\".", uri);
break;
+ case TOTEM_PL_PARSER_RESULT_SUCCESS:
+ case TOTEM_PL_PARSER_RESULT_CANCELLED:
default:
g_assert_not_reached ();
;;
diff --git a/plparse/totem-disc.c b/plparse/totem-disc.c
index 8709b41..c3c0f7b 100644
--- a/plparse/totem-disc.c
+++ b/plparse/totem-disc.c
@@ -101,20 +101,20 @@ static void cd_cache_free (CdCache *cache);
static char *
totem_resolve_symlink (const char *device, GError **error)
{
- char *dir, *link;
+ char *dir, *_link;
char *f;
char *f1;
f = g_strdup (device);
while (g_file_test (f, G_FILE_TEST_IS_SYMLINK)) {
- link = g_file_read_link (f, error);
- if(link == NULL) {
+ _link = g_file_read_link (f, error);
+ if (_link == NULL) {
g_free (f);
return NULL;
}
dir = g_path_get_dirname (f);
- f1 = g_build_filename (dir, link, NULL);
+ f1 = g_build_filename (dir, _link, NULL);
g_free (dir);
g_free (f);
f = f1;
@@ -278,7 +278,7 @@ cd_cache_check_archive (CdCache *cache,
#else
struct archive *a;
struct archive_entry *entry;
- char *content_types[] = { NULL, NULL };
+ const char * content_types[] = { NULL, NULL };
int r;
a = archive_read_new();
@@ -296,15 +296,15 @@ cd_cache_check_archive (CdCache *cache,
name = archive_entry_pathname (entry);
if (g_ascii_strcasecmp (name, "VIDEO_TS/VIDEO_TS.IFO") == 0) {
content_types[0] = "x-content/video-dvd";
- cache->content_types = g_strdupv (content_types);
+ cache->content_types = g_strdupv ((gchar**) content_types);
break;
} else if (g_ascii_strcasecmp (name, "mpegav/AVSEQ01.DAT") == 0) {
content_types[0] = "x-content/video-vcd";
- cache->content_types = g_strdupv (content_types);
+ cache->content_types = g_strdupv ((gchar**) content_types);
break;
} else if (g_ascii_strcasecmp (name, "MPEG2/AVSEQ01.MPG") == 0) {
content_types[0] = "x-content/video-svcd";
- cache->content_types = g_strdupv (content_types);
+ cache->content_types = g_strdupv ((gchar**) content_types);
break;
}
archive_read_data_skip(a);
@@ -811,6 +811,8 @@ totem_cd_detect_type_with_url (const char *device,
*mrl = g_strdup (cache->mountpoint);
}
break;
+ case MEDIA_TYPE_ERROR:
+ case MEDIA_TYPE_DVB:
default:
break;
}
@@ -883,6 +885,8 @@ totem_cd_get_human_readable_name (TotemDiscMediaType type)
return N_("DVD");
case MEDIA_TYPE_DVB:
return N_("Digital Television");
+ case MEDIA_TYPE_ERROR:
+ case MEDIA_TYPE_DATA:
default:
g_assert_not_reached ();
}
diff --git a/plparse/totem-pl-parser-lines.c b/plparse/totem-pl-parser-lines.c
index 9ebf539..df1737a 100644
--- a/plparse/totem-pl-parser-lines.c
+++ b/plparse/totem-pl-parser-lines.c
@@ -87,7 +87,7 @@ totem_pl_parser_save_m3u (TotemPlParser *parser,
GFileOutputStream *stream;
gboolean valid, success;
char *buf;
- char *cr;
+ const char *cr;
stream = g_file_replace (output, NULL, FALSE, G_FILE_CREATE_NONE, NULL, error);
if (stream == NULL)
diff --git a/plparse/totem-pl-parser-media.c b/plparse/totem-pl-parser-media.c
index 42688b8..2f7487d 100644
--- a/plparse/totem-pl-parser-media.c
+++ b/plparse/totem-pl-parser-media.c
@@ -242,15 +242,15 @@ totem_pl_parser_add_directory (TotemPlParser *parser,
g_free (uri);
if (type != MEDIA_TYPE_DATA && type != MEDIA_TYPE_ERROR && media_uri != NULL) {
- char *basename = NULL, *fname;
+ char *base_name = NULL, *fname;
fname = g_file_get_path (file);
if (fname != NULL) {
- basename = g_filename_display_basename (fname);
+ base_name = g_filename_display_basename (fname);
g_free (fname);
}
- totem_pl_parser_add_one_uri (parser, media_uri, basename);
- g_free (basename);
+ totem_pl_parser_add_one_uri (parser, media_uri, base_name);
+ g_free (base_name);
g_free (media_uri);
return TOTEM_PL_PARSER_RESULT_SUCCESS;
}
diff --git a/plparse/totem-pl-parser-misc.c b/plparse/totem-pl-parser-misc.c
index 03a2c0b..11e40e2 100644
--- a/plparse/totem-pl-parser-misc.c
+++ b/plparse/totem-pl-parser-misc.c
@@ -44,7 +44,7 @@ totem_pl_parser_add_gvp (TotemPlParser *parser,
gpointer data)
{
TotemPlParserResult retval = TOTEM_PL_PARSER_RESULT_UNHANDLED;
- char *contents, **lines, *title, *link, *version;
+ char *contents, **lines, *title, *url_link, *version;
gsize size;
if (g_file_load_contents (file, NULL, &contents, &size, NULL, NULL) == FALSE)
@@ -67,8 +67,8 @@ totem_pl_parser_add_gvp (TotemPlParser *parser,
}
g_free (version);
- link = totem_pl_parser_read_ini_line_string_with_sep (lines, "url", ":");
- if (link == NULL) {
+ url_link = totem_pl_parser_read_ini_line_string_with_sep (lines, "url", ":");
+ if (url_link == NULL) {
g_strfreev (lines);
return retval;
}
@@ -77,9 +77,9 @@ totem_pl_parser_add_gvp (TotemPlParser *parser,
title = totem_pl_parser_read_ini_line_string_with_sep (lines, "title", ":");
- totem_pl_parser_add_one_uri (parser, link, title);
+ totem_pl_parser_add_one_uri (parser, url_link, title);
- g_free (link);
+ g_free (url_link);
g_free (title);
g_strfreev (lines);
diff --git a/plparse/totem-pl-parser-pls.c b/plparse/totem-pl-parser-pls.c
index 504448b..5f74dfe 100644
--- a/plparse/totem-pl-parser-pls.c
+++ b/plparse/totem-pl-parser-pls.c
@@ -78,18 +78,18 @@ totem_pl_parser_save_pls (TotemPlParser *parser,
i = 0;
while (valid) {
- gchar *uri, *title, *relative;
+ gchar *uri, *entry_title, *relative;
GFile *file;
totem_pl_playlist_get (playlist, &iter,
TOTEM_PL_PARSER_FIELD_URI, &uri,
- TOTEM_PL_PARSER_FIELD_TITLE, &title,
+ TOTEM_PL_PARSER_FIELD_TITLE, &entry_title,
NULL);
valid = totem_pl_playlist_iter_next (playlist, &iter);
if (!uri) {
- g_free (title);
+ g_free (entry_title);
continue;
}
@@ -98,7 +98,7 @@ totem_pl_parser_save_pls (TotemPlParser *parser,
if (totem_pl_parser_scheme_is_ignored (parser, file)) {
g_object_unref (file);
g_free (uri);
- g_free (title);
+ g_free (entry_title);
continue;
}
@@ -114,18 +114,18 @@ totem_pl_parser_save_pls (TotemPlParser *parser,
g_free (buf);
if (success == FALSE) {
- g_free (title);
+ g_free (entry_title);
return FALSE;
}
- if (!title) {
+ if (!entry_title) {
continue;
}
- buf = g_strdup_printf ("Title%d=%s\n", i, title);
+ buf = g_strdup_printf ("Title%d=%s\n", i, entry_title);
success = totem_pl_parser_write_string (G_OUTPUT_STREAM (stream), buf, error);
g_free (buf);
- g_free (title);
+ g_free (entry_title);
if (success == FALSE) {
return FALSE;
diff --git a/plparse/totem-pl-parser-podcast.c b/plparse/totem-pl-parser-podcast.c
index 8ca7432..6a6437f 100644
--- a/plparse/totem-pl-parser-podcast.c
+++ b/plparse/totem-pl-parser-podcast.c
@@ -674,14 +674,14 @@ totem_pl_parser_get_feed_uri (char *data, gsize len, gboolean debug)
/* Probably HTML, look for feed-url */
if (g_strstr_len (data, len, "feed-url") != NULL) {
- char *uri;
- uri = totem_pl_parser_parse_html (data, len, debug);
+ char *feed_uri;
+ feed_uri = totem_pl_parser_parse_html (data, len, debug);
if (debug)
- g_print ("Found feed-url in HTML: '%s'\n", uri);
- if (uri == NULL)
+ g_print ("Found feed-url in HTML: '%s'\n", feed_uri);
+ if (feed_uri == NULL)
return NULL;
- ret = g_file_new_for_uri (uri);
- g_free (uri);
+ ret = g_file_new_for_uri (feed_uri);
+ g_free (feed_uri);
return ret;
}
diff --git a/plparse/totem-pl-parser-qt.c b/plparse/totem-pl-parser-qt.c
index fc50ae3..335b4cb 100644
--- a/plparse/totem-pl-parser-qt.c
+++ b/plparse/totem-pl-parser-qt.c
@@ -129,8 +129,6 @@ totem_pl_parser_add_quicktime_metalink (TotemPlParser *parser,
return totem_pl_parser_add_quicktime_rtsptext (parser, file, base_file, parse_data, data);
}
if (g_str_has_prefix (data, "SMILtext") != FALSE) {
- char *contents;
- gsize size;
TotemPlParserResult retval;
if (g_file_load_contents (file, NULL, &contents, &size, NULL, NULL) == FALSE)
diff --git a/plparse/totem-pl-parser.c b/plparse/totem-pl-parser.c
index 8e3cef4..dc4a2e0 100644
--- a/plparse/totem-pl-parser.c
+++ b/plparse/totem-pl-parser.c
@@ -167,7 +167,7 @@ typedef TotemPlParserResult (*PlaylistCallback) (TotemPlParser *parser, GFile *u
#endif
typedef struct {
- char *mimetype;
+ const char *mimetype;
#ifndef TOTEM_PL_PARSER_MINI
PlaylistCallback func;
#endif
@@ -289,8 +289,6 @@ static void totem_pl_parser_base_class_finalize (TotemPlParserClass *klass);
static void totem_pl_parser_init (TotemPlParser *parser);
static void totem_pl_parser_finalize (GObject *object);
-static void totem_pl_parser_init (TotemPlParser *self);
-static void totem_pl_parser_class_init (TotemPlParserClass *klass);
static gpointer totem_pl_parser_parent_class = NULL;
#define TOTEM_PL_PARSER_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TOTEM_TYPE_PL_PARSER, TotemPlParserPrivate))
@@ -1057,7 +1055,6 @@ totem_pl_parser_resolve_uri (GFile *base_gfile,
resolved_gfile = g_file_resolve_relative_path (base_parent_gfile, new_relative_uri);
g_object_unref (base_parent_gfile);
if (!resolved_gfile) {
- char *base_uri;
base_uri = g_file_get_uri (base_gfile);
g_warning ("Failed to resolve relative URI '%s' against base '%s'\n", relative_uri, base_uri);
g_free (base_uri);
@@ -1079,7 +1076,6 @@ totem_pl_parser_resolve_uri (GFile *base_gfile,
resolved_gfile = g_file_resolve_relative_path (base_parent_gfile, relative_uri);
g_object_unref (base_parent_gfile);
if (!resolved_gfile) {
- char *base_uri;
base_uri = g_file_get_uri (base_gfile);
g_warning ("Failed to resolve relative URI '%s' against base '%s'\n", relative_uri, base_uri);
g_free (base_uri);
diff --git a/plparse/xmllexer.c b/plparse/xmllexer.c
index 36a8466..c3633df 100644
--- a/plparse/xmllexer.c
+++ b/plparse/xmllexer.c
@@ -65,6 +65,7 @@ static void lex_convert (struct lexer * lexer, const char * buf, int size, enum
case UTF32LE: c = _X_LE_32 (buf); buf += 4; break;
case UTF16BE: c = _X_BE_16 (buf); buf += 2; break;
case UTF16LE: c = _X_LE_16 (buf); buf += 2; break;
+ default: /* erk! */ abort ();
}
if (!c)
break; /* embed a NUL, get a truncated string */
@@ -96,12 +97,6 @@ void lexer_init(const char * buf, int size) {
static_lexer = lexer_init_r(buf, size);
}
-static enum {
- NORMAL,
- DATA,
- CDATA,
-} lex_mode = NORMAL;
-
struct lexer *lexer_init_r(const char * buf, int size) {
static const char boms[] = { 0xFF, 0xFE, 0, 0, 0xFE, 0xFF },
bom_utf8[] = { 0xEF, 0xBB, 0xBF };
@@ -488,6 +483,7 @@ int lexer_get_token_d_r(struct lexer * lexer, char ** _tok, int * _tok_size, int
lexer->lexbuf_pos++;
}
break;
+ case STATE_UNKNOWN:
default:
lprintf("expected char \'%c\'\n", tok[tok_pos - 1]); /* FIX ME */
return T_ERROR;
@@ -528,6 +524,10 @@ int lexer_get_token_d_r(struct lexer * lexer, char ** _tok, int * _tok_size, int
lexer->lexbuf_pos++;
}
break;
+
+ default:
+ lprintf ("Unexpected mode: %u\n", lexer->lex_mode);
+ return T_ERROR;
}
}
lprintf ("loop done tok_pos = %d, tok_size=%d, lexbuf_pos=%d, lexbuf_size=%d\n",
@@ -580,6 +580,11 @@ int lexer_get_token_d_r(struct lexer * lexer, char ** _tok, int * _tok_size, int
case STATE_IDENT:
return T_DATA;
break;
+ case STATE_UNKNOWN:
+ case STATE_T_COMMENT:
+ case STATE_T_TI_STOP:
+ case STATE_T_DASHDASH:
+ case STATE_T_C_STOP:
default:
lprintf("unknown state, state=%d\n", state);
}
diff --git a/plparse/xmllexer.h b/plparse/xmllexer.h
index 70fa86e..96c6e54 100644
--- a/plparse/xmllexer.h
+++ b/plparse/xmllexer.h
@@ -55,13 +55,19 @@
#define T_CDATA_STOP 19 /* ]]> */
+typedef enum {
+ NORMAL,
+ DATA,
+ CDATA,
+} LexMode;
+
/* public structure */
struct lexer
{
const char * lexbuf;
int lexbuf_size;
int lexbuf_pos;
- int lex_mode;
+ LexMode lex_mode;
int in_comment;
char *lex_malloc;
};
diff --git a/plparse/xmlparser.c b/plparse/xmlparser.c
index 17481fc..ee55c39 100644
--- a/plparse/xmlparser.c
+++ b/plparse/xmlparser.c
@@ -218,7 +218,7 @@ static xml_node_t *xml_parser_append_text (xml_node_t *node, xml_node_t *subnode
} else {
/* most recent node is not CDATA - add a sibling */
subnode->next = new_xml_node ();
- subnode->next->name = cdata;
+ subnode->next->name = (char*) cdata; /* we never free cdata */
subnode->next->data = strdup (text);
subnode = subnode->next;
}
@@ -655,6 +655,8 @@ static int xml_parser_get_node_internal (xml_parser_t *xml_parser,
break;
+ case STATE_Q_NODE_CLOSE:
+ case STATE_Q_TAG_TERM:
default:
lprintf("error: unknown parser state, state=%d\n", state);
return -1;
@@ -680,7 +682,7 @@ static int xml_parser_get_node (xml_parser_t *xml_parser, xml_node_t *current_no
char *pname_buffer = calloc(1, pname_buffer_size);
char *nname_buffer = calloc(1, nname_buffer_size);
char *root_names[MAX_RECURSION + 1];
- root_names[0] = "";
+ root_names[0] = (char*) ""; /* xml_parser_get_node_internal() only frees names which it allocates */
res = xml_parser_get_node_internal (xml_parser,
&token_buffer, &token_buffer_size,
@@ -858,7 +860,7 @@ static void xml_parser_dump_node (const xml_node_t *node, int indent) {
free (value);
p = p->next;
if (p) {
- printf ("\n%*s", indent+2+l, "");
+ printf ("\n%*s", indent + 2 + (int) l, "");
}
}
printf (">\n");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]