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.
This commit is contained in:
Marvin W 2020-01-21 21:53:43 +01:00
parent 55b148a0f7
commit 4a9c05ea37
No known key found for this signature in database
GPG Key ID: 072E9235DB996F2A
8 changed files with 66 additions and 54 deletions

View File

@ -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 ()
AddCFlagIfSupported(-Wall)
AddCFlagIfSupported(-Werror=format-security)
# 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)
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 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 ()
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 ()
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")

View File

@ -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));
}

View File

@ -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

View File

@ -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]);

View File

@ -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")]

View File

@ -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) {

View File

@ -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")]

View File

@ -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")]