From a284f11b8a4157401f68b6f6a04fdb1607bac51f Mon Sep 17 00:00:00 2001 From: Lucas De Marchi Date: Wed, 7 Aug 2013 12:57:20 -0300 Subject: [PATCH] plugins: Turn on warnings Turn on the same compiler warnings that were on for the library and fix the issues. * signed/unsigned comparison * Missing function prototype * constify lms_plugin_info * Missing struct initializers (actually remove all of them) * Fix LMS_STATIC_STRING_SIZE to cast to char* since lms_string_size is declared with 'char *str' and we can't really change it (otherwise in other places it would not be able to change the string in place Warnings like this in mp4 plugin is not fixed: mp4/mp4.c:120:5: warning: implicit declaration of function 'MP4GetMetadataName' [-Wimplicit-function-declaration] MP4GetMetadataName(mp4_fh, &info.title.str); This happens because MP4v2 lib deprecated the use of these functions in favor to another MP4Tags*() API. Let this warning as is so we remember to change this code. --- src/lib/lightmediascanner_plugin.h | 3 +++ src/lib/lightmediascanner_utils.h | 2 +- src/plugins/Makefile.am | 4 ++-- src/plugins/asf/asf.c | 26 +++++++++++++------------- src/plugins/audio-dummy/audio-dummy.c | 2 +- src/plugins/dummy/dummy.c | 2 +- src/plugins/flac/flac.c | 7 ++++--- src/plugins/id3/id3.c | 6 +++--- src/plugins/jpeg/jpeg.c | 2 +- src/plugins/m3u/m3u.c | 2 +- src/plugins/mp4/mp4.c | 8 ++++---- src/plugins/ogg/ogg.c | 2 +- src/plugins/pls/pls.c | 2 +- src/plugins/png/png.c | 2 +- src/plugins/rm/rm.c | 8 ++++---- src/plugins/video-dummy/video-dummy.c | 2 +- 16 files changed, 42 insertions(+), 38 deletions(-) diff --git a/src/lib/lightmediascanner_plugin.h b/src/lib/lightmediascanner_plugin.h index 0b58e37..477f132 100644 --- a/src/lib/lightmediascanner_plugin.h +++ b/src/lib/lightmediascanner_plugin.h @@ -184,6 +184,9 @@ extern "C" { const char *uri; /**< how to find who wrote it (bug reports, etc) */ }; + /* Plugins' entrypoints */ + API struct lms_plugin *lms_plugin_open(void); + API const struct lms_plugin_info *lms_plugin_info(void); #ifdef __cplusplus } diff --git a/src/lib/lightmediascanner_utils.h b/src/lib/lightmediascanner_utils.h index 41812e4..91e343c 100644 --- a/src/lib/lightmediascanner_utils.h +++ b/src/lib/lightmediascanner_utils.h @@ -51,7 +51,7 @@ extern "C" { unsigned int len; }; -#define LMS_STATIC_STRING_SIZE(s) {s, sizeof(s) - 1} +#define LMS_STATIC_STRING_SIZE(s) { (char *)s, sizeof(s) - 1} #define LMS_ARRAY_SIZE(a) (sizeof(a) / sizeof(*a)) diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am index 48ec040..66365f2 100644 --- a/src/plugins/Makefile.am +++ b/src/plugins/Makefile.am @@ -1,7 +1,7 @@ MAINTAINERCLEANFILES = Makefile.in -AM_LDFLAGS = -module -avoid-version -shared -AM_CFLAGS = -fvisibility=hidden +AM_LDFLAGS = -module -avoid-version -shared $(GCLDFLAGS) +AM_CFLAGS = -fvisibility=hidden $(WARNINGFLAGS) AM_CPPFLAGS = -include $(top_builddir)/config.h \ -I$(top_srcdir)/src/lib @SQLITE3_CFLAGS@ pkgdir = $(pluginsdir) diff --git a/src/plugins/asf/asf.c b/src/plugins/asf/asf.c index 33da123..f0251cf 100644 --- a/src/plugins/asf/asf.c +++ b/src/plugins/asf/asf.c @@ -160,10 +160,10 @@ _read_qword(int fd) } static int -_read_string(int fd, size_t count, char **str, size_t *len) +_read_string(int fd, size_t count, char **str, unsigned int *len) { char *data; - size_t data_size, size; + ssize_t data_size, size; if (!str) { lseek(fd, count, SEEK_CUR); @@ -199,9 +199,9 @@ _parse_content_description(lms_charset_conv_t *cs_conv, int fd, struct asf_info int comment_length = _read_word(fd); int rating_length = _read_word(fd); - _read_string(fd, title_length, &info->title.str, (size_t *)&info->title.len); + _read_string(fd, title_length, &info->title.str, &info->title.len); lms_charset_conv_force(cs_conv, &info->title.str, &info->title.len); - _read_string(fd, artist_length, &info->artist.str, (size_t *)&info->artist.len); + _read_string(fd, artist_length, &info->artist.str, &info->artist.len); lms_charset_conv_force(cs_conv, &info->artist.str, &info->artist.len); /* ignore copyright, comment and rating */ lseek(fd, copyright_length + comment_length + rating_length, SEEK_CUR); @@ -211,7 +211,7 @@ static void _parse_attribute_name(int fd, int kind, char **attr_name, - size_t *attr_name_len, + unsigned int *attr_name_len, int *attr_type, int *attr_size) { @@ -239,10 +239,10 @@ _parse_attribute_string_data(lms_charset_conv_t *cs_conv, int fd, int attr_size, char **attr_data, - size_t *attr_data_len) + unsigned int *attr_data_len) { _read_string(fd, attr_size, attr_data, attr_data_len); - lms_charset_conv_force(cs_conv, attr_data, (unsigned int *)attr_data_len); + lms_charset_conv_force(cs_conv, attr_data, attr_data_len); } static void @@ -292,7 +292,7 @@ _parse_extended_content_description_object(lms_charset_conv_t *cs_conv, int fd, { int count = _read_word(fd); char *attr_name; - size_t attr_name_len; + unsigned int attr_name_len; int attr_type, attr_size; while (count--) { attr_name = NULL; @@ -304,20 +304,20 @@ _parse_extended_content_description_object(lms_charset_conv_t *cs_conv, int fd, _parse_attribute_string_data(cs_conv, fd, attr_size, &info->album.str, - (size_t *)&info->album.len); + &info->album.len); else if (memcmp(attr_name, attr_name_wm_genre, attr_name_len) == 0) _parse_attribute_string_data(cs_conv, fd, attr_size, &info->genre.str, - (size_t *)&info->genre.len); + &info->genre.len); else if (memcmp(attr_name, attr_name_wm_album_artist, attr_name_len) == 0) _parse_attribute_string_data(cs_conv, fd, attr_size, &info->artist.str, - (size_t *)&info->artist.len); + &info->artist.len); else if (memcmp(attr_name, attr_name_wm_track_number, attr_name_len) == 0) { char *trackno; - size_t trackno_len; + unsigned int trackno_len; _parse_attribute_string_data(cs_conv, fd, attr_size, &trackno, @@ -582,7 +582,7 @@ lms_plugin_open(void) return (struct lms_plugin *)plugin; } -API struct lms_plugin_info * +API const struct lms_plugin_info * lms_plugin_info(void) { static struct lms_plugin_info info = { diff --git a/src/plugins/audio-dummy/audio-dummy.c b/src/plugins/audio-dummy/audio-dummy.c index 731ada7..f239707 100644 --- a/src/plugins/audio-dummy/audio-dummy.c +++ b/src/plugins/audio-dummy/audio-dummy.c @@ -139,7 +139,7 @@ lms_plugin_open(void) return (struct lms_plugin *)plugin; } -API struct lms_plugin_info * +API const struct lms_plugin_info * lms_plugin_info(void) { static struct lms_plugin_info info = { diff --git a/src/plugins/dummy/dummy.c b/src/plugins/dummy/dummy.c index 8354da1..ff7998d 100644 --- a/src/plugins/dummy/dummy.c +++ b/src/plugins/dummy/dummy.c @@ -106,7 +106,7 @@ lms_plugin_open(void) return plugin; } -API struct lms_plugin_info * +API const struct lms_plugin_info * lms_plugin_info(void) { static struct lms_plugin_info info = { diff --git a/src/plugins/flac/flac.c b/src/plugins/flac/flac.c index 5d8be5a..ccb95be 100644 --- a/src/plugins/flac/flac.c +++ b/src/plugins/flac/flac.c @@ -69,10 +69,11 @@ _match(struct plugin *p, const char *path, int len, int base) static int _parse(struct plugin *plugin, struct lms_context *ctxt, const struct lms_file_info *finfo, void *match) { - struct lms_audio_info info = {0, {0}, {0}, {0}, {0}, 0, 0, 0}; + struct lms_audio_info info = { }; FLAC__StreamMetadata *tags = 0; char *str; - int i, len, r; + int len, r; + unsigned int i; if (!FLAC__metadata_get_tags(finfo->path, &tags)) { fprintf(stderr, "ERROR: cannot retrieve file %s tags\n", finfo->path); @@ -197,7 +198,7 @@ lms_plugin_open(void) return (struct lms_plugin *)plugin; } -API struct lms_plugin_info * +API const struct lms_plugin_info * lms_plugin_info(void) { static struct lms_plugin_info info = { diff --git a/src/plugins/id3/id3.c b/src/plugins/id3/id3.c index 91a4178..6f62fb3 100644 --- a/src/plugins/id3/id3.c +++ b/src/plugins/id3/id3.c @@ -560,7 +560,7 @@ _parse_id3v1_genre(const char *str_genre, struct lms_string_size *out) static void _get_id3v2_genre(const char *frame_data, unsigned int frame_size, struct lms_string_size *out, lms_charset_conv_t *cs_conv) { - int i, is_number; + unsigned int i, is_number; struct lms_string_size genre = {0}; _get_id3v2_frame_info(frame_data, frame_size, &genre, cs_conv, 1); @@ -822,7 +822,7 @@ _id3v1_str_get(struct lms_string_size *s, const char *buf, int maxlen, lms_chars return; len++; /* p_last is not included yet */ - if (len > s->len) { + if ((unsigned)len > s->len) { char *tmp; tmp = realloc(s->str, sizeof(char) * (len + 1)); @@ -1066,7 +1066,7 @@ lms_plugin_open(void) return (struct lms_plugin *)plugin; } -API struct lms_plugin_info * +API const struct lms_plugin_info * lms_plugin_info(void) { static struct lms_plugin_info info = { diff --git a/src/plugins/jpeg/jpeg.c b/src/plugins/jpeg/jpeg.c index c21a824..a0d194a 100644 --- a/src/plugins/jpeg/jpeg.c +++ b/src/plugins/jpeg/jpeg.c @@ -729,7 +729,7 @@ lms_plugin_open(void) return (struct lms_plugin *)plugin; } -API struct lms_plugin_info * +API const struct lms_plugin_info * lms_plugin_info(void) { static struct lms_plugin_info info = { diff --git a/src/plugins/m3u/m3u.c b/src/plugins/m3u/m3u.c index 26e0ace..f0afb27 100644 --- a/src/plugins/m3u/m3u.c +++ b/src/plugins/m3u/m3u.c @@ -205,7 +205,7 @@ lms_plugin_open(void) return (struct lms_plugin *)plugin; } -API struct lms_plugin_info * +API const struct lms_plugin_info * lms_plugin_info(void) { static struct lms_plugin_info info = { diff --git a/src/plugins/mp4/mp4.c b/src/plugins/mp4/mp4.c index 0ea8f65..406c4fb 100644 --- a/src/plugins/mp4/mp4.c +++ b/src/plugins/mp4/mp4.c @@ -95,9 +95,9 @@ _match(struct plugin *p, const char *path, int len, int base) static int _parse(struct plugin *plugin, struct lms_context *ctxt, const struct lms_file_info *finfo, void *match) { - struct mp4_info info = {{0}, {0}, {0}, {0}}; - struct lms_audio_info audio_info = {0, {0}, {0}, {0}, {0}, 0, 0, 0}; - struct lms_video_info video_info = {0, {0}, {0}}; + struct mp4_info info = { }; + struct lms_audio_info audio_info = { }; + struct lms_video_info video_info = { }; int r, stream_type = STREAM_TYPE_AUDIO; MP4FileHandle mp4_fh; u_int32_t num_tracks; @@ -258,7 +258,7 @@ lms_plugin_open(void) return (struct lms_plugin *)plugin; } -API struct lms_plugin_info * +API const struct lms_plugin_info * lms_plugin_info(void) { static struct lms_plugin_info info = { diff --git a/src/plugins/ogg/ogg.c b/src/plugins/ogg/ogg.c index 37e0724..7b5a133 100644 --- a/src/plugins/ogg/ogg.c +++ b/src/plugins/ogg/ogg.c @@ -344,7 +344,7 @@ lms_plugin_open(void) return (struct lms_plugin *)plugin; } -API struct lms_plugin_info * +API const struct lms_plugin_info * lms_plugin_info(void) { static struct lms_plugin_info info = { diff --git a/src/plugins/pls/pls.c b/src/plugins/pls/pls.c index 476ad66..0c2e7a8 100644 --- a/src/plugins/pls/pls.c +++ b/src/plugins/pls/pls.c @@ -387,7 +387,7 @@ lms_plugin_open(void) return (struct lms_plugin *)plugin; } -API struct lms_plugin_info * +API const struct lms_plugin_info * lms_plugin_info(void) { static struct lms_plugin_info info = { diff --git a/src/plugins/png/png.c b/src/plugins/png/png.c index e7742c9..c3f93d4 100644 --- a/src/plugins/png/png.c +++ b/src/plugins/png/png.c @@ -223,7 +223,7 @@ lms_plugin_open(void) return (struct lms_plugin *)plugin; } -API struct lms_plugin_info * +API const struct lms_plugin_info * lms_plugin_info(void) { static struct lms_plugin_info info = { diff --git a/src/plugins/rm/rm.c b/src/plugins/rm/rm.c index 3f2edd6..44f34c7 100644 --- a/src/plugins/rm/rm.c +++ b/src/plugins/rm/rm.c @@ -220,9 +220,9 @@ _match(struct plugin *p, const char *path, int len, int base) static int _parse(struct plugin *plugin, struct lms_context *ctxt, const struct lms_file_info *finfo, void *match) { - struct rm_info info = {{0}, {0}}; - struct lms_audio_info audio_info = {0, {0}, {0}, {0}, {0}, 0, 0, 0}; - struct lms_video_info video_info = {0, {0}, {0}}; + struct rm_info info = { }; + struct lms_audio_info audio_info = { }; + struct lms_video_info video_info = { }; int r, fd, stream_type = STREAM_TYPE_UNKNOWN; struct rm_file_header file_header; char type[4]; @@ -376,7 +376,7 @@ lms_plugin_open(void) return (struct lms_plugin *)plugin; } -API struct lms_plugin_info * +API const struct lms_plugin_info * lms_plugin_info(void) { static struct lms_plugin_info info = { diff --git a/src/plugins/video-dummy/video-dummy.c b/src/plugins/video-dummy/video-dummy.c index 9bee5e6..4565d14 100644 --- a/src/plugins/video-dummy/video-dummy.c +++ b/src/plugins/video-dummy/video-dummy.c @@ -145,7 +145,7 @@ lms_plugin_open(void) return (struct lms_plugin *)plugin; } -API struct lms_plugin_info * +API const struct lms_plugin_info * lms_plugin_info(void) { static struct lms_plugin_info info = { -- 2.7.4