Commit 8a46b25c authored by Lubomir Rintel's avatar Lubomir Rintel 🥕

all: require glib 2.40

RHEL 7.1 and Ubuntu 14.04 LTS both have this.

https://bugzilla.gnome.org/show_bug.cgi?id=792323
parent 1443bf77
......@@ -626,8 +626,6 @@ main (int argc, char *argv[])
textdomain (GETTEXT_PACKAGE);
#endif
nm_g_type_init ();
/* Save terminal settings */
tcgetattr (STDIN_FILENO, &termios_orig);
......
......@@ -86,7 +86,7 @@ test_client_meta_check (void)
g_assert (pi->setting_info == info);
g_assert (pi->property_name);
g_assert (nm_g_hash_table_add (property_names, (gpointer) pi->property_name));
g_assert (g_hash_table_add (property_names, (gpointer) pi->property_name));
g_assert_cmpstr (pi->property_name, ==, pi->meta_type->get_name ((const NMMetaAbstractInfo *) pi, FALSE));
g_assert_cmpstr (pi->property_name, ==, pi->meta_type->get_name ((const NMMetaAbstractInfo *) pi, TRUE));
......@@ -107,7 +107,7 @@ test_client_meta_check (void)
for (i = 0; info->valid_parts[i]; i++) {
g_assert (info->valid_parts[i]->setting_info);
g_assert (nm_g_hash_table_add (dup, (gpointer) info->valid_parts[i]->setting_info));
g_assert (g_hash_table_add (dup, (gpointer) info->valid_parts[i]->setting_info));
if (i == 0) {
g_assert (info->valid_parts[i]->setting_info == &nm_meta_setting_infos_editor[NM_META_SETTING_TYPE_CONNECTION]);
......
......@@ -244,8 +244,6 @@ main (int argc, char *argv[])
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
textdomain (GETTEXT_PACKAGE);
nm_g_type_init ();
data.start_timestamp_ms = _now_ms ();
opt_ctx = g_option_context_new (NULL);
......
......@@ -359,21 +359,11 @@ nmt_newt_edit_string (const char *data)
goto done;
}
#if GLIB_CHECK_VERSION (2, 34, 0)
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
if (!g_spawn_check_exit_status (status, &error)) {
nmt_newt_message_dialog (_("Editor failed: %s"), error->message);
g_error_free (error);
goto done;
}
G_GNUC_END_IGNORE_DEPRECATIONS
#else
if (WIFEXITED (status)) {
if (WEXITSTATUS (status) != 0)
nmt_newt_message_dialog (_("Editor failed with status %d"), WEXITSTATUS (status));
} else if (WIFSIGNALED (status))
nmt_newt_message_dialog (_("Editor failed with signal %d"), WTERMSIG (status));
#endif
if (!g_file_get_contents (filename, &new_data, NULL, &error)) {
nmt_newt_message_dialog (_("Could not re-read file: %s"), error->message);
......
......@@ -234,14 +234,14 @@ AC_SUBST([DL_LIBS], "$ac_cv_search_dlopen")
PKG_CHECK_MODULES(GLIB, [gio-unix-2.0 >= 2.37.6 gmodule-2.0],
[AC_SUBST(LOG_DRIVER, '$(top_srcdir)/build-aux/tap-driver.sh')
AC_SUBST(AM_TESTS_FD_REDIRECT, '--tap')],
[PKG_CHECK_MODULES(GLIB, gio-unix-2.0 >= 2.32 gmodule-2.0)
[PKG_CHECK_MODULES(GLIB, gio-unix-2.0 >= 2.40 gmodule-2.0)
AC_SUBST(LOG_DRIVER, '$(top_srcdir)/build-aux/test-driver')])
dnl GLIB_VERSION_MIN_REQUIRED should match the version above.
dnl GLIB_VERSION_MAX_ALLOWED should be set to the same version;
dnl nm-glib.h will cause it to be overridden for the functions
dnl we have compat versions of.
GLIB_CFLAGS="$GLIB_CFLAGS -DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_32 -DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_32"
GLIB_CFLAGS="$GLIB_CFLAGS -DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_40 -DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_40"
AC_SUBST(GLIB_CFLAGS)
AC_SUBST(GLIB_LIBS)
......
......@@ -916,8 +916,6 @@ main (int argc, char **argv)
g_option_context_free (opt_ctx);
nm_g_type_init ();
g_unix_signal_add (SIGTERM, signal_handler, GINT_TO_POINTER (SIGTERM));
g_unix_signal_add (SIGINT, signal_handler, GINT_TO_POINTER (SIGINT));
......
......@@ -15,9 +15,6 @@ DOC_SOURCE_DIR=$(top_srcdir)/libnm-glib
# Extra options to supply to gtkdoc-scan.
SCAN_OPTIONS=
# Extra options to supply to gtkdoc-scangobj.
SCANGOBJ_OPTIONS=--type-init-func 'g_type_init();'
# Extra options to supply to gtkdoc-mkdb.
MKDB_OPTIONS=--sgml-mode --output-format=xml
......
......@@ -17,9 +17,6 @@ DOC_SOURCE_DIR= \
# Extra options to supply to gtkdoc-scan.
SCAN_OPTIONS=--rebuild-types --rebuild-sections
# Extra options to supply to gtkdoc-scangobj.
SCANGOBJ_OPTIONS=--type-init-func 'g_type_init();'
# Extra options to supply to gtkdoc-mkdb.
MKDB_OPTIONS=--sgml-mode --output-format=xml
......
......@@ -19,9 +19,6 @@ DOC_SOURCE_DIR= \
# Extra options to supply to gtkdoc-scan.
SCAN_OPTIONS=--rebuild-types --rebuild-sections
# Extra options to supply to gtkdoc-scangobj.
SCANGOBJ_OPTIONS=--type-init-func 'g_type_init();'
# Extra options to supply to gtkdoc-mkdb.
MKDB_OPTIONS=--sgml-mode --output-format=xml
......
......@@ -124,11 +124,6 @@ main (int argc, char *argv[])
GDBusProxy *proxy;
GError *error = NULL;
#if !GLIB_CHECK_VERSION (2, 35, 0)
/* Initialize GType system */
g_type_init ();
#endif
/* Create a D-Bus proxy; NM_DBUS_* defined in nm-dbus-interface.h */
proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
G_DBUS_PROXY_FLAGS_NONE,
......
......@@ -105,11 +105,6 @@ main (int argc, char *argv[])
GMainLoop *loop;
GError *error = NULL;
#if !GLIB_CHECK_VERSION (2, 35, 0)
/* Initialize GType system */
g_type_init ();
#endif
loop = g_main_loop_new (NULL, FALSE);
/* Connect to NetworkManager */
......
......@@ -251,11 +251,6 @@ main (int argc, char *argv[])
{
GDBusProxy *props_proxy;
#if !GLIB_CHECK_VERSION (2, 35, 0)
/* Initialize GType system */
g_type_init ();
#endif
/* Create a D-Bus proxy to get the object properties from the NM Manager
* object. NM_DBUS_* defines are from nm-dbus-interface.h.
*/
......
......@@ -202,11 +202,6 @@ main (int argc, char *argv[])
int i;
GError *error = NULL;
#if !GLIB_CHECK_VERSION (2, 35, 0)
/* Initialize GType system */
g_type_init ();
#endif
/* Get NMClient object */
client = nm_client_new (NULL, &error);
if (!client) {
......
......@@ -65,11 +65,6 @@ main (int argc, char *argv[])
{
GDBusProxy *proxy;
#if !GLIB_CHECK_VERSION (2, 35, 0)
/* Initialize GType system */
g_type_init ();
#endif
/* Create a D-Bus proxy; NM_DBUS_* defined in nm-dbus-interface.h */
proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
G_DBUS_PROXY_FLAGS_NONE,
......
......@@ -69,11 +69,6 @@ main (int argc, char *argv[])
const GPtrArray *connections;
int i;
#if !GLIB_CHECK_VERSION (2, 35, 0)
/* Initialize GType system */
g_type_init ();
#endif
if (!(client = nm_client_new (NULL, &error))) {
g_message ("Error: Could not connect to NetworkManager: %s.", error->message);
g_error_free (error);
......
......@@ -56,11 +56,6 @@ main (int argc, char *argv[])
GMainLoop *loop;
GBusNameWatcherFlags flags;
#if !GLIB_CHECK_VERSION (2, 35, 0)
/* Initialize GType system */
g_type_init ();
#endif
g_print ("Monitor 'org.freedesktop.NetworkManager' D-Bus name\n");
g_print ("===================================================\n");
......
......@@ -90,11 +90,6 @@ main (int argc, char *argv[])
GDBusProxyFlags flags;
GDBusProxy *proxy;
#if !GLIB_CHECK_VERSION (2, 35, 0)
/* Initialize GType system */
g_type_init ();
#endif
/* Monitor 'StateChanged' signal on 'org.freedesktop.NetworkManager' interface */
g_print ("Monitor NetworkManager's state\n");
g_print ("==============================\n");
......
......@@ -89,7 +89,7 @@ gboolean _nm_setting_clear_secrets_with_flags (NMSetting *setting,
/* Ensure the setting's GType is registered at library load time */
#define NM_SETTING_REGISTER_TYPE(x) \
static void __attribute__((constructor)) register_setting (void) \
{ nm_g_type_init (); g_type_ensure (x); }
{ g_type_ensure (x); }
GVariant *_nm_setting_get_deprecated_virtual_interface_name (NMSetting *setting,
NMConnection *connection,
......
......@@ -94,7 +94,6 @@ static void
_ensure_registered (void)
{
if (G_UNLIKELY (registered_settings == NULL)) {
nm_g_type_init ();
registered_settings = g_hash_table_new (nm_str_hash, g_str_equal);
registered_settings_by_type = g_hash_table_new (_nm_gtype_hash, _nm_gtype_equal);
}
......@@ -816,7 +815,7 @@ _nm_setting_new_from_dbus (GType setting_type,
g_variant_unref (entry_key);
g_variant_unref (entry);
if (!nm_g_hash_table_add (keys, key)) {
if (!g_hash_table_add (keys, key)) {
g_set_error (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_SETTING,
_("duplicate property"));
g_prefix_error (error, "%s.%s: ", nm_setting_get_name (setting), key);
......
......@@ -253,8 +253,6 @@ _nm_utils_init (void)
bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
nm_g_type_init ();
_nm_dbus_errors_init ();
}
......
......@@ -6093,66 +6093,6 @@ again:
/*****************************************************************************/
static void
test_g_ptr_array_insert (void)
{
/* this test only makes sense on a recent glib, where we compare our compat
* with the original implementation. */
#if GLIB_CHECK_VERSION(2, 40, 0)
gs_unref_ptrarray GPtrArray *arr1 = g_ptr_array_new ();
gs_unref_ptrarray GPtrArray *arr2 = g_ptr_array_new ();
GRand *rand = nmtst_get_rand ();
guint i;
for (i = 0; i < 560; i++) {
gint32 idx = g_rand_int_range (rand, -1, arr1->len + 1);
g_ptr_array_insert (arr1, idx, GINT_TO_POINTER (i));
_nm_g_ptr_array_insert (arr2, idx, GINT_TO_POINTER (i));
g_assert_cmpint (arr1->len, ==, arr2->len);
g_assert (memcmp (arr1->pdata, arr2->pdata, arr1->len * sizeof (gpointer)) == 0);
}
#endif
}
/*****************************************************************************/
static void
test_g_hash_table_get_keys_as_array (void)
{
GHashTable *table = g_hash_table_new (nm_str_hash, g_str_equal);
guint length = 0;
char **keys;
g_hash_table_insert (table, "one", "1");
g_hash_table_insert (table, "two", "2");
g_hash_table_insert (table, "three", "3");
keys = (char **) _nm_g_hash_table_get_keys_as_array (table, &length);
g_assert (keys);
g_assert_cmpuint (length, ==, 3);
g_assert ( !strcmp (keys[0], "one")
|| !strcmp (keys[1], "one")
|| !strcmp (keys[2], "one"));
g_assert ( !strcmp (keys[0], "two")
|| !strcmp (keys[1], "two")
|| !strcmp (keys[2], "two"));
g_assert ( !strcmp (keys[0], "three")
|| !strcmp (keys[1], "three")
|| !strcmp (keys[2], "three"));
g_assert (!keys[3]);
g_free (keys);
g_hash_table_unref (table);
}
/*****************************************************************************/
static int
_test_find_binary_search_cmp (gconstpointer a, gconstpointer b, gpointer dummy)
{
......@@ -7074,8 +7014,6 @@ int main (int argc, char **argv)
g_test_add_func ("/core/general/_nm_utils_ascii_str_to_int64", test_nm_utils_ascii_str_to_int64);
g_test_add_func ("/core/general/nm_utils_is_power_of_two", test_nm_utils_is_power_of_two);
g_test_add_func ("/core/general/_glib_compat_g_ptr_array_insert", test_g_ptr_array_insert);
g_test_add_func ("/core/general/_glib_compat_g_hash_table_get_keys_as_array", test_g_hash_table_get_keys_as_array);
g_test_add_func ("/core/general/_nm_utils_ptrarray_find_binary_search", test_nm_utils_ptrarray_find_binary_search);
g_test_add_func ("/core/general/_nm_utils_ptrarray_find_binary_search_with_duplicates", test_nm_utils_ptrarray_find_binary_search_with_duplicates);
g_test_add_func ("/core/general/_nm_utils_strstrdictkey", test_nm_utils_strstrdictkey);
......
......@@ -400,8 +400,6 @@ main (int argc, char *argv[])
{
NMClient *client;
nm_g_type_init ();
client = nm_client_new ();
if (!client) {
exit (1);
......
......@@ -495,8 +495,6 @@ libnm_glib_init (void)
{
libnm_glib_ctx *ctx = NULL;
nm_g_type_init ();
if (!g_thread_supported ())
g_thread_init (NULL);
dbus_g_thread_init ();
......
......@@ -956,8 +956,6 @@ main (int argc, char *argv[])
{
DBusGConnection *bus;
nm_g_type_init ();
bus = dbus_g_bus_get (DBUS_BUS_SESSION, NULL);
compare_ints ();
......
......@@ -105,7 +105,7 @@ gboolean _nm_setting_clear_secrets_with_flags (NMSetting *setting,
/* Ensure the setting's GType is registered at library load time */
#define NM_SETTING_REGISTER_TYPE(x) \
static void __attribute__((constructor)) register_setting (void) \
{ nm_g_type_init (); g_type_ensure (x); }
{ g_type_ensure (x); }
NMSetting *nm_setting_find_in_list (GSList *settings_list, const char *setting_name);
......
......@@ -102,7 +102,6 @@ static void
_ensure_registered (void)
{
if (G_UNLIKELY (registered_settings == NULL)) {
nm_g_type_init ();
_nm_value_transforms_register ();
registered_settings = g_hash_table_new (g_str_hash, g_str_equal);
registered_settings_by_type = g_hash_table_new (_nm_gtype_hash, _nm_gtype_equal);
......
......@@ -386,10 +386,10 @@ _add (NMDedupMultiIndex *self,
head_entry->len++;
if ( add_head_entry
&& !nm_g_hash_table_add (self->idx_entries, head_entry))
&& !g_hash_table_add (self->idx_entries, head_entry))
nm_assert_not_reached ();
if (!nm_g_hash_table_add (self->idx_entries, entry))
if (!g_hash_table_add (self->idx_entries, entry))
nm_assert_not_reached ();
NM_SET_OUT (out_entry, entry);
......@@ -870,7 +870,7 @@ nm_dedup_multi_index_obj_intern (NMDedupMultiIndex *self,
nm_assert (obj_new);
nm_assert (!obj_new->_multi_idx);
if (!nm_g_hash_table_add (self->idx_objs, (gpointer) obj_new))
if (!g_hash_table_add (self->idx_objs, (gpointer) obj_new))
nm_assert_not_reached ();
((NMDedupMultiObj *) obj_new)->_multi_idx = self;
......
......@@ -14,7 +14,7 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Copyright 2008 - 2011 Red Hat, Inc.
* Copyright 2008 - 2018 Red Hat, Inc.
*/
#ifndef __NM_GLIB_H__
......@@ -40,84 +40,6 @@
#endif
static inline void
__g_type_ensure (GType type)
{
#if !GLIB_CHECK_VERSION(2,34,0)
if (G_UNLIKELY (type == (GType)-1))
g_error ("can't happen");
#else
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
g_type_ensure (type);
G_GNUC_END_IGNORE_DEPRECATIONS;
#endif
}
#define g_type_ensure __g_type_ensure
#if !GLIB_CHECK_VERSION(2,34,0)
#define g_clear_pointer(pp, destroy) \
G_STMT_START { \
G_STATIC_ASSERT (sizeof *(pp) == sizeof (gpointer)); \
/* Only one access, please */ \
gpointer *_pp = (gpointer *) (pp); \
gpointer _p; \
/* This assignment is needed to avoid a gcc warning */ \
GDestroyNotify _destroy = (GDestroyNotify) (destroy); \
\
_p = *_pp; \
if (_p) \
{ \
*_pp = NULL; \
_destroy (_p); \
} \
} G_STMT_END
/* These are used to clean up the output of test programs; we can just let
* them no-op in older glib.
*/
#define g_test_expect_message(log_domain, log_level, pattern)
#define g_test_assert_expected_messages()
#else
/* We build with -DGLIB_MAX_ALLOWED_VERSION set to 2.32 to make sure we don't
* accidentally use new API that we shouldn't. But we don't want warnings for
* the APIs that we emulate above.
*/
#define g_test_expect_message(domain, level, format...) \
G_STMT_START { \
G_GNUC_BEGIN_IGNORE_DEPRECATIONS \
g_test_expect_message (domain, level, format); \
G_GNUC_END_IGNORE_DEPRECATIONS \
} G_STMT_END
#define g_test_assert_expected_messages_internal(domain, file, line, func) \
G_STMT_START { \
G_GNUC_BEGIN_IGNORE_DEPRECATIONS \
g_test_assert_expected_messages_internal (domain, file, line, func); \
G_GNUC_END_IGNORE_DEPRECATIONS \
} G_STMT_END
#endif
#if GLIB_CHECK_VERSION (2, 35, 0)
/* For glib >= 2.36, g_type_init() is deprecated.
* But since 2.35.1 (7c42ab23b55c43ab96d0ac2124b550bf1f49c1ec) this function
* does nothing. Replace the call with empty statement. */
#define nm_g_type_init() G_STMT_START { (void) 0; } G_STMT_END
#else
#define nm_g_type_init() G_STMT_START { g_type_init (); } G_STMT_END
#endif
/* g_test_initialized() is only available since glib 2.36. */
#if !GLIB_CHECK_VERSION (2, 36, 0)
#define g_test_initialized() (g_test_config_vars->test_initialized)
#endif
/* g_assert_cmpmem() is only available since glib 2.46. */
#if !GLIB_CHECK_VERSION (2, 45, 7)
#define g_assert_cmpmem(m1, l1, m2, l2) G_STMT_START {\
......@@ -146,239 +68,6 @@ nm_glib_check_version (guint major, guint minor, guint micro)
&& glib_micro_version < micro));
}
/* g_test_skip() is only available since glib 2.38. Add a compatibility wrapper. */
static inline void
__nmtst_g_test_skip (const gchar *msg)
{
#if GLIB_CHECK_VERSION (2, 38, 0)
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
g_test_skip (msg);
G_GNUC_END_IGNORE_DEPRECATIONS
#else
g_debug ("%s", msg);
#endif
}
#define g_test_skip __nmtst_g_test_skip
/* g_test_add_data_func_full() is only available since glib 2.34. Add a compatibility wrapper. */
static inline void
__g_test_add_data_func_full (const char *testpath,
gpointer test_data,
GTestDataFunc test_func,
GDestroyNotify data_free_func)
{
#if GLIB_CHECK_VERSION (2, 34, 0)
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
g_test_add_data_func_full (testpath, test_data, test_func, data_free_func);
G_GNUC_END_IGNORE_DEPRECATIONS
#else
g_return_if_fail (testpath != NULL);
g_return_if_fail (testpath[0] == '/');
g_return_if_fail (test_func != NULL);
g_test_add_vtable (testpath, 0, test_data, NULL,
(GTestFixtureFunc) test_func,
(GTestFixtureFunc) data_free_func);
#endif
}
#define g_test_add_data_func_full __g_test_add_data_func_full
#if !GLIB_CHECK_VERSION (2, 34, 0)
#define G_DEFINE_QUARK(QN, q_n) \
GQuark \
q_n##_quark (void) \
{ \
static GQuark q; \
\
if G_UNLIKELY (q == 0) \
q = g_quark_from_static_string (#QN); \
\
return q; \
}
#endif
static inline gboolean
nm_g_hash_table_replace (GHashTable *hash, gpointer key, gpointer value)
{
/* glib 2.40 added a return value indicating whether the key already existed
* (910191597a6c2e5d5d460e9ce9efb4f47d9cc63c). */
#if GLIB_CHECK_VERSION(2, 40, 0)
return g_hash_table_replace (hash, key, value);
#else
gboolean contained = g_hash_table_contains (hash, key);
g_hash_table_replace (hash, key, value);
return !contained;
#endif
}
static inline gboolean
nm_g_hash_table_insert (GHashTable *hash, gpointer key, gpointer value)
{
/* glib 2.40 added a return value indicating whether the key already existed
* (910191597a6c2e5d5d460e9ce9efb4f47d9cc63c). */
#if GLIB_CHECK_VERSION(2, 40, 0)
return g_hash_table_insert (hash, key, value);
#else
gboolean contained = g_hash_table_contains (hash, key);
g_hash_table_insert (hash, key, value);
return !contained;
#endif
}
static inline gboolean
nm_g_hash_table_add (GHashTable *hash, gpointer key)
{
/* glib 2.40 added a return value indicating whether the key already existed
* (910191597a6c2e5d5d460e9ce9efb4f47d9cc63c). */
#if GLIB_CHECK_VERSION(2, 40, 0)
return g_hash_table_add (hash, key);
#else
gboolean contained = g_hash_table_contains (hash, key);
g_hash_table_add (hash, key);
return !contained;
#endif
}
#if !GLIB_CHECK_VERSION(2, 40, 0) || defined (NM_GLIB_COMPAT_H_TEST)
static inline void
_nm_g_ptr_array_insert (GPtrArray *array,
gint index_,
gpointer data)
{
g_return_if_fail (array);
g_return_if_fail (index_ >= -1);
g_return_if_fail (index_ <= (gint) array->len);
g_ptr_array_add (array, data);
if (index_ != -1 && index_ != (gint) (array->len - 1)) {
memmove (&(array->pdata[index_ + 1]),
&(array->pdata[index_]),
(array->len - index_ - 1) * sizeof (gpointer));
array->pdata[index_] = data;
}
}
#endif
#if !GLIB_CHECK_VERSION(2, 40, 0)
#define g_ptr_array_insert(array, index, data) G_STMT_START { _nm_g_ptr_array_insert (array, index, data); } G_STMT_END
#else
#define g_ptr_array_insert(array, index, data) \
G_STMT_START { \
G_GNUC_BEGIN_IGNORE_DEPRECATIONS \
g_ptr_array_insert (array, index, data); \
G_GNUC_END_IGNORE_DEPRECATIONS \
} G_STMT_END
#endif
#if !GLIB_CHECK_VERSION (2, 40, 0)
static inline gboolean
_g_key_file_save_to_file (GKeyFile *key_file,
const gchar *filename,
GError **error)
{
gchar *contents;
gboolean success;
gsize length;
g_return_val_if_fail (key_file != NULL, FALSE);
g_return_val_if_fail (filename != NULL, FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
contents = g_key_file_to_data (key_file, &length, NULL);
g_assert (contents != NULL);
success = g_file_set_contents (filename, contents, length, error);
g_free (contents);
return success;
}
#define g_key_file_save_to_file(key_file, filename, error) \
_g_key_file_save_to_file (key_file, filename, error)
#else
#define g_key_file_save_to_file(key_file, filename, error) \
({ \
gboolean _success; \
\
G_GNUC_BEGIN_IGNORE_DEPRECATIONS \
_success = g_key_file_save_to_file (key_file, filename, error); \
G_GNUC_END_IGNORE_DEPRECATIONS \
_success; \
})
#endif
#if GLIB_CHECK_VERSION (2, 36, 0)
#define g_credentials_get_unix_pid(creds, error) \
({ \
G_GNUC_BEGIN_IGNORE_DEPRECATIONS \
(g_credentials_get_unix_pid) ((creds), (error)); \
G_GNUC_END_IGNORE_DEPRECATIONS \
})
#else
#define g_credentials_get_unix_pid(creds, error) \
({ \
struct ucred *native_creds; \
\
native_creds = g_credentials_get_native ((creds), G_CREDENTIALS_TYPE_LINUX_UCRED); \
g_assert (native_creds); \
native_creds->pid; \
})
#endif
#if !GLIB_CHECK_VERSION(2, 40, 0) || defined (NM_GLIB_COMPAT_H_TEST)
static inline gpointer *
_nm_g_hash_table_get_keys_as_array (GHashTable *hash_table,
guint *length)
{
GHashTableIter iter;
gpointer key, *ret;
guint i = 0;
g_return_val_if_fail (hash_table, NULL);
ret = g_new0 (gpointer, g_hash_table_size (hash_table) + 1);
g_hash_table_iter_init (&iter, hash_table);
while (g_hash_table_iter_next (&iter, &key, NULL))
ret[i++] = key;
ret[i] = NULL;
if (length)
*length = i;
return ret;
}
#endif
#if !GLIB_CHECK_VERSION(2, 40, 0)