Fix various deprecation warnings in code and tests

This code uses, or tests, deprecated functions, types or macros; so
needs to be compiled with deprecation warnings disabled.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
This commit is contained in:
Philip Withnall 2019-05-27 19:30:31 +01:00
parent f0fb7b77a1
commit e62e89f2f8
4 changed files with 15 additions and 11 deletions

View File

@ -20,6 +20,10 @@
#include "config.h" #include "config.h"
/* For the #GDesktopAppInfoLookup macros; since macro deprecation is implemented
* in the preprocessor, we need to define this before including glib.h*/
#define GLIB_DISABLE_DEPRECATION_WARNINGS
#include <string.h> #include <string.h>
#include "giomodule.h" #include "giomodule.h"
@ -1087,9 +1091,7 @@ _g_io_modules_ensure_extension_points_registered (void)
#if defined(G_OS_UNIX) && !defined(HAVE_COCOA) #if defined(G_OS_UNIX) && !defined(HAVE_COCOA)
#if !GLIB_CHECK_VERSION (3, 0, 0) #if !GLIB_CHECK_VERSION (3, 0, 0)
ep = g_io_extension_point_register (G_DESKTOP_APP_INFO_LOOKUP_EXTENSION_POINT_NAME); ep = g_io_extension_point_register (G_DESKTOP_APP_INFO_LOOKUP_EXTENSION_POINT_NAME);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
g_io_extension_point_set_required_type (ep, G_TYPE_DESKTOP_APP_INFO_LOOKUP); g_io_extension_point_set_required_type (ep, G_TYPE_DESKTOP_APP_INFO_LOOKUP);
G_GNUC_END_IGNORE_DEPRECATIONS
#endif #endif
#endif #endif

View File

@ -28,6 +28,9 @@
#include "config.h" #include "config.h"
/* we know we are deprecated here, no need for warnings */
#define GLIB_DISABLE_DEPRECATION_WARNINGS
#include "gcache.h" #include "gcache.h"
#include "gslice.h" #include "gslice.h"

View File

@ -1,6 +1,5 @@
#undef G_DISABLE_ASSERT #undef G_DISABLE_ASSERT
#undef G_LOG_DOMAIN #undef G_LOG_DOMAIN
#undef G_DISABLE_DEPRECATED
#include <time.h> #include <time.h>
#include <stdlib.h> #include <stdlib.h>

View File

@ -1169,10 +1169,11 @@ hash_table_tests (void)
g_hash_table_destroy (hash_table); g_hash_table_destroy (hash_table);
} }
#ifndef G_DISABLE_DEPRECATED
static void static void
relation_test (void) relation_test (void)
{ {
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
GRelation *relation = g_relation_new (2); GRelation *relation = g_relation_new (2);
GTuples *tuples; GTuples *tuples;
gint data [1024]; gint data [1024];
@ -1241,8 +1242,9 @@ relation_test (void)
g_relation_destroy (relation); g_relation_destroy (relation);
relation = NULL; relation = NULL;
G_GNUC_END_IGNORE_DEPRECATIONS
} }
#endif
static void static void
gstring_tests (void) gstring_tests (void)
@ -1637,10 +1639,11 @@ various_string_tests (void)
/* g_debug (argv[0]); */ /* g_debug (argv[0]); */
} }
#ifndef G_DISABLE_DEPRECATED
static void static void
test_mem_chunks (void) test_mem_chunks (void)
{ {
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
GMemChunk *mem_chunk = g_mem_chunk_new ("test mem chunk", 50, 100, G_ALLOC_AND_FREE); GMemChunk *mem_chunk = g_mem_chunk_new ("test mem chunk", 50, 100, G_ALLOC_AND_FREE);
gchar *mem[10000]; gchar *mem[10000];
guint i; guint i;
@ -1655,8 +1658,9 @@ test_mem_chunks (void)
g_mem_chunk_free (mem_chunk, mem[i]); g_mem_chunk_free (mem_chunk, mem[i]);
g_mem_chunk_destroy (mem_chunk); g_mem_chunk_destroy (mem_chunk);
G_GNUC_END_IGNORE_DEPRECATIONS
} }
#endif
int int
main (int argc, main (int argc,
@ -1674,15 +1678,11 @@ main (int argc,
g_test_add_func ("/testglib/GTree", binary_tree_test); g_test_add_func ("/testglib/GTree", binary_tree_test);
g_test_add_func ("/testglib/Arrays", test_arrays); g_test_add_func ("/testglib/Arrays", test_arrays);
g_test_add_func ("/testglib/GHashTable", hash_table_tests); g_test_add_func ("/testglib/GHashTable", hash_table_tests);
#ifndef G_DISABLE_DEPRECATED
g_test_add_func ("/testglib/Relation (deprecated)", relation_test); g_test_add_func ("/testglib/Relation (deprecated)", relation_test);
#endif
g_test_add_func ("/testglib/File Paths", test_paths); g_test_add_func ("/testglib/File Paths", test_paths);
g_test_add_func ("/testglib/File Functions", test_file_functions); g_test_add_func ("/testglib/File Functions", test_file_functions);
g_test_add_func ("/testglib/Parse Debug Strings", test_g_parse_debug_string); g_test_add_func ("/testglib/Parse Debug Strings", test_g_parse_debug_string);
#ifndef G_DISABLE_DEPRECATED
g_test_add_func ("/testglib/GMemChunk (deprecated)", test_mem_chunks); g_test_add_func ("/testglib/GMemChunk (deprecated)", test_mem_chunks);
#endif
g_test_add_func ("/testglib/Warnings & Errors", log_warning_error_tests); g_test_add_func ("/testglib/Warnings & Errors", log_warning_error_tests);
g_test_add_func ("/testglib/Timers (slow)", timer_tests); g_test_add_func ("/testglib/Timers (slow)", timer_tests);