mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-02 13:08:05 +02:00
build: merge branch 'th/gcc-suppress-dangling-pointer-warning'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1107
This commit is contained in:
commit
e730769208
13 changed files with 76 additions and 18 deletions
|
|
@ -241,6 +241,7 @@ _nmtstp_platform_ip_addresses_assert(const char *filename,
|
|||
if ((IS_IPv4 ? force_exact_4 : force_exact_6) && nm_g_ptr_array_len(plat_addrs) > 0) {
|
||||
char sbuf[sizeof(_nm_utils_to_string_buffer)];
|
||||
|
||||
NM_PRAGMA_WARNING_DISABLE_DANGLING_POINTER
|
||||
g_error("%s:%d: %u IPv%c addresses found on ifindex %d that should not be there (one "
|
||||
"is %s)",
|
||||
filename,
|
||||
|
|
@ -252,6 +253,7 @@ _nmtstp_platform_ip_addresses_assert(const char *filename,
|
|||
NMP_OBJECT_TO_STRING_PUBLIC,
|
||||
sbuf,
|
||||
sizeof(sbuf)));
|
||||
NM_PRAGMA_WARNING_REENABLE
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -580,6 +582,7 @@ _nmtstp_assert_ip4_route_exists(const char *file,
|
|||
if (c != c_exists && c_exists != -1) {
|
||||
char sbuf[NM_UTILS_INET_ADDRSTRLEN];
|
||||
|
||||
NM_PRAGMA_WARNING_DISABLE_DANGLING_POINTER
|
||||
g_error("[%s:%u] %s(): The ip4 route %s/%d metric %u tos %u shall exist %u times, but "
|
||||
"platform has it %u times",
|
||||
file,
|
||||
|
|
@ -591,6 +594,7 @@ _nmtstp_assert_ip4_route_exists(const char *file,
|
|||
tos,
|
||||
c_exists,
|
||||
c);
|
||||
NM_PRAGMA_WARNING_REENABLE
|
||||
}
|
||||
|
||||
return r;
|
||||
|
|
@ -673,6 +677,7 @@ _nmtstp_assert_ip6_route_exists(const char *file,
|
|||
char s_src[NM_UTILS_INET_ADDRSTRLEN];
|
||||
char s_network[NM_UTILS_INET_ADDRSTRLEN];
|
||||
|
||||
NM_PRAGMA_WARNING_DISABLE_DANGLING_POINTER
|
||||
g_error("[%s:%u] %s(): The ip6 route %s/%d metric %u src %s/%d shall exist %u times, but "
|
||||
"platform has it %u times",
|
||||
file,
|
||||
|
|
@ -685,6 +690,7 @@ _nmtstp_assert_ip6_route_exists(const char *file,
|
|||
src_plen,
|
||||
c_exists,
|
||||
c);
|
||||
NM_PRAGMA_WARNING_REENABLE
|
||||
}
|
||||
|
||||
return r;
|
||||
|
|
|
|||
|
|
@ -731,15 +731,17 @@ test_platform_ip_address_pretty_sort_cmp(gconstpointer test_data)
|
|||
&bin_len);
|
||||
|
||||
if (bin_len != ELM_SIZE * N_ADDRESSES || memcmp(addresses, bin_arr, bin_len) != 0) {
|
||||
char *addresses_str = nm_utils_bin2hexstr(addresses, ELM_SIZE * N_ADDRESSES, -1);
|
||||
gs_free char *addresses_str = NULL;
|
||||
|
||||
NM_PRAGMA_WARNING_DISABLE_DANGLING_POINTER
|
||||
g_error(">>> test_platform_ip_address_pretty_sort_cmp() will fail:\n"
|
||||
">>> addresses[%zu]: %s\n"
|
||||
">>> expected [%zu]: %s\n",
|
||||
ELM_SIZE * N_ADDRESSES,
|
||||
addresses_str,
|
||||
(addresses_str = nm_utils_bin2hexstr(addresses, ELM_SIZE * N_ADDRESSES, -1)),
|
||||
bin_len,
|
||||
EXPECTED_BUFFER[TEST_DATA_I]);
|
||||
NM_PRAGMA_WARNING_REENABLE
|
||||
}
|
||||
|
||||
g_assert_cmpmem(addresses, ELM_SIZE * N_ADDRESSES, bin_arr, bin_len);
|
||||
|
|
|
|||
|
|
@ -221,6 +221,7 @@ _assert_expected_content(NMConnection *connection, const char *filename, const c
|
|||
success = g_file_set_contents(expected, content_written, len_written, &error);
|
||||
nmtst_assert_success(success, error);
|
||||
} else {
|
||||
NM_PRAGMA_WARNING_DISABLE_DANGLING_POINTER
|
||||
g_error(
|
||||
"The content of \"%s\" (%zu) differs from \"%s\" (%zu). Set "
|
||||
"NMTST_IFCFG_RH_UPDATE_EXPECTED=yes (or NM_TEST_REGENERATE=1) to update the files "
|
||||
|
|
@ -231,6 +232,7 @@ _assert_expected_content(NMConnection *connection, const char *filename, const c
|
|||
len_expectd,
|
||||
content_written,
|
||||
content_expectd);
|
||||
NM_PRAGMA_WARNING_REENABLE
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2635,8 +2635,11 @@ _escape_filename(gboolean with_extension, const char *filename, gboolean would_b
|
|||
g_assert(esc && esc[0]);
|
||||
g_assert(!strchr(esc, '/'));
|
||||
|
||||
if (nm_keyfile_utils_ignore_filename(esc, with_extension))
|
||||
if (nm_keyfile_utils_ignore_filename(esc, with_extension)) {
|
||||
NM_PRAGMA_WARNING_DISABLE_DANGLING_POINTER
|
||||
g_error("Escaping filename \"%s\" yielded \"%s\", but this is ignored", filename, esc);
|
||||
NM_PRAGMA_WARNING_REENABLE
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
|
|
@ -2327,13 +2327,14 @@ _do_read_vpn_details_impl1(const char *file,
|
|||
if (nm_streq(_expected[_i].key, _k)) \
|
||||
break; \
|
||||
} \
|
||||
if (_i >= _expected_len) \
|
||||
if (_i >= _expected_len) { \
|
||||
g_error("%s:%d: hash '%s' contains unexpected data key '%s' with value '%s'", \
|
||||
file, \
|
||||
line, \
|
||||
G_STRINGIFY(hash), \
|
||||
_k, \
|
||||
_v); \
|
||||
} \
|
||||
} \
|
||||
\
|
||||
for (_i = 0; _i < _expected_len; _i++) { \
|
||||
|
|
@ -2342,7 +2343,7 @@ _do_read_vpn_details_impl1(const char *file,
|
|||
g_assert(_d->key); \
|
||||
g_assert(_d->val); \
|
||||
_v = g_hash_table_lookup(_hash, _d->key); \
|
||||
if (!nm_streq0(_v, _d->val)) \
|
||||
if (!nm_streq0(_v, _d->val)) { \
|
||||
g_error("%s:%d: hash '%s' contains data key '%s' with value %s%s%s but we " \
|
||||
"expected '%s'", \
|
||||
file, \
|
||||
|
|
@ -2351,14 +2352,17 @@ _do_read_vpn_details_impl1(const char *file,
|
|||
_d->key, \
|
||||
NM_PRINT_FMT_QUOTE_STRING(_v), \
|
||||
_d->val); \
|
||||
} \
|
||||
} \
|
||||
\
|
||||
g_assert_cmpint(g_hash_table_size(_hash), ==, _expected_len); \
|
||||
} \
|
||||
G_STMT_END
|
||||
|
||||
NM_PRAGMA_WARNING_DISABLE_DANGLING_POINTER
|
||||
_assert_hash(data, expected_data, expected_data_len);
|
||||
_assert_hash(secrets, expected_secrets, expected_secrets_len);
|
||||
NM_PRAGMA_WARNING_REENABLE
|
||||
|
||||
#undef _assert_hash
|
||||
return TRUE;
|
||||
|
|
@ -3049,10 +3053,12 @@ check_dbus_properties:
|
|||
break;
|
||||
p_expected_type++;
|
||||
if (p_expected_type >= &expected_types[G_N_ELEMENTS(expected_types)]) {
|
||||
NM_PRAGMA_WARNING_DISABLE_DANGLING_POINTER
|
||||
g_error("D-Bus type \"%s\" is not implemented (in property %s.%s)",
|
||||
(const char *) mpr->dbus_type,
|
||||
mif->dbus_iface_name,
|
||||
mpr->dbus_property_name);
|
||||
NM_PRAGMA_WARNING_REENABLE
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -3151,6 +3157,7 @@ check_dbus_properties:
|
|||
break;
|
||||
}
|
||||
if (p_expected_type_2 >= &expected_types[G_N_ELEMENTS(expected_types)]) {
|
||||
NM_PRAGMA_WARNING_DISABLE_DANGLING_POINTER
|
||||
g_error("D-Bus property \"%s.%s\" (type \"%s\") maps to property \"%s\", "
|
||||
"but that has an unexpected property type %s (expected %s)",
|
||||
mif->dbus_iface_name,
|
||||
|
|
@ -3159,6 +3166,7 @@ check_dbus_properties:
|
|||
pspec->name,
|
||||
g_type_name(pspec->value_type),
|
||||
g_type_name(p_expected_type->default_gtype));
|
||||
NM_PRAGMA_WARNING_REENABLE
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -159,7 +159,9 @@ nmtstc_service_init(void)
|
|||
* via pygobject. */
|
||||
return NULL;
|
||||
}
|
||||
NM_PRAGMA_WARNING_DISABLE_DANGLING_POINTER
|
||||
g_error("test service %s exited with error code %d", NMTSTC_NM_SERVICE, data.exit_code);
|
||||
NM_PRAGMA_WARNING_REENABLE
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4774,10 +4774,12 @@ check_done:;
|
|||
g_assert(NM_IS_SETTING_VPN(setting));
|
||||
g_assert_cmpstr(sip->name, ==, NM_SETTING_VPN_SECRETS);
|
||||
} else {
|
||||
NM_PRAGMA_WARNING_DISABLE_DANGLING_POINTER
|
||||
g_error("secret %s.%s is of unexpected property type %s",
|
||||
nm_setting_get_name(setting),
|
||||
sip->name,
|
||||
g_type_name(sip->param_spec->value_type));
|
||||
NM_PRAGMA_WARNING_REENABLE
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -4900,12 +4902,14 @@ check_done:;
|
|||
|
||||
/* the property-types with same content should all be shared. Here we have two that
|
||||
* are the same content, but different instances. Bug. */
|
||||
NM_PRAGMA_WARNING_DISABLE_DANGLING_POINTER
|
||||
g_error("The identical property type for D-Bus type \"%s\" is used by: %s and %s. "
|
||||
"If a NMSettInfoPropertType is identical, it should be shared by creating "
|
||||
"a common instance of the property type",
|
||||
(const char *) pt->dbus_type,
|
||||
_PROP_IDX_OWNER(h_property_types, pt),
|
||||
_PROP_IDX_OWNER(h_property_types, pt_2));
|
||||
NM_PRAGMA_WARNING_REENABLE
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -184,26 +184,36 @@ _nm_auto_freev(gpointer ptr)
|
|||
* same name for the same warning. */
|
||||
|
||||
#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))
|
||||
#define NM_PRAGMA_DIAGNOSTICS_PUSH _Pragma("GCC diagnostic push")
|
||||
#define NM_PRAGMA_WARNING_DISABLE(warning) \
|
||||
_Pragma("GCC diagnostic push") _Pragma(_NM_PRAGMA_WARNING_DO(warning))
|
||||
#elif defined(__clang__)
|
||||
#define NM_PRAGMA_WARNING_DISABLE(warning) \
|
||||
_Pragma("clang diagnostic push") _Pragma(_NM_PRAGMA_WARNING_DO("-Wunknown-warning-option")) \
|
||||
_Pragma(_NM_PRAGMA_WARNING_DO(warning))
|
||||
#else
|
||||
#define NM_PRAGMA_WARNING_DISABLE(warning)
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))
|
||||
NM_PRAGMA_DIAGNOSTICS_PUSH _Pragma(_NM_PRAGMA_WARNING_DO(warning))
|
||||
#define NM_PRAGMA_WARNING_REENABLE _Pragma("GCC diagnostic pop")
|
||||
#elif defined(__clang__)
|
||||
#define NM_PRAGMA_DIAGNOSTICS_PUSH _Pragma("clang diagnostic push")
|
||||
#define NM_PRAGMA_WARNING_DISABLE(warning) \
|
||||
NM_PRAGMA_DIAGNOSTICS_PUSH _Pragma(_NM_PRAGMA_WARNING_DO("-Wunknown-warning-option")) \
|
||||
_Pragma(_NM_PRAGMA_WARNING_DO(warning))
|
||||
#define NM_PRAGMA_WARNING_REENABLE _Pragma("clang diagnostic pop")
|
||||
#else
|
||||
#define NM_PRAGMA_DIAGNOSTICS_PUSH
|
||||
#define NM_PRAGMA_WARNING_DISABLE(warning)
|
||||
#define NM_PRAGMA_WARNING_REENABLE
|
||||
#endif
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/* Seems gcc-12 has a tendency for false-positive -Wdangling-pointer warnings with
|
||||
* g_error()'s `for(;;);`.
|
||||
*
|
||||
* Work around that, but it's only for gcc 12 (for now). */
|
||||
#if defined(__GNUC__) && __GNUC__ == 12
|
||||
#define NM_PRAGMA_WARNING_DISABLE_DANGLING_POINTER NM_PRAGMA_WARNING_DISABLE("-Wdangling-pointer")
|
||||
#else
|
||||
#define NM_PRAGMA_WARNING_DISABLE_DANGLING_POINTER NM_PRAGMA_DIAGNOSTICS_PUSH
|
||||
#endif
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/**
|
||||
* NM_G_ERROR_MSG:
|
||||
* @error: (allow-none): the #GError instance
|
||||
|
|
|
|||
|
|
@ -1130,6 +1130,7 @@ nm_utils_parse_inaddr_bin_full(int addr_family,
|
|||
|
||||
#if NM_MORE_ASSERTS > 10
|
||||
if (addr_family == AF_INET) {
|
||||
NM_PRAGMA_WARNING_DISABLE_DANGLING_POINTER
|
||||
gs_free_error GError *error = NULL;
|
||||
in_addr_t a;
|
||||
|
||||
|
|
@ -1145,6 +1146,7 @@ nm_utils_parse_inaddr_bin_full(int addr_family,
|
|||
error->message);
|
||||
}
|
||||
nm_assert(addrbin.addr4 == a);
|
||||
NM_PRAGMA_WARNING_REENABLE
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -1714,8 +1714,11 @@ __nmtst_spawn_sync(const char *working_directory,
|
|||
standard_err,
|
||||
&exit_status,
|
||||
&error);
|
||||
if (!success)
|
||||
if (!success) {
|
||||
NM_PRAGMA_WARNING_DISABLE_DANGLING_POINTER
|
||||
g_error("nmtst_spawn_sync(%s): %s", ((char **) argv->pdata)[0], error->message);
|
||||
NM_PRAGMA_WARNING_REENABLE
|
||||
}
|
||||
g_assert(!error);
|
||||
|
||||
g_assert(!standard_out || *standard_out);
|
||||
|
|
@ -1844,7 +1847,8 @@ _nmtst_assert_resolve_relative_path_equals(const char *f1,
|
|||
|
||||
/* Fixme: later we might need to coalesce repeated '/', "./", and "../".
|
||||
* For now, it's good enough. */
|
||||
if (g_strcmp0(p1, p2) != 0)
|
||||
if (g_strcmp0(p1, p2) != 0) {
|
||||
NM_PRAGMA_WARNING_DISABLE_DANGLING_POINTER
|
||||
g_error("%s:%d : filenames don't match \"%s\" vs. \"%s\" // \"%s\" - \"%s\"",
|
||||
file,
|
||||
line,
|
||||
|
|
@ -1852,6 +1856,8 @@ _nmtst_assert_resolve_relative_path_equals(const char *f1,
|
|||
f2,
|
||||
p1,
|
||||
p2);
|
||||
NM_PRAGMA_WARNING_REENABLE
|
||||
}
|
||||
}
|
||||
#define nmtst_assert_resolve_relative_path_equals(f1, f2) \
|
||||
_nmtst_assert_resolve_relative_path_equals(f1, f2, __FILE__, __LINE__);
|
||||
|
|
@ -2404,9 +2410,11 @@ _nmtst_assert_connection_has_settings(NMConnection *connection,
|
|||
settings = nm_connection_get_settings(connection, &len);
|
||||
for (i = 0; i < len; i++) {
|
||||
if (!g_hash_table_remove(names, nm_setting_get_name(settings[i])) && has_at_most) {
|
||||
NM_PRAGMA_WARNING_DISABLE_DANGLING_POINTER
|
||||
g_error(
|
||||
"nmtst_assert_connection_has_settings(): has setting \"%s\" which is not expected",
|
||||
nm_setting_get_name(settings[i]));
|
||||
NM_PRAGMA_WARNING_REENABLE
|
||||
}
|
||||
}
|
||||
if (g_hash_table_size(names) > 0 && has_at_least) {
|
||||
|
|
@ -2419,11 +2427,13 @@ _nmtst_assert_connection_has_settings(NMConnection *connection,
|
|||
settings_names[i] = nm_setting_get_name(settings[i]);
|
||||
has_str = g_strjoinv(" ", (char **) settings_names);
|
||||
|
||||
NM_PRAGMA_WARNING_DISABLE_DANGLING_POINTER
|
||||
g_error("nmtst_assert_connection_has_settings(): the setting lacks %u expected settings "
|
||||
"(expected: [%s] vs. has: [%s])",
|
||||
g_hash_table_size(names),
|
||||
expected_str,
|
||||
has_str);
|
||||
NM_PRAGMA_WARNING_REENABLE
|
||||
}
|
||||
}
|
||||
#define nmtst_assert_connection_has_settings(connection, ...) \
|
||||
|
|
|
|||
|
|
@ -8966,6 +8966,8 @@ finalize(GObject *object)
|
|||
g_clear_object(&self->_netns);
|
||||
nm_dedup_multi_index_unref(priv->multi_idx);
|
||||
nmp_cache_free(priv->cache);
|
||||
|
||||
G_OBJECT_CLASS(nm_platform_parent_class)->finalize(object);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
|
|
@ -131,11 +131,13 @@ test_nmp_link_mode_all_advertised_modes_bits(void)
|
|||
|
||||
for (i = 0; i < (int) G_N_ELEMENTS(_nmp_link_mode_all_advertised_modes); i++) {
|
||||
if (flags[i] != _nmp_link_mode_all_advertised_modes[i]) {
|
||||
NM_PRAGMA_WARNING_DISABLE_DANGLING_POINTER
|
||||
g_error("_nmp_link_mode_all_advertised_modes[%d] should be 0x%0x but is 0x%0x "
|
||||
"(according to the bits in _nmp_link_mode_all_advertised_modes_bits)",
|
||||
i,
|
||||
flags[i],
|
||||
_nmp_link_mode_all_advertised_modes[i]);
|
||||
NM_PRAGMA_WARNING_REENABLE
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -530,8 +530,11 @@ test_generic(const char *file, const char *override_vpn_ip_iface)
|
|||
|
||||
g_assert((!denv && error_message) || (denv && !error_message));
|
||||
|
||||
if (error_message)
|
||||
if (error_message) {
|
||||
NM_PRAGMA_WARNING_DISABLE_DANGLING_POINTER
|
||||
g_error("FAILED: %s", error_message);
|
||||
NM_PRAGMA_WARNING_REENABLE
|
||||
}
|
||||
|
||||
if (g_strv_length(denv) != g_hash_table_size(expected_env)) {
|
||||
_print_env(NM_CAST_STRV_CC(denv), expected_env);
|
||||
|
|
@ -552,8 +555,10 @@ test_generic(const char *file, const char *override_vpn_ip_iface)
|
|||
|
||||
foo = g_hash_table_lookup(expected_env, i_value);
|
||||
if (!foo) {
|
||||
NM_PRAGMA_WARNING_DISABLE_DANGLING_POINTER
|
||||
_print_env(NM_CAST_STRV_CC(denv), expected_env);
|
||||
g_error("Failed to find %s in environment", i_value);
|
||||
NM_PRAGMA_WARNING_REENABLE
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue