[gjs/wip/ptomato/warnings: 14/15] build: Fix various compiler warnings



commit c5bd16d021258a3321b522758f95f975eb6a480b
Author: Philip Chimento <philip chimento gmail com>
Date:   Sun Oct 2 15:56:46 2016 -0700

    build: Fix various compiler warnings
    
    Fixing various compiler warnings that are too small to have their own
    commit.

 gi/arg.cpp                   |    3 ++-
 gi/fundamental.h             |    7 ++++---
 gi/object.cpp                |    4 ++--
 gi/value.cpp                 |    4 ++--
 gjs/compat.h                 |    6 ++++++
 gjs/jsapi-private.cpp        |    1 +
 gjs/jsapi-util-error.cpp     |    1 +
 gjs/runtime.cpp              |    2 +-
 gjs/type-module.cpp          |    1 +
 installed-tests/gjs-unit.cpp |    4 ++--
 modules/cairo.cpp            |    2 +-
 test/gjs-test-coverage.cpp   |    9 ++++++---
 util/log.cpp                 |    7 +++++++
 13 files changed, 36 insertions(+), 15 deletions(-)
---
diff --git a/gi/arg.cpp b/gi/arg.cpp
index e3e0731..6b2324e 100644
--- a/gi/arg.cpp
+++ b/gi/arg.cpp
@@ -2826,7 +2826,8 @@ gjs_value_from_g_argument (JSContext  *context,
                 return result;
             } else {
                 /* arrays with length are handled outside of this function */
-                g_assert(("Use gjs_value_from_explicit_array() for arrays with length param",
+                g_assert(((void) "Use gjs_value_from_explicit_array() for "
+                          "arrays with length param",
                           g_type_info_get_array_length(type_info) == -1));
                 return gjs_array_from_fixed_size_array(context, value_p, type_info, arg->v_pointer);
             }
diff --git a/gi/fundamental.h b/gi/fundamental.h
index dec8fcf..824f1e2 100644
--- a/gi/fundamental.h
+++ b/gi/fundamental.h
@@ -53,9 +53,10 @@ bool      gjs_typecheck_fundamental(JSContext       *context,
                                     GType            expected_gtype,
                                     bool             throw_error);
 
-bool      gjs_typecheck_is_fundamental       (JSContext     *context,
-                                              JSObject      *object,
-                                              bool           throw_error);
+bool      gjs_typecheck_is_fundamental(JSContext       *context,
+                                       JS::HandleObject object,
+                                       bool             throw_error);
+
 void*     gjs_fundamental_ref                (JSContext     *context,
                                               void          *fobj);
 void      gjs_fundamental_unref              (JSContext     *context,
diff --git a/gi/object.cpp b/gi/object.cpp
index 1b87a34..120fd0f 100644
--- a/gi/object.cpp
+++ b/gi/object.cpp
@@ -2999,8 +2999,8 @@ gjs_signal_new(JSContext *cx,
             return false;
         }
 
-        JS::RootedObject gtype(cx, &gtype_val.toObject());
-        params[i] = gjs_gtype_get_actual_gtype(cx, gtype);
+        JS::RootedObject gjs_gtype(cx, &gtype_val.toObject());
+        params[i] = gjs_gtype_get_actual_gtype(cx, gjs_gtype);
     }
 
     gtype = gjs_gtype_get_actual_gtype(cx, obj);
diff --git a/gi/value.cpp b/gi/value.cpp
index dc80d9d..ee5a1cf 100644
--- a/gi/value.cpp
+++ b/gi/value.cpp
@@ -947,8 +947,8 @@ gjs_value_from_g_value_internal(JSContext    *context,
         arg_info = g_callable_info_get_arg(signal_info, arg_n - 1);
         g_arg_info_load_type(arg_info, &type_info);
 
-        g_assert(("Check gjs_value_from_array_and_length_values() before calling"
-                  " gjs_value_from_g_value_internal()",
+        g_assert(((void) "Check gjs_value_from_array_and_length_values() before"
+                  " calling gjs_value_from_g_value_internal()",
                   g_type_info_get_array_length(&type_info) == -1));
 
         arg.v_pointer = g_value_get_pointer(gvalue);
diff --git a/gjs/compat.h b/gjs/compat.h
index 329f259..c61c61f 100644
--- a/gjs/compat.h
+++ b/gjs/compat.h
@@ -29,10 +29,16 @@
 _Pragma("clang diagnostic push")
 _Pragma("clang diagnostic ignored \"-Wuninitialized\"")
 _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"")
+_Pragma("clang diagnostic ignored \"-Wunused-variable\"")
+_Pragma("clang diagnostic ignored \"-Wignored-qualifiers\"")
 #elif __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
 _Pragma("GCC diagnostic push")
 _Pragma("GCC diagnostic ignored \"-Wstrict-prototypes\"")
 _Pragma("GCC diagnostic ignored \"-Winvalid-offsetof\"")
+_Pragma("GCC diagnostic ignored \"-Wunused-variable\"")
+_Pragma("GCC diagnostic ignored \"-Wredundant-decls\"")
+_Pragma("GCC diagnostic ignored \"-Wignored-qualifiers\"")
+_Pragma("GCC diagnostic ignored \"-Wshadow\"")
 #endif
 #include <jsapi.h>
 #include <jsdbgapi.h> // Needed by some bits
diff --git a/gjs/jsapi-private.cpp b/gjs/jsapi-private.cpp
index e0314e3..d3fc96a 100644
--- a/gjs/jsapi-private.cpp
+++ b/gjs/jsapi-private.cpp
@@ -35,6 +35,7 @@
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wstrict-prototypes"
 #pragma GCC diagnostic ignored "-Winvalid-offsetof"
+#pragma GCC diagnostic ignored "-Wredundant-decls"
 #include <jsfriendapi.h>
 #pragma GCC diagnostic pop
 
diff --git a/gjs/jsapi-util-error.cpp b/gjs/jsapi-util-error.cpp
index c6849a7..983b43e 100644
--- a/gjs/jsapi-util-error.cpp
+++ b/gjs/jsapi-util-error.cpp
@@ -42,6 +42,7 @@
  * http://egachine.berlios.de/embedding-sm-best-practice/embedding-sm-best-practice.html#error-handling
  */
 static void
+G_GNUC_PRINTF(3, 0)
 gjs_throw_valist(JSContext       *context,
                  const char      *error_class,
                  const char      *format,
diff --git a/gjs/runtime.cpp b/gjs/runtime.cpp
index de2e779..cc6a536 100644
--- a/gjs/runtime.cpp
+++ b/gjs/runtime.cpp
@@ -164,7 +164,7 @@ static JSLocaleCallbacks gjs_locale_callbacks =
     gjs_locale_to_unicode
 };
 
-void
+static void
 gjs_finalize_callback(JSFreeOp         *fop,
                       JSFinalizeStatus  status,
                       JSBool            isCompartment)
diff --git a/gjs/type-module.cpp b/gjs/type-module.cpp
index 730d14c..4457d94 100644
--- a/gjs/type-module.cpp
+++ b/gjs/type-module.cpp
@@ -51,6 +51,7 @@ gjs_type_module_load (GTypeModule *self)
     return true;
 }
 
+G_GNUC_NORETURN
 static void
 gjs_type_module_unload (GTypeModule *self)
 {
diff --git a/installed-tests/gjs-unit.cpp b/installed-tests/gjs-unit.cpp
index 4f093d4..034273f 100644
--- a/installed-tests/gjs-unit.cpp
+++ b/installed-tests/gjs-unit.cpp
@@ -41,7 +41,7 @@ typedef struct {
     char       *filename;
 } GjsTestData;
 
-GjsTestData *
+static GjsTestData *
 gjs_unit_test_data_new(const char *coverage_prefix,
                        const char *coverage_output_path,
                        char       *filename)
@@ -53,7 +53,7 @@ gjs_unit_test_data_new(const char *coverage_prefix,
     return data;
 }
 
-void
+static void
 gjs_unit_test_data_free(gpointer test_data, gpointer user_data)
 {
     GjsTestData *data = (GjsTestData *) test_data;
diff --git a/modules/cairo.cpp b/modules/cairo.cpp
index 7e4b915..3ca5769 100644
--- a/modules/cairo.cpp
+++ b/modules/cairo.cpp
@@ -25,7 +25,7 @@
 #include "gjs/compat.h"
 #include "cairo-private.h"
 
-#if CAIRO_HAS_XLIB_SURFACE
+#ifdef CAIRO_HAS_XLIB_SURFACE
 #include "cairo-xlib.h"
 
 class XLibConstructor {
diff --git a/test/gjs-test-coverage.cpp b/test/gjs-test-coverage.cpp
index 6b93874..67f60ed 100644
--- a/test/gjs-test-coverage.cpp
+++ b/test/gjs-test-coverage.cpp
@@ -36,6 +36,8 @@
 #include "gjs/coverage.h"
 #include "gjs/coverage-internal.h"
 
+#include "gjs-tests-add-funcs.h"
+
 typedef struct _GjsCoverageFixture {
     GjsContext    *context;
     GjsCoverage   *coverage;
@@ -338,7 +340,7 @@ coverage_data_matches_values_for_key(const char            *data,
 }
 
 /* A simple wrapper around gjs_coverage_new */
-GjsCoverage *
+static GjsCoverage *
 create_coverage_for_script(GjsContext *context,
                            const char *script)
 {
@@ -351,7 +353,7 @@ create_coverage_for_script(GjsContext *context,
                             context);
 }
 
-GjsCoverage *
+static GjsCoverage *
 create_coverage_for_script_and_cache(GjsContext *context,
                                      const char *cache,
                                      const char *script)
@@ -2207,7 +2209,8 @@ add_table_driven_test_for_fixture(const char                *name,
     for (test_table_index = 0;
          test_table_index < n_table_entries;
          ++test_table_index, test_table_ptr += table_entry_size) {
-        TestTableDataHeader *header = (TestTableDataHeader *) test_table_ptr;
+        const TestTableDataHeader *header =
+            reinterpret_cast<const TestTableDataHeader *>(test_table_ptr);
         gchar *test_name_for_table_index = g_strdup_printf("%s/%s",
                                                            name,
                                                            header->test_name);
diff --git a/util/log.cpp b/util/log.cpp
index e211031..38901db 100644
--- a/util/log.cpp
+++ b/util/log.cpp
@@ -125,7 +125,14 @@ gjs_debug(GjsDebugTopic topic,
              */
             c = strchr((char *) debug_output, '%');
             if (c && c[1] == 'u' && !strchr(c+1, '%')) {
+#if defined(__clang__) || __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
+_Pragma("GCC diagnostic push")
+_Pragma("GCC diagnostic ignored \"-Wformat-nonliteral\"")
+#endif
                 free_me = g_strdup_printf(debug_output, (guint)getpid());
+#if defined(__clang__) || __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
+_Pragma("GCC diagnostic pop")
+#endif
                 log_file = free_me;
             } else {
                 log_file = debug_output;


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