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



commit bfc65c6c51dcb40eeaebb1bead1ac8b74ff46e58
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/object.cpp                |    4 ++--
 gi/value.cpp                 |    4 ++--
 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 +++++++
 11 files changed, 26 insertions(+), 12 deletions(-)
---
diff --git a/gi/arg.cpp b/gi/arg.cpp
index 8f5b0bb..77a25d2 100644
--- a/gi/arg.cpp
+++ b/gi/arg.cpp
@@ -2762,7 +2762,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/object.cpp b/gi/object.cpp
index b8d7b33..517bed2 100644
--- a/gi/object.cpp
+++ b/gi/object.cpp
@@ -2962,8 +2962,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 a3da3fc..edff321 100644
--- a/gi/value.cpp
+++ b/gi/value.cpp
@@ -943,8 +943,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/jsapi-private.cpp b/gjs/jsapi-private.cpp
index 36a83d6..632d1da 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 66a819a..9b24b48 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 cfc52e3..512733c 100644
--- a/gjs/runtime.cpp
+++ b/gjs/runtime.cpp
@@ -165,7 +165,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 fc1bb38..3977cd4 100644
--- a/modules/cairo.cpp
+++ b/modules/cairo.cpp
@@ -26,7 +26,7 @@
 #include "gjs/jsapi-wrapper.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..7354c20 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-test-utils.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]