diff options
author | Marvin W <git@larma.de> | 2020-01-21 21:53:43 +0100 |
---|---|---|
committer | Marvin W <git@larma.de> | 2020-01-21 21:55:08 +0100 |
commit | 4a9c05ea372e8f1279644ad6dc519ca407aec88a (patch) | |
tree | e76c9dfa5a716831a9f3496353d304c15fce84a0 | |
parent | 55b148a0f78c1abef57c21b2a84d97cad32b2290 (diff) | |
download | dino-4a9c05ea372e8f1279644ad6dc519ca407aec88a.tar.gz dino-4a9c05ea372e8f1279644ad6dc519ca407aec88a.zip |
Enabling display of more compiler warnings and fix some of them
Most of these are caused by various issues is the Vala compiler,
but it doesn't hurt to display them and report them upstream.
-rw-r--r-- | CMakeLists.txt | 68 | ||||
-rw-r--r-- | main/src/emojichooser.c | 4 | ||||
-rw-r--r-- | main/src/emojichooser.h | 2 | ||||
-rw-r--r-- | main/src/ui/occupant_menu/list.vala | 6 | ||||
-rw-r--r-- | plugins/crypto-vala/vapi/gcrypt.vapi | 4 | ||||
-rw-r--r-- | plugins/signal-protocol/src/store.vala | 14 | ||||
-rw-r--r-- | plugins/signal-protocol/vapi/signal-protocol-native.vapi | 16 | ||||
-rw-r--r-- | xmpp-vala/vapi/icu-uc.vapi | 6 |
8 files changed, 66 insertions, 54 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 13c84af7..06810ef2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.0) +cmake_minimum_required(VERSION 3.3) list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake) include(ComputeVersion) if (NOT VERSION_FOUND) @@ -88,45 +88,65 @@ set(PLUGIN_INSTALL LIBRARY DESTINATION ${PLUGIN_INSTALL_DIR} RUNTIME DESTINATION include(CheckCCompilerFlag) include(CheckCSourceCompiles) -macro(AddCFlagIfSupported flag) +macro(AddCFlagIfSupported list flag) string(REGEX REPLACE "[^a-z^A-Z^_^0-9]+" "_" flag_name ${flag}) check_c_compiler_flag(${flag} COMPILER_SUPPORTS${flag_name}) if (${COMPILER_SUPPORTS${flag_name}}) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${flag}") - endif () -endmacro() - -macro(AddValaCFlagIfSupported flag) - string(REGEX REPLACE "[^a-z^A-Z^_^0-9]+" "_" flag_name ${flag}) - check_c_compiler_flag(${flag} COMPILER_SUPPORTS${flag_name}) - if (${COMPILER_SUPPORTS${flag_name}}) - set(VALA_CFLAGS "${VALA_CFLAGS} ${flag}") + set(${list} "${${list}} ${flag}") endif () endmacro() if ("Ninja" STREQUAL ${CMAKE_GENERATOR}) - AddCFlagIfSupported(-fdiagnostics-color COMPILER_SUPPORTS_fdiagnistics-color) + AddCFlagIfSupported(CMAKE_C_FLAGS -fdiagnostics-color) +endif () + +# Flags for all C files +AddCFlagIfSupported(CMAKE_C_FLAGS -Wall) +AddCFlagIfSupported(CMAKE_C_FLAGS -Wextra) +AddCFlagIfSupported(CMAKE_C_FLAGS -Werror=format-security) +AddCFlagIfSupported(CMAKE_C_FLAGS -Wno-duplicate-decl-specifier) + +if (NOT VALA_WARN) + set(VALA_WARN "conversion") +endif () +set(VALA_WARN "${VALA_WARN}" CACHE STRING "Which warnings to show when invoking C compiler on Vala compiler output") +set_property(CACHE VALA_WARN PROPERTY STRINGS "all;unused;qualifier;conversion;deprecated;format;none") + +# Vala generates some unused stuff +if (NOT ("all" IN_LIST VALA_WARN OR "unused" IN_LIST VALA_WARN)) + AddCFlagIfSupported(VALA_CFLAGS -Wno-unused-but-set-variable) + AddCFlagIfSupported(VALA_CFLAGS -Wno-unused-function) + AddCFlagIfSupported(VALA_CFLAGS -Wno-unused-label) + AddCFlagIfSupported(VALA_CFLAGS -Wno-unused-parameter) + AddCFlagIfSupported(VALA_CFLAGS -Wno-unused-value) + AddCFlagIfSupported(VALA_CFLAGS -Wno-unused-variable) +endif () + +if (NOT ("all" IN_LIST VALA_WARN OR "qualifier" IN_LIST VALA_WARN)) + AddCFlagIfSupported(VALA_CFLAGS -Wno-discarded-qualifiers) + AddCFlagIfSupported(VALA_CFLAGS -Wno-discarded-array-qualifiers) endif () -AddCFlagIfSupported(-Wall) -AddCFlagIfSupported(-Werror=format-security) +if (NOT ("all" IN_LIST VALA_WARN OR "deprecated" IN_LIST VALA_WARN)) + AddCFlagIfSupported(VALA_CFLAGS -Wno-deprecated-declarations) +endif () + +if (NOT ("all" IN_LIST VALA_WARN OR "format" IN_LIST VALA_WARN)) + AddCFlagIfSupported(VALA_CFLAGS -Wno-missing-braces) +endif () -AddValaCFlagIfSupported(-Wno-incompatible-pointer-types) -AddValaCFlagIfSupported(-Wno-pointer-sign) -AddValaCFlagIfSupported(-Wno-int-conversion) -AddValaCFlagIfSupported(-Wno-discarded-qualifiers) -AddValaCFlagIfSupported(-Wno-unused-but-set-variable) -AddValaCFlagIfSupported(-Wno-unused-variable) -AddValaCFlagIfSupported(-Wno-unused-function) -AddValaCFlagIfSupported(-Wno-unused-label) +if (NOT ("all" IN_LIST VALA_WARN OR "conversion" IN_LIST VALA_WARN)) + AddCFlagIfSupported(VALA_CFLAGS -Wno-int-conversion) + AddCFlagIfSupported(VALA_CFLAGS -Wno-pointer-sign) + AddCFlagIfSupported(VALA_CFLAGS -Wno-incompatible-pointer-types) +endif () try_compile(__WITHOUT_FILE_OFFSET_BITS_64 ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR}/cmake/LargeFileOffsets.c COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}) if (NOT __WITHOUT_FILE_OFFSET_BITS_64) try_compile(__WITH_FILE_OFFSET_BITS_64 ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR}/cmake/LargeFileOffsets.c COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} -D_FILE_OFFSET_BITS=64) if (__WITH_FILE_OFFSET_BITS_64) - AddCFlagIfSupported(-D_FILE_OFFSET_BITS=64) - AddValaCFlagIfSupported(-D_FILE_OFFSET_BITS=64) + AddCFlagIfSupported(CMAKE_C_FLAGS -D_FILE_OFFSET_BITS=64) message(STATUS "Enabled large file support using _FILE_OFFSET_BITS=64") else (__WITH_FILE_OFFSET_BITS_64) message(STATUS "Large file support not available") diff --git a/main/src/emojichooser.c b/main/src/emojichooser.c index f8c0c51c..35d3bcff 100644 --- a/main/src/emojichooser.c +++ b/main/src/emojichooser.c @@ -813,8 +813,8 @@ dino_emoji_chooser_class_init (DinoEmojiChooserClass *klass) gtk_widget_class_bind_template_callback (widget_class, search_changed); } -GtkWidget * +DinoEmojiChooser * dino_emoji_chooser_new (void) { - return GTK_WIDGET (g_object_new (GTK_TYPE_EMOJI_CHOOSER, NULL)); + return DINO_EMOJI_CHOOSER (g_object_new (GTK_TYPE_EMOJI_CHOOSER, NULL)); } diff --git a/main/src/emojichooser.h b/main/src/emojichooser.h index 3e459431..e7dc8660 100644 --- a/main/src/emojichooser.h +++ b/main/src/emojichooser.h @@ -31,6 +31,6 @@ typedef struct _DinoEmojiChooser DinoEmojiChooser; typedef struct _DinoEmojiChooserClass DinoEmojiChooserClass; GType dino_emoji_chooser_get_type (void) G_GNUC_CONST; -GtkWidget *dino_emoji_chooser_new (void); +DinoEmojiChooser *dino_emoji_chooser_new (void); G_END_DECLS diff --git a/main/src/ui/occupant_menu/list.vala b/main/src/ui/occupant_menu/list.vala index c422a899..ffa98f31 100644 --- a/main/src/ui/occupant_menu/list.vala +++ b/main/src/ui/occupant_menu/list.vala @@ -24,7 +24,7 @@ public class List : Box { list_box.set_header_func(header); list_box.set_sort_func(sort); list_box.set_filter_func(filter); - search_entry.search_changed.connect(search_changed); + search_entry.search_changed.connect(refilter); stream_interactor.get_module(PresenceManager.IDENTITY).show_received.connect(on_show_received); stream_interactor.get_module(RosterManager.IDENTITY).updated_roster_item.connect(on_updated_roster_item); @@ -52,10 +52,6 @@ public class List : Box { list_box.invalidate_filter(); } - private void search_changed(Editable editable) { - refilter(); - } - public void add_occupant(Jid jid) { rows[jid] = new ListRow(stream_interactor, conversation, jid); list_box.add(rows[jid]); diff --git a/plugins/crypto-vala/vapi/gcrypt.vapi b/plugins/crypto-vala/vapi/gcrypt.vapi index ca620e0f..0fa69a02 100644 --- a/plugins/crypto-vala/vapi/gcrypt.vapi +++ b/plugins/crypto-vala/vapi/gcrypt.vapi @@ -608,9 +608,9 @@ namespace GCrypt { CBC_CTS, /* Enable CBC cipher text stealing (CTS). */ CBC_MAC /* Enable CBC message auth. code (MAC). */ } - [Compact] [CCode (cname = "gcry_cipher_hd_t", lower_case_cprefix = "gcry_cipher_", free_function = "gcry_cipher_close")] - public class Cipher { + [SimpleType] + public struct Cipher { public static Error open (out Cipher cipher, Algorithm algo, Mode mode, Flag flags); public void close (); [CCode (cname = "gcry_cipher_ctl")] diff --git a/plugins/signal-protocol/src/store.vala b/plugins/signal-protocol/src/store.vala index 632ff8cc..b440d838 100644 --- a/plugins/signal-protocol/src/store.vala +++ b/plugins/signal-protocol/src/store.vala @@ -138,12 +138,12 @@ public class Store : Object { }); } - static int iks_destroy_func(void* user_data) { - return 0; + static void iks_destroy_func(void* user_data) { } static int ss_load_session_func(out Buffer? record, out Buffer? user_record, Address address, void* user_data) { Store store = (Store) user_data; + user_record = null; // No support for user_record uint8[]? res = null; try { res = store.session_store.load_session(address); @@ -156,7 +156,6 @@ public class Store : Object { return 0; } record = new Buffer.from((!)res); - user_record = null; // No support for user_record if (record == null) return ErrorCode.NOMEM; return 1; } @@ -204,8 +203,7 @@ public class Store : Object { }); } - static int ss_destroy_func(void* user_data) { - return 0; + static void ss_destroy_func(void* user_data) { } static int pks_load_pre_key(out Buffer? record, uint32 pre_key_id, void* user_data) { @@ -249,8 +247,7 @@ public class Store : Object { }); } - static int pks_destroy_func(void* user_data) { - return 0; + static void pks_destroy_func(void* user_data) { } static int spks_load_signed_pre_key(out Buffer? record, uint32 pre_key_id, void* user_data) { @@ -294,8 +291,7 @@ public class Store : Object { }); } - static int spks_destroy_func(void* user_data) { - return 0; + static void spks_destroy_func(void* user_data) { } internal Store(Context context) { diff --git a/plugins/signal-protocol/vapi/signal-protocol-native.vapi b/plugins/signal-protocol/vapi/signal-protocol-native.vapi index fd69d7d0..0bac0317 100644 --- a/plugins/signal-protocol/vapi/signal-protocol-native.vapi +++ b/plugins/signal-protocol/vapi/signal-protocol-native.vapi @@ -64,15 +64,15 @@ namespace Signal { [CCode (has_target = false)] public delegate int LoadSessionFunc(out Buffer record, out Buffer user_record, Address address, void* user_data); [CCode (has_target = false)] - public delegate int GetSubDeviceSessionsFunc(out IntList sessions, char[] name, void* user_data); + public delegate int GetSubDeviceSessionsFunc(out IntList sessions, [CCode (array_length_type = "size_t")] char[] name, void* user_data); [CCode (has_target = false)] - public delegate int StoreSessionFunc(Address address, uint8[] record, uint8[] user_record, void* user_data); + public delegate int StoreSessionFunc(Address address, [CCode (array_length_type = "size_t")] uint8[] record, [CCode (array_length_type = "size_t")] uint8[] user_record, void* user_data); [CCode (has_target = false)] public delegate int ContainsSessionFunc(Address address, void* user_data); [CCode (has_target = false)] public delegate int DeleteSessionFunc(Address address, void* user_data); [CCode (has_target = false)] - public delegate int DeleteAllSessionsFunc(char[] name, void* user_data); + public delegate int DeleteAllSessionsFunc([CCode (array_length_type = "size_t")] char[] name, void* user_data); [Compact] [CCode (cname = "signal_protocol_identity_key_store", cheader_filename = "signal/signal_protocol.h")] @@ -89,9 +89,9 @@ namespace Signal { [CCode (has_target = false)] public delegate int GetLocalRegistrationIdFunc(void* user_data, out uint32 registration_id); [CCode (has_target = false)] - public delegate int SaveIdentityFunc(Address address, uint8[] key, void* user_data); + public delegate int SaveIdentityFunc(Address address, [CCode (array_length_type = "size_t")] uint8[] key, void* user_data); [CCode (has_target = false)] - public delegate int IsTrustedIdentityFunc(Address address, uint8[] key, void* user_data); + public delegate int IsTrustedIdentityFunc(Address address, [CCode (array_length_type = "size_t")] uint8[] key, void* user_data); [Compact] [CCode (cname = "signal_protocol_pre_key_store", cheader_filename = "signal/signal_protocol.h")] @@ -106,7 +106,7 @@ namespace Signal { [CCode (has_target = false)] public delegate int LoadPreKeyFunc(out Buffer record, uint32 pre_key_id, void* user_data); [CCode (has_target = false)] - public delegate int StorePreKeyFunc(uint32 pre_key_id, uint8[] record, void* user_data); + public delegate int StorePreKeyFunc(uint32 pre_key_id, [CCode (array_length_type = "size_t")] uint8[] record, void* user_data); [CCode (has_target = false)] public delegate int ContainsPreKeyFunc(uint32 pre_key_id, void* user_data); [CCode (has_target = false)] @@ -134,12 +134,12 @@ namespace Signal { void* user_data; } [CCode (has_target = false)] - public delegate int StoreSenderKeyFunc(SenderKeyName sender_key_name, uint8[] record, uint8[] user_record, void* user_data); + public delegate int StoreSenderKeyFunc(SenderKeyName sender_key_name, [CCode (array_length_type = "size_t")] uint8[] record, [CCode (array_length_type = "size_t")] uint8[] user_record, void* user_data); [CCode (has_target = false)] public delegate int LoadSenderKeyFunc(out Buffer record, out Buffer user_record, SenderKeyName sender_key_name, void* user_data); [CCode (has_target = false)] - public delegate int DestroyFunc(void* user_data); + public delegate void DestroyFunc(void* user_data); [Compact] [CCode (cname = "signal_protocol_store_context", cprefix = "signal_protocol_store_context_", free_function="signal_protocol_store_context_destroy", cheader_filename = "signal/signal_protocol.h")] diff --git a/xmpp-vala/vapi/icu-uc.vapi b/xmpp-vala/vapi/icu-uc.vapi index 9768e10b..ea28a32a 100644 --- a/xmpp-vala/vapi/icu-uc.vapi +++ b/xmpp-vala/vapi/icu-uc.vapi @@ -5,7 +5,7 @@ namespace ICU { [IntegerType (rank = 5, min = 0, max = 65535)] struct Char {} -[CCode (cname = "UChar*", destroy_function="g_free", has_type_id = false)] +[CCode (cname = "UChar*", destroy_function="g_free", has_type_id = false, cheader_filename = "unicode/ustring.h")] [SimpleType] struct String { public static String alloc(int32 length) { @@ -26,7 +26,7 @@ struct String { public string to_string() throws GLib.ConvertError { ErrorCode status = ErrorCode.ZERO_ERROR; - uint8[] dest = new uint8[len() * 4 + 1]; + char[] dest = new char[len() * 4 + 1]; int32 dest_length; strToUTF8(dest, out dest_length, this, -1, ref status); if (status.is_failure()) { @@ -42,7 +42,7 @@ struct String { [CCode (cname="u_strFromUTF8")] private static void strFromUTF8(String dest, int32 dest_capacity, out int32 dest_length, string src, int32 src_length, ref ErrorCode status); [CCode (cname="u_strToUTF8")] - private static void strToUTF8(uint8[] dest, out int32 dest_length, String src, int32 src_length, ref ErrorCode status); + private static void strToUTF8(char[] dest, out int32 dest_length, String src, int32 src_length, ref ErrorCode status); } [CCode (cname = "UErrorCode", cprefix = "U_", cheader_filename = "unicode/utypes.h")] |