mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-29 23:10:18 +01:00
all: fix "-Wcast-align=strict" warnings for GArray casts
GArray.data is a char pointer. Most of the time we track other data in a GArray. Casting that pointer can trigger "-Wcast-align=strict" warnings. Avoid them. Most of the time, instead use the nm_g_array*() helpers, which also assert that the expected element size is correct.
This commit is contained in:
parent
67ee711743
commit
1bf73642dc
13 changed files with 45 additions and 45 deletions
|
|
@ -8135,7 +8135,7 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
|
|||
break;
|
||||
case PROP_CAPABILITIES:
|
||||
g_value_set_variant(value,
|
||||
nm_g_variant_new_au((const guint32 *) priv->capabilities->data,
|
||||
nm_g_variant_new_au(nm_g_array_first_p(priv->capabilities, guint32),
|
||||
priv->capabilities->len));
|
||||
break;
|
||||
case PROP_STATE:
|
||||
|
|
|
|||
|
|
@ -1250,7 +1250,7 @@ _test_wireguard_change(NMPlatform *platform, int ifindex, int test_mode)
|
|||
r = nm_platform_link_wireguard_change(platform,
|
||||
ifindex,
|
||||
&lnk_wireguard,
|
||||
(const NMPWireGuardPeer *) peers->data,
|
||||
nm_g_array_first_p(peers, const NMPWireGuardPeer),
|
||||
NULL,
|
||||
peers->len,
|
||||
NM_PLATFORM_WIREGUARD_CHANGE_FLAG_HAS_PRIVATE_KEY
|
||||
|
|
|
|||
|
|
@ -2210,7 +2210,7 @@ write_array_of_uint(GKeyFile *file, NMSetting *setting, const char *key, const G
|
|||
nm_keyfile_plugin_kf_set_integer_list_uint(file,
|
||||
nm_setting_get_name(setting),
|
||||
key,
|
||||
(const guint *) array->data,
|
||||
&nm_g_array_first(array, const guint),
|
||||
array->len);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -292,7 +292,7 @@ nm_setting_wired_get_mac_address_blacklist(NMSettingWired *setting)
|
|||
g_return_val_if_fail(NM_IS_SETTING_WIRED(setting), NULL);
|
||||
|
||||
priv = NM_SETTING_WIRED_GET_PRIVATE(setting);
|
||||
return (const char *const *) priv->mac_address_blacklist->data;
|
||||
return nm_g_array_data(priv->mac_address_blacklist);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1007,7 +1007,7 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
|
|||
g_value_set_string(value, nm_setting_wired_get_cloned_mac_address(setting));
|
||||
break;
|
||||
case PROP_MAC_ADDRESS_BLACKLIST:
|
||||
g_value_set_boxed(value, (char **) priv->mac_address_blacklist->data);
|
||||
g_value_set_boxed(value, nm_g_array_data(priv->mac_address_blacklist));
|
||||
break;
|
||||
case PROP_S390_SUBCHANNELS:
|
||||
g_value_set_boxed(value, priv->s390_subchannels);
|
||||
|
|
|
|||
|
|
@ -473,7 +473,7 @@ nm_setting_wireless_get_mac_address_blacklist(NMSettingWireless *setting)
|
|||
g_return_val_if_fail(NM_IS_SETTING_WIRELESS(setting), NULL);
|
||||
|
||||
priv = NM_SETTING_WIRELESS_GET_PRIVATE(setting);
|
||||
return (const char *const *) priv->mac_address_blacklist->data;
|
||||
return nm_g_array_data(priv->mac_address_blacklist);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1174,7 +1174,7 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
|
|||
g_value_set_string(value, nm_setting_wireless_get_cloned_mac_address(setting));
|
||||
break;
|
||||
case PROP_MAC_ADDRESS_BLACKLIST:
|
||||
g_value_set_boxed(value, (char **) priv->mac_address_blacklist->data);
|
||||
g_value_set_boxed(value, nm_g_array_data(priv->mac_address_blacklist));
|
||||
break;
|
||||
case PROP_SEEN_BSSIDS:
|
||||
g_value_take_boxed(
|
||||
|
|
|
|||
|
|
@ -350,10 +350,10 @@ _nm_setting_class_commit(NMSettingClass *setting_class,
|
|||
gboolean found = FALSE;
|
||||
guint k;
|
||||
|
||||
nm_assert(
|
||||
!_nm_sett_info_property_find_in_array((NMSettInfoProperty *) properties_override->data,
|
||||
i,
|
||||
p->name));
|
||||
nm_assert(!_nm_sett_info_property_find_in_array(
|
||||
nm_g_array_index_p(properties_override, NMSettInfoProperty, 0),
|
||||
i,
|
||||
p->name));
|
||||
for (k = 0; k < n_property_specs; k++) {
|
||||
if (!nm_streq(property_specs[k]->name, p->name))
|
||||
continue;
|
||||
|
|
@ -369,9 +369,10 @@ _nm_setting_class_commit(NMSettingClass *setting_class,
|
|||
const char *name = property_specs[i]->name;
|
||||
NMSettInfoProperty *p;
|
||||
|
||||
if (_nm_sett_info_property_find_in_array((NMSettInfoProperty *) properties_override->data,
|
||||
override_len,
|
||||
name))
|
||||
if (_nm_sett_info_property_find_in_array(
|
||||
nm_g_array_index_p(properties_override, NMSettInfoProperty, 0),
|
||||
override_len,
|
||||
name))
|
||||
continue;
|
||||
|
||||
p = nm_g_array_append_new(properties_override, NMSettInfoProperty);
|
||||
|
|
@ -1301,7 +1302,7 @@ _nm_setting_property_to_dbus_fcn_direct(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_
|
|||
(const NMValueStrv *) _nm_setting_get_private_field(setting, sett_info, property_info);
|
||||
if (!val->arr)
|
||||
return NULL;
|
||||
return g_variant_new_strv((const char *const *) val->arr->data, val->arr->len);
|
||||
return g_variant_new_strv(nm_g_array_data(val->arr), val->arr->len);
|
||||
}
|
||||
default:
|
||||
return nm_assert_unreachable_val(NULL);
|
||||
|
|
@ -1355,7 +1356,7 @@ _nm_setting_property_to_dbus_fcn_gprop(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_n
|
|||
nm_assert(G_VALUE_HOLDS(&prop_value, G_TYPE_ARRAY));
|
||||
tmp_array = g_value_get_boxed(&prop_value);
|
||||
nm_assert(tmp_array);
|
||||
return nm_g_variant_new_au((const guint32 *) tmp_array->data, tmp_array->len);
|
||||
return nm_g_variant_new_au(nm_g_array_data(tmp_array), tmp_array->len);
|
||||
case NM_SETTING_PROPERTY_TO_DBUS_FCN_GPROP_TYPE_STRDICT:
|
||||
nm_assert(G_VALUE_HOLDS(&prop_value, G_TYPE_HASH_TABLE));
|
||||
return nm_strdict_to_variant_ass(g_value_get_boxed(&prop_value));
|
||||
|
|
|
|||
|
|
@ -3065,12 +3065,12 @@ nm_strvarray_remove_first(GArray *strv, const char *needle)
|
|||
static inline int
|
||||
nm_strvarray_cmp(const GArray *a, const GArray *b)
|
||||
{
|
||||
nm_assert(!a || sizeof(const char *const *) == g_array_get_element_size((GArray *) a));
|
||||
nm_assert(!b || sizeof(const char *const *) == g_array_get_element_size((GArray *) b));
|
||||
|
||||
NM_CMP_SELF(a, b);
|
||||
|
||||
return nm_strv_cmp_n((const char *const *) a->data,
|
||||
a->len,
|
||||
(const char *const *) b->data,
|
||||
b->len);
|
||||
return nm_strv_cmp_n(nm_g_array_data(a), a->len, nm_g_array_data(b), b->len);
|
||||
}
|
||||
|
||||
#define nm_strvarray_equal(a, b) (nm_strvarray_cmp((a), (b)) == 0)
|
||||
|
|
@ -3078,10 +3078,9 @@ nm_strvarray_cmp(const GArray *a, const GArray *b)
|
|||
static inline int
|
||||
_nm_strvarray_cmp_strv(const GArray *strv, const char *const *ss, gsize ss_len)
|
||||
{
|
||||
return nm_strv_cmp_n(strv ? (const char *const *) strv->data : NULL,
|
||||
strv ? ((gssize) strv->len) : -1,
|
||||
ss,
|
||||
ss_len);
|
||||
nm_assert(!strv || sizeof(const char *const *) == g_array_get_element_size((GArray *) strv));
|
||||
|
||||
return nm_strv_cmp_n(nm_g_array_data(strv), strv ? ((gssize) strv->len) : -1, ss, ss_len);
|
||||
}
|
||||
#define nm_strvarray_cmp_strv(strv, ss, ss_len) \
|
||||
_nm_strvarray_cmp_strv((strv), NM_CAST_STRV_CC(ss), (ss_len))
|
||||
|
|
|
|||
|
|
@ -312,7 +312,7 @@ BREAK_INNER_LOOPS:
|
|||
str = &str[i];
|
||||
}
|
||||
|
||||
return (char **) g_array_free(result, FALSE);
|
||||
return (char **) ((gpointer) g_array_free(result, FALSE));
|
||||
}
|
||||
|
||||
/* free instances allocated by nmtst (especially nmtst_init()) on shutdown
|
||||
|
|
@ -666,7 +666,7 @@ __nmtst_init(int *argc,
|
|||
for (i = 0; i < debug_messages->len; i++)
|
||||
__NMTST_LOG(g_message, "%s", nm_g_array_index(debug_messages, const char *, i));
|
||||
|
||||
g_strfreev((char **) g_array_free(debug_messages, FALSE));
|
||||
g_strfreev((char **) ((gpointer) g_array_free(debug_messages, FALSE)));
|
||||
g_free(c_log_level);
|
||||
g_free(c_log_domains);
|
||||
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@ nmt_newt_grid_get_components(NmtNewtWidget *widget)
|
|||
int i, c;
|
||||
|
||||
g_array_sort(priv->children, child_sort_func);
|
||||
children = (NmtNewtGridChild *) priv->children->data;
|
||||
children = nm_g_array_first_p(priv->children, NmtNewtGridChild);
|
||||
|
||||
cos = g_ptr_array_new();
|
||||
|
||||
|
|
@ -132,7 +132,7 @@ nmt_newt_grid_size_request(NmtNewtWidget *widget, int *width, int *height)
|
|||
{
|
||||
NmtNewtGrid *grid = NMT_NEWT_GRID(widget);
|
||||
NmtNewtGridPrivate *priv = NMT_NEWT_GRID_GET_PRIVATE(grid);
|
||||
NmtNewtGridChild *children = (NmtNewtGridChild *) priv->children->data;
|
||||
NmtNewtGridChild *children = nm_g_array_first_p(priv->children, NmtNewtGridChild);
|
||||
int row, col, i;
|
||||
|
||||
g_free(priv->row_heights);
|
||||
|
|
@ -190,7 +190,7 @@ static void
|
|||
nmt_newt_grid_size_allocate(NmtNewtWidget *widget, int x, int y, int width, int height)
|
||||
{
|
||||
NmtNewtGridPrivate *priv = NMT_NEWT_GRID_GET_PRIVATE(widget);
|
||||
NmtNewtGridChild *children = (NmtNewtGridChild *) priv->children->data, *child;
|
||||
NmtNewtGridChild *children = nm_g_array_first_p(priv->children, NmtNewtGridChild), *child;
|
||||
int i, row, col;
|
||||
int child_x, child_y, child_width, child_height;
|
||||
int extra, extra_all, extra_some;
|
||||
|
|
@ -268,7 +268,7 @@ static void
|
|||
nmt_newt_grid_find_size(NmtNewtGrid *grid)
|
||||
{
|
||||
NmtNewtGridPrivate *priv = NMT_NEWT_GRID_GET_PRIVATE(grid);
|
||||
NmtNewtGridChild *children = (NmtNewtGridChild *) priv->children->data;
|
||||
NmtNewtGridChild *children = nm_g_array_first_p(priv->children, NmtNewtGridChild);
|
||||
int i;
|
||||
|
||||
priv->max_x = priv->max_y = 0;
|
||||
|
|
@ -315,7 +315,7 @@ static int
|
|||
find_child(NmtNewtGrid *grid, NmtNewtWidget *widget)
|
||||
{
|
||||
NmtNewtGridPrivate *priv = NMT_NEWT_GRID_GET_PRIVATE(grid);
|
||||
NmtNewtGridChild *children = (NmtNewtGridChild *) priv->children->data;
|
||||
NmtNewtGridChild *children = nm_g_array_first_p(priv->children, NmtNewtGridChild);
|
||||
int i;
|
||||
|
||||
for (i = 0; i < priv->children->len; i++) {
|
||||
|
|
@ -355,7 +355,7 @@ void
|
|||
nmt_newt_grid_move(NmtNewtGrid *grid, NmtNewtWidget *widget, int x, int y)
|
||||
{
|
||||
NmtNewtGridPrivate *priv = NMT_NEWT_GRID_GET_PRIVATE(grid);
|
||||
NmtNewtGridChild *children = (NmtNewtGridChild *) priv->children->data;
|
||||
NmtNewtGridChild *children = nm_g_array_first_p(priv->children, NmtNewtGridChild);
|
||||
int i;
|
||||
|
||||
i = find_child(grid, widget);
|
||||
|
|
@ -411,7 +411,7 @@ void
|
|||
nmt_newt_grid_set_flags(NmtNewtGrid *grid, NmtNewtWidget *widget, NmtNewtGridFlags flags)
|
||||
{
|
||||
NmtNewtGridPrivate *priv = NMT_NEWT_GRID_GET_PRIVATE(grid);
|
||||
NmtNewtGridChild *children = (NmtNewtGridChild *) priv->children->data;
|
||||
NmtNewtGridChild *children = nm_g_array_first_p(priv->children, NmtNewtGridChild);
|
||||
int i;
|
||||
|
||||
i = find_child(grid, widget);
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ static newtComponent
|
|||
nmt_newt_popup_build_component(NmtNewtComponent *component, gboolean sensitive)
|
||||
{
|
||||
NmtNewtPopupPrivate *priv = NMT_NEWT_POPUP_GET_PRIVATE(component);
|
||||
NmtNewtPopupEntry *entries = (NmtNewtPopupEntry *) priv->entries->data;
|
||||
NmtNewtPopupEntry *entries = nm_g_array_first_p(priv->entries, NmtNewtPopupEntry);
|
||||
|
||||
nmt_newt_button_set_label(NMT_NEWT_BUTTON(component), entries[priv->active].label);
|
||||
return NMT_NEWT_COMPONENT_CLASS(nmt_newt_popup_parent_class)
|
||||
|
|
@ -118,7 +118,7 @@ static void
|
|||
nmt_newt_popup_activated(NmtNewtWidget *widget)
|
||||
{
|
||||
NmtNewtPopupPrivate *priv = NMT_NEWT_POPUP_GET_PRIVATE(widget);
|
||||
NmtNewtPopupEntry *entries = (NmtNewtPopupEntry *) priv->entries->data;
|
||||
NmtNewtPopupEntry *entries = nm_g_array_first_p(priv->entries, NmtNewtPopupEntry);
|
||||
NmtNewtForm *form;
|
||||
NmtNewtWidget *listbox, *ret;
|
||||
int button_x, button_y;
|
||||
|
|
@ -232,7 +232,7 @@ const char *
|
|||
nmt_newt_popup_get_active_id(NmtNewtPopup *popup)
|
||||
{
|
||||
NmtNewtPopupPrivate *priv = NMT_NEWT_POPUP_GET_PRIVATE(popup);
|
||||
NmtNewtPopupEntry *entries = (NmtNewtPopupEntry *) priv->entries->data;
|
||||
NmtNewtPopupEntry *entries = nm_g_array_first_p(priv->entries, NmtNewtPopupEntry);
|
||||
|
||||
return entries[priv->active].id;
|
||||
}
|
||||
|
|
@ -248,7 +248,7 @@ void
|
|||
nmt_newt_popup_set_active_id(NmtNewtPopup *popup, const char *active_id)
|
||||
{
|
||||
NmtNewtPopupPrivate *priv = NMT_NEWT_POPUP_GET_PRIVATE(popup);
|
||||
NmtNewtPopupEntry *entries = (NmtNewtPopupEntry *) priv->entries->data;
|
||||
NmtNewtPopupEntry *entries = nm_g_array_first_p(priv->entries, NmtNewtPopupEntry);
|
||||
int i;
|
||||
|
||||
for (i = 0; i < priv->entries->len; i++) {
|
||||
|
|
|
|||
|
|
@ -825,7 +825,7 @@ _output_selection_parse(const NMMetaAbstractInfo *const *fields,
|
|||
_output_selection_complete(cols);
|
||||
|
||||
*out_cols_len = cols->len;
|
||||
*out_cols_data = (PrintDataCol *) g_array_free(g_steal_pointer(&cols), FALSE);
|
||||
*out_cols_data = (PrintDataCol *) ((gpointer) g_array_free(g_steal_pointer(&cols), FALSE));
|
||||
*out_gfree_keeper = g_steal_pointer(&gfree_keeper);
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -552,7 +552,7 @@ nmt_8021x_fields_constructed(GObject *object)
|
|||
entry.id = (char *) eap_method_descs[i].id;
|
||||
g_array_append_val(entries, entry);
|
||||
}
|
||||
priv->authentication = nmt_newt_popup_new((NmtNewtPopupEntry *) entries->data);
|
||||
priv->authentication = nmt_newt_popup_new(nm_g_array_index_p(entries, NmtNewtPopupEntry, 0));
|
||||
nmt_editor_grid_append(grid, "Authentication", NMT_NEWT_WIDGET(priv->authentication), NULL);
|
||||
|
||||
widget = nmt_newt_stack_new();
|
||||
|
|
|
|||
|
|
@ -147,7 +147,7 @@ static int
|
|||
nmt_editor_grid_find_widget(NmtEditorGrid *grid, NmtNewtWidget *widget)
|
||||
{
|
||||
NmtEditorGridPrivate *priv = NMT_EDITOR_GRID_GET_PRIVATE(grid);
|
||||
NmtEditorGridRow *rows = (NmtEditorGridRow *) priv->rows->data;
|
||||
NmtEditorGridRow *rows = nm_g_array_first_p(priv->rows, NmtEditorGridRow);
|
||||
int i;
|
||||
|
||||
for (i = 0; i < priv->rows->len; i++) {
|
||||
|
|
@ -182,7 +182,7 @@ nmt_editor_grid_set_row_flags(NmtEditorGrid *grid,
|
|||
NmtEditorGridRowFlags flags)
|
||||
{
|
||||
NmtEditorGridPrivate *priv = NMT_EDITOR_GRID_GET_PRIVATE(grid);
|
||||
NmtEditorGridRow *rows = (NmtEditorGridRow *) priv->rows->data;
|
||||
NmtEditorGridRow *rows = nm_g_array_first_p(priv->rows, NmtEditorGridRow);
|
||||
int i;
|
||||
|
||||
i = nmt_editor_grid_find_widget(grid, widget);
|
||||
|
|
@ -196,7 +196,7 @@ nmt_editor_grid_remove(NmtNewtContainer *container, NmtNewtWidget *widget)
|
|||
NmtEditorGrid *grid = NMT_EDITOR_GRID(container);
|
||||
NmtEditorGridPrivate *priv = NMT_EDITOR_GRID_GET_PRIVATE(grid);
|
||||
NmtNewtContainerClass *parent_class = NMT_NEWT_CONTAINER_CLASS(nmt_editor_grid_parent_class);
|
||||
NmtEditorGridRow *rows = (NmtEditorGridRow *) priv->rows->data;
|
||||
NmtEditorGridRow *rows = nm_g_array_first_p(priv->rows, NmtEditorGridRow);
|
||||
int i;
|
||||
|
||||
i = nmt_editor_grid_find_widget(grid, widget);
|
||||
|
|
@ -219,7 +219,7 @@ static newtComponent *
|
|||
nmt_editor_grid_get_components(NmtNewtWidget *widget)
|
||||
{
|
||||
NmtEditorGridPrivate *priv = NMT_EDITOR_GRID_GET_PRIVATE(widget);
|
||||
NmtEditorGridRow *rows = (NmtEditorGridRow *) priv->rows->data;
|
||||
NmtEditorGridRow *rows = nm_g_array_first_p(priv->rows, NmtEditorGridRow);
|
||||
newtComponent *child_cos;
|
||||
GPtrArray *cos;
|
||||
int i, c;
|
||||
|
|
@ -308,7 +308,7 @@ static void
|
|||
nmt_editor_grid_size_request(NmtNewtWidget *widget, int *width, int *height)
|
||||
{
|
||||
NmtEditorGridPrivate *priv = NMT_EDITOR_GRID_GET_PRIVATE(widget);
|
||||
NmtEditorGridRow *rows = (NmtEditorGridRow *) priv->rows->data;
|
||||
NmtEditorGridRow *rows = nm_g_array_first_p(priv->rows, NmtEditorGridRow);
|
||||
NmtEditorGridFormState *state = get_form_state(widget);
|
||||
gboolean add_padding = FALSE;
|
||||
int i;
|
||||
|
|
@ -356,7 +356,7 @@ static void
|
|||
nmt_editor_grid_size_allocate(NmtNewtWidget *widget, int x, int y, int width, int height)
|
||||
{
|
||||
NmtEditorGridPrivate *priv = NMT_EDITOR_GRID_GET_PRIVATE(widget);
|
||||
NmtEditorGridRow *rows = (NmtEditorGridRow *) priv->rows->data;
|
||||
NmtEditorGridRow *rows = nm_g_array_first_p(priv->rows, NmtEditorGridRow);
|
||||
NmtEditorGridFormState *state = get_form_state(widget);
|
||||
int col0_width, col1_width, col2_width;
|
||||
int i, row;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue