[libdmapsharing] Fix more warnings after adding --enable-more-warnings configure option
- From: W. Michael Petullo <wmpetullo src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libdmapsharing] Fix more warnings after adding --enable-more-warnings configure option
- Date: Fri, 3 Jul 2020 19:38:24 +0000 (UTC)
commit 2403bf4e27cdcbbc5fc1b03dc86ec9dae896c027
Author: W. Michael Petullo <mike flyn org>
Date: Fri Jul 3 14:37:16 2020 -0500
Fix more warnings after adding --enable-more-warnings configure option
Closes #34.
.gitignore | 1 +
configure.ac | 53 ++++++++++++++++++++++++++++++++++
libdmapsharing/Makefile.am | 6 ++--
libdmapsharing/dmap-av-share.c | 3 +-
libdmapsharing/dmap-control-share.c | 6 ++--
libdmapsharing/dmap-error.c | 2 +-
libdmapsharing/dmap-error.h | 2 +-
libdmapsharing/dmap-transcode-stream.c | 3 +-
libdmapsharing/generate-test-suites | 15 +++++++++-
libdmapsharing/gst-util.c | 4 +--
libdmapsharing/test-dmap-db.c | 2 +-
11 files changed, 83 insertions(+), 14 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index f14b1fd..ceb21b5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -40,6 +40,7 @@ libdmapsharing/Makefile
libdmapsharing/Makefile.in
libdmapsharing/*.[oa]
libdmapsharing/*-suite.c
+libdmapsharing/*-suite.h
libdmapsharing/unit-test.stamp
m4/gtk-doc.m4
diff --git a/configure.ac b/configure.ac
index 73202db..7390f79 100644
--- a/configure.ac
+++ b/configure.ac
@@ -52,6 +52,59 @@ if test "x$LIBDMAPSHARING_WALL" = "xyes"; then
fi
fi
+AC_ARG_ENABLE(more-warnings, [ --enable-more-warnings Maximum compiler warnings],
set_more_warnings="$enableval",[
+ if test -d "$srcdir/.git"; then
+ set_more_warnings=yes
+ else
+ set_more_warnings=no
+ fi
+])
+AC_MSG_CHECKING(for more warnings, including -Werror)
+if test "$GCC" = "yes" -a "$set_more_warnings" != "no"; then
+ AC_MSG_RESULT(yes)
+ WARN_CFLAGS="\
+ -Wcomment -Wformat -Wnonnull -Wimplicit-int -Wimplicit \
+ -Wmain -Wmissing-braces -Wparentheses -Wsequence-point \
+ -Wreturn-type -Wswitch -Wtrigraphs -Wunused-function \
+ -Wunused-label -Wunused-value \
+ -Wchar-subscripts -Wmissing-declarations -Wmissing-prototypes \
+ -Wnested-externs -Wpointer-arith \
+ -Wformat-security -Wall \
+ -Werror -Wno-deprecated-declarations -std=gnu89"
+
+ if echo "$CFLAGS" | grep -q -- '-O' && echo "$CFLAGS" | grep -q -v -- '-O0'; then
+ WARN_CFLAGS="-Wuninitialized $WARN_CFLAGS"
+ fi
+
+ for option in $WARN_CFLAGS; do
+ SAVE_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS $option"
+ AC_MSG_CHECKING([whether gcc understands $option])
+ AC_TRY_COMPILE([], [], has_option=yes, has_option=no,)
+ if test x$has_option = xyes; then
+ LIBDMAPSHARING_CFLAGS="$LIBDMAPSHARING_CFLAGS $option"
+ fi
+ AC_MSG_RESULT($has_option)
+ CFLAGS="$SAVE_CFLAGS"
+ unset has_option
+ unset SAVE_CFLAGS
+ done
+ unset option
+ AC_SUBST(WARN_CFLAGS)
+
+ SAVE_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS -Wno-error"
+ AC_TRY_COMPILE([], [], WNOERROR_CFLAGS="-Wno-error", WNOERROR_CFLAGS="")
+ AC_SUBST(WNOERROR_CFLAGS)
+ CFLAGS="$SAVE_CFLAGS"
+ unset SAVE_CFLAGS
+ unset has_wnoerror
+else
+ AC_MSG_RESULT(no)
+fi
+
+AC_SUBST(WARN_CFLAGS)
+
dnl check for tools
dnl Make sure CFLAGS is defined to stop AC_PROC_CC adding -g
CFLAGS="$CFLAGS "
diff --git a/libdmapsharing/Makefile.am b/libdmapsharing/Makefile.am
index ce1ed09..205c76e 100644
--- a/libdmapsharing/Makefile.am
+++ b/libdmapsharing/Makefile.am
@@ -71,7 +71,8 @@ libdmapsharing_4_0_la_CFLAGS = \
$(GDKPIXBUF_CFLAGS) \
$(SOUP_CFLAGS) \
$(GSTREAMERAPP_CFLAGS) \
- $(MDNS_CFLAGS)
+ $(MDNS_CFLAGS) \
+ $(WARN_CFLAGS)
libdmapsharing_4_0_la_LDFLAGS = \
-version-info @SO_VERSION@ \
@@ -146,10 +147,11 @@ BUILT_SOURCES = \
CLEANFILES = $(BUILT_SOURCES) \
../tests/unit-test.c \
*-suite.c \
+ *-suite.h \
pedansee.conf
dmap-marshal.c: dmap-marshal.list
- @glib-genmarshal --prefix=dmap_marshal_generated $(srcdir)/dmap-marshal.list --body >dmap-marshal.c
+ @glib-genmarshal --prefix=dmap_marshal_generated --include-header dmap-marshal.h
$(srcdir)/dmap-marshal.list --body >dmap-marshal.c
dmap-marshal.h: dmap-marshal.list
@glib-genmarshal --prefix=dmap_marshal_generated $(srcdir)/dmap-marshal.list --header >dmap-marshal.h
diff --git a/libdmapsharing/dmap-av-share.c b/libdmapsharing/dmap-av-share.c
index 1f763cd..013897f 100644
--- a/libdmapsharing/dmap-av-share.c
+++ b/libdmapsharing/dmap-av-share.c
@@ -1649,6 +1649,7 @@ START_TEST(_databases_items_xxx_test)
GFile *file;
GError *error = NULL;
gboolean ok;
+ guint64 i;
share = _build_share_test(nameprop);
server = soup_server_new(NULL, NULL);
@@ -1670,7 +1671,7 @@ START_TEST(_databases_items_xxx_test)
g_signal_emit_by_name(message, "wrote_headers", NULL);
- for (guint64 i = 0; i < size1 / DMAP_SHARE_CHUNK_SIZE + 1; i++) {
+ for (i = 0; i < size1 / DMAP_SHARE_CHUNK_SIZE + 1; i++) {
g_signal_emit_by_name(message, "wrote_chunk", NULL);
}
diff --git a/libdmapsharing/dmap-control-share.c b/libdmapsharing/dmap-control-share.c
index 1dc9bd4..3bad58d 100644
--- a/libdmapsharing/dmap-control-share.c
+++ b/libdmapsharing/dmap-control-share.c
@@ -231,8 +231,8 @@ _finalize (GObject * object)
G_OBJECT_CLASS (dmap_control_share_parent_class)->finalize (object);
}
-const char *
-dmap_control_share_get_type_of_service (G_GNUC_UNUSED DmapShare * share)
+static const char *
+_get_type_of_service (G_GNUC_UNUSED DmapShare * share)
{
return DACP_TYPE_OF_SERVICE;
}
@@ -248,7 +248,7 @@ dmap_control_share_class_init (DmapControlShareClass * klass)
object_class->dispose = _dispose;
object_class->finalize = _finalize;
- dmap_class->get_type_of_service = dmap_control_share_get_type_of_service;
+ dmap_class->get_type_of_service = _get_type_of_service;
dmap_class->ctrl_int = dmap_control_share_ctrl_int;
dmap_class->login = dmap_control_share_login;
diff --git a/libdmapsharing/dmap-error.c b/libdmapsharing/dmap-error.c
index 9b8fe02..73e41e0 100644
--- a/libdmapsharing/dmap-error.c
+++ b/libdmapsharing/dmap-error.c
@@ -21,7 +21,7 @@
#include <libdmapsharing/dmap-error.h>
GQuark
-dmap_error_quark ()
+dmap_error_quark (void)
{
static GQuark quark = 0;
diff --git a/libdmapsharing/dmap-error.h b/libdmapsharing/dmap-error.h
index b083928..dd515a3 100644
--- a/libdmapsharing/dmap-error.h
+++ b/libdmapsharing/dmap-error.h
@@ -26,7 +26,7 @@
G_BEGIN_DECLS
-GQuark dmap_error_quark ();
+GQuark dmap_error_quark (void);
/**
* DMAP_ERROR:
diff --git a/libdmapsharing/dmap-transcode-stream.c b/libdmapsharing/dmap-transcode-stream.c
index 3d9ce6d..6742c83 100644
--- a/libdmapsharing/dmap-transcode-stream.c
+++ b/libdmapsharing/dmap-transcode-stream.c
@@ -25,6 +25,7 @@
#include <gst/app/gstappsink.h>
#include "dmap-transcode-stream.h"
+#include "dmap-transcode-stream-private.h"
#include "dmap-transcode-mp3-stream.h"
#include "dmap-transcode-wav-stream.h"
#include "dmap-transcode-qt-stream.h"
@@ -155,7 +156,7 @@ _seekable_iface_init (GSeekableIface * iface)
void
dmap_transcode_stream_new_buffer_cb (GstElement * element,
- DmapTranscodeStream * stream)
+ DmapTranscodeStream * stream)
{
gsize i;
guint8 *ptr;
diff --git a/libdmapsharing/generate-test-suites b/libdmapsharing/generate-test-suites
index 465ff2a..a014896 100755
--- a/libdmapsharing/generate-test-suites
+++ b/libdmapsharing/generate-test-suites
@@ -4,15 +4,28 @@
for f in *.c; do
tests=$(grep ^START_TEST $f | cut -c 12- | sed 's/).*//')
suitefn=$(echo ${f%.*} | sed 's/-/_/g')
+ cppname=$(echo ${f%.*} | sed 's/-/_/g' | tr [:lower:] [:upper:])
# Continue if no tests.
if [ -z "$tests" ]; then
continue
fi
+ cat <<EOF > ${f%.*}-suite.h
+/* Machine-generated by $0; do not edit. */
+
+#ifndef _${cppname}_SUITE_H
+
+Suite *dmap_test_${suitefn}(void);
+
+#endif
+EOF
+
cat <<EOF > ${f%.*}-suite.c
/* Machine-generated by $0; do not edit. */
+#include "${f%.*}-suite.h"
+
Suite *dmap_test_${suitefn}(void)
{
TCase *tc;
@@ -55,7 +68,7 @@ for f in *.c; do
continue
fi
cat <<EOF >> unit-test.c
-Suite *dmap_test_${suitefn}(void);
+#include "../libdmapsharing/${f%.*}-suite.h"
EOF
done
diff --git a/libdmapsharing/gst-util.c b/libdmapsharing/gst-util.c
index 2f09928..497e093 100644
--- a/libdmapsharing/gst-util.c
+++ b/libdmapsharing/gst-util.c
@@ -18,9 +18,7 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include <string.h>
-#include <gst/gst.h>
-
+#include "gst-util.h"
#include "dmap-transcode-stream.h"
gboolean
diff --git a/libdmapsharing/test-dmap-db.c b/libdmapsharing/test-dmap-db.c
index 8e0451b..f181da5 100644
--- a/libdmapsharing/test-dmap-db.c
+++ b/libdmapsharing/test-dmap-db.c
@@ -63,7 +63,7 @@ test_dmap_db_count (const DmapDb *db)
return g_hash_table_size (TEST_DMAP_DB (db)->priv->db);
}
-guint
+static guint
test_dmap_db_add (DmapDb *db, DmapRecord *record, G_GNUC_UNUSED GError **error)
{
guint id;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]