Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
NetworkManager
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
147
Issues
147
List
Boards
Labels
Service Desk
Milestones
Merge Requests
12
Merge Requests
12
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
NetworkManager
NetworkManager
Commits
8a46b25c
Commit
8a46b25c
authored
Jan 02, 2018
by
Lubomir Rintel
🥕
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
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
Changes
40
Hide whitespace changes
Inline
Side-by-side
Showing
40 changed files
with
26 additions
and
563 deletions
+26
-563
clients/cli/nmcli.c
clients/cli/nmcli.c
+0
-2
clients/common/tests/test-general.c
clients/common/tests/test-general.c
+2
-2
clients/nm-online.c
clients/nm-online.c
+0
-2
clients/tui/newt/nmt-newt-utils.c
clients/tui/newt/nmt-newt-utils.c
+0
-10
configure.ac
configure.ac
+2
-2
dispatcher/nm-dispatcher.c
dispatcher/nm-dispatcher.c
+0
-2
docs/libnm-glib/Makefile.am
docs/libnm-glib/Makefile.am
+0
-3
docs/libnm-util/Makefile.am
docs/libnm-util/Makefile.am
+0
-3
docs/libnm/Makefile.am
docs/libnm/Makefile.am
+0
-3
examples/C/glib/add-connection-gdbus.c
examples/C/glib/add-connection-gdbus.c
+0
-5
examples/C/glib/add-connection-libnm.c
examples/C/glib/add-connection-libnm.c
+0
-5
examples/C/glib/get-active-connections-gdbus.c
examples/C/glib/get-active-connections-gdbus.c
+0
-5
examples/C/glib/get-ap-info-libnm.c
examples/C/glib/get-ap-info-libnm.c
+0
-5
examples/C/glib/list-connections-gdbus.c
examples/C/glib/list-connections-gdbus.c
+0
-5
examples/C/glib/list-connections-libnm.c
examples/C/glib/list-connections-libnm.c
+0
-5
examples/C/glib/monitor-nm-running-gdbus.c
examples/C/glib/monitor-nm-running-gdbus.c
+0
-5
examples/C/glib/monitor-nm-state-gdbus.c
examples/C/glib/monitor-nm-state-gdbus.c
+0
-5
libnm-core/nm-setting-private.h
libnm-core/nm-setting-private.h
+1
-1
libnm-core/nm-setting.c
libnm-core/nm-setting.c
+1
-2
libnm-core/nm-utils.c
libnm-core/nm-utils.c
+0
-2
libnm-core/tests/test-general.c
libnm-core/tests/test-general.c
+0
-62
libnm-glib/libnm-glib-test.c
libnm-glib/libnm-glib-test.c
+0
-2
libnm-glib/libnm_glib.c
libnm-glib/libnm_glib.c
+0
-2
libnm-util/nm-param-spec-specialized.c
libnm-util/nm-param-spec-specialized.c
+0
-2
libnm-util/nm-setting-private.h
libnm-util/nm-setting-private.h
+1
-1
libnm-util/nm-setting.c
libnm-util/nm-setting.c
+0
-1
shared/nm-utils/nm-dedup-multi.c
shared/nm-utils/nm-dedup-multi.c
+3
-3
shared/nm-utils/nm-glib.h
shared/nm-utils/nm-glib.h
+1
-373
shared/nm-utils/nm-test-utils.h
shared/nm-utils/nm-test-utils.h
+1
-15
src/devices/nm-device.c
src/devices/nm-device.c
+2
-2
src/dhcp/nm-dhcp-helper.c
src/dhcp/nm-dhcp-helper.c
+0
-2
src/main.c
src/main.c
+0
-2
src/nm-bus-manager.c
src/nm-bus-manager.c
+0
-4
src/nm-checkpoint-manager.c
src/nm-checkpoint-manager.c
+1
-3
src/nm-config.c
src/nm-config.c
+1
-1
src/nm-iface-helper.c
src/nm-iface-helper.c
+0
-2
src/nm-manager.c
src/nm-manager.c
+5
-5
src/nm-policy.c
src/nm-policy.c
+2
-2
src/platform/nm-platform.c
src/platform/nm-platform.c
+3
-3
src/ppp/nm-pppd-plugin.c
src/ppp/nm-pppd-plugin.c
+0
-2
No files found.
clients/cli/nmcli.c
View file @
8a46b25c
...
...
@@ -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
);
...
...
clients/common/tests/test-general.c
View file @
8a46b25c
...
...
@@ -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
]);
...
...
clients/nm-online.c
View file @
8a46b25c
...
...
@@ -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
);
...
...
clients/tui/newt/nmt-newt-utils.c
View file @
8a46b25c
...
...
@@ -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
);
...
...
configure.ac
View file @
8a46b25c
...
...
@@ -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)
...
...
dispatcher/nm-dispatcher.c
View file @
8a46b25c
...
...
@@ -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
));
...
...
docs/libnm-glib/Makefile.am
View file @
8a46b25c
...
...
@@ -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
...
...
docs/libnm-util/Makefile.am
View file @
8a46b25c
...
...
@@ -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
...
...
docs/libnm/Makefile.am
View file @
8a46b25c
...
...
@@ -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
...
...
examples/C/glib/add-connection-gdbus.c
View file @
8a46b25c
...
...
@@ -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
,
...
...
examples/C/glib/add-connection-libnm.c
View file @
8a46b25c
...
...
@@ -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 */
...
...
examples/C/glib/get-active-connections-gdbus.c
View file @
8a46b25c
...
...
@@ -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.
*/
...
...
examples/C/glib/get-ap-info-libnm.c
View file @
8a46b25c
...
...
@@ -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
)
{
...
...
examples/C/glib/list-connections-gdbus.c
View file @
8a46b25c
...
...
@@ -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
,
...
...
examples/C/glib/list-connections-libnm.c
View file @
8a46b25c
...
...
@@ -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
);
...
...
examples/C/glib/monitor-nm-running-gdbus.c
View file @
8a46b25c
...
...
@@ -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
"
);
...
...
examples/C/glib/monitor-nm-state-gdbus.c
View file @
8a46b25c
...
...
@@ -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
"
);
...
...
libnm-core/nm-setting-private.h
View file @
8a46b25c
...
...
@@ -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
,
...
...
libnm-core/nm-setting.c
View file @
8a46b25c
...
...
@@ -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
);
...
...
libnm-core/nm-utils.c
View file @
8a46b25c
...
...
@@ -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
();
}
...
...
libnm-core/tests/test-general.c
View file @
8a46b25c
...
...
@@ -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
);
...
...
libnm-glib/libnm-glib-test.c
View file @
8a46b25c
...
...
@@ -400,8 +400,6 @@ main (int argc, char *argv[])
{
NMClient
*
client
;
nm_g_type_init
();
client
=
nm_client_new
();
if
(
!
client
)
{
exit
(
1
);
...
...
libnm-glib/libnm_glib.c
View file @
8a46b25c
...
...
@@ -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
();
...
...
libnm-util/nm-param-spec-specialized.c
View file @
8a46b25c
...
...
@@ -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 ();
...
...
libnm-util/nm-setting-private.h
View file @
8a46b25c
...
...
@@ -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
);
...
...
libnm-util/nm-setting.c
View file @
8a46b25c
...
...
@@ -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
);
...
...
shared/nm-utils/nm-dedup-multi.c
View file @
8a46b25c
...
...
@@ -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
;
...
...
shared/nm-utils/nm-glib.h
View file @
8a46b25c
...
...
@@ -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 - 201
1
Red Hat, Inc.
* Copyright 2008 - 201
8
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 \