[gjs/gnome-41] gjs/jsapi-util.cpp: fix build on gcc-12



commit 4f76c40733af86121b96f8471ff43278808c2a47
Author: Sergei Trofimovich <slyich gmail com>
Date:   Sun Dec 26 13:09:51 2021 +0000

    gjs/jsapi-util.cpp: fix build on gcc-12
    
    c++17 (gcc-12 default) and disallows std::string to be
    initialized by NULL pointer:
    
        ../gjs/jsapi-util.cpp: In function 'std::string _gjs_g_utf8_make_valid(const char*)':
          ...-glib-2.70.2-dev/include/glib-2.0/glib/gmessages.h:652:20:
            error: use of deleted function 'std::...::basic_string(std::nullptr_t)
              [with _CharT = char; _Traits = std::char_traits<char>;
                _Alloc = std::allocator<char>; std::nullptr_t = std::nullptr_t]'
          652 |         return (val); \
              |                    ^
        ../gjs/jsapi-util.cpp:273:5: note: in expansion of macro 'g_return_val_if_fail'
          273 |     g_return_val_if_fail (name != NULL, NULL);
              |     ^~~~~~~~~~~~~~~~~~~~

 gjs/jsapi-util.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
---
diff --git a/gjs/jsapi-util.cpp b/gjs/jsapi-util.cpp
index 6f2df2cdc..bf5210c09 100644
--- a/gjs/jsapi-util.cpp
+++ b/gjs/jsapi-util.cpp
@@ -270,7 +270,7 @@ JSObject* gjs_define_string_array(JSContext* context,
     const char *remainder, *invalid;
     int remaining_bytes, valid_bytes;
 
-    g_return_val_if_fail (name != NULL, NULL);
+    g_return_val_if_fail (name != NULL, "");
 
     remainder = name;
     remaining_bytes = strlen (name);


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