platform/netlink: make callback parameters to nl_recvmsg() const

This commit is contained in:
Thomas Haller 2022-08-05 21:59:30 +02:00
parent 6e5dae732a
commit c74c783c28
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728
5 changed files with 23 additions and 21 deletions

View file

@ -2576,7 +2576,7 @@ typedef struct {
} WireGuardParseData;
static int
_wireguard_get_device_cb(struct nl_msg *msg, void *arg)
_wireguard_get_device_cb(const struct nl_msg *msg, void *arg)
{
static const struct nla_policy policy[] = {
[WGDEVICE_A_IFINDEX] = {.type = NLA_U32},

View file

@ -255,7 +255,7 @@ flags_done:
/*****************************************************************************/
struct nlmsghdr *
nlmsg_hdr(struct nl_msg *n)
nlmsg_hdr(const struct nl_msg *n)
{
return n->nm_nlh;
}
@ -856,7 +856,7 @@ const struct nla_policy genl_ctrl_policy[CTRL_ATTR_MCAST_GROUPS + 1] = {
};
static int
_genl_parse_getfamily(struct nl_msg *msg, void *arg)
_genl_parse_getfamily(const struct nl_msg *msg, void *arg)
{
struct nlattr *tb[G_N_ELEMENTS(genl_ctrl_policy)];
struct nlmsghdr *nlh = nlmsg_hdr(msg);
@ -1155,7 +1155,7 @@ _cb_init(struct nl_cb *dst, const struct nl_cb *src)
}
static int
ack_wait_handler(struct nl_msg *msg, void *arg)
ack_wait_handler(const struct nl_msg *msg, void *arg)
{
return NL_STOP;
}

View file

@ -454,7 +454,7 @@ nlmsg_tail(const struct nlmsghdr *nlh)
return (unsigned char *) nlh + NLMSG_ALIGN(nlh->nlmsg_len);
}
struct nlmsghdr *nlmsg_hdr(struct nl_msg *n);
struct nlmsghdr *nlmsg_hdr(const struct nl_msg *n);
static inline int
nlmsg_valid_hdr(const struct nlmsghdr *nlh, int hdrlen)
@ -585,9 +585,11 @@ enum nl_cb_action {
NL_STOP,
};
typedef int (*nl_recvmsg_msg_cb_t)(struct nl_msg *msg, void *arg);
typedef int (*nl_recvmsg_msg_cb_t)(const struct nl_msg *msg, void *arg);
typedef int (*nl_recvmsg_err_cb_t)(struct sockaddr_nl *nla, struct nlmsgerr *nlerr, void *arg);
typedef int (*nl_recvmsg_err_cb_t)(const struct sockaddr_nl *nla,
const struct nlmsgerr *nlerr,
void *arg);
struct nl_cb {
nl_recvmsg_msg_cb_t valid_cb;

View file

@ -58,7 +58,7 @@ typedef struct {
G_DEFINE_TYPE(NMWifiUtilsNl80211, nm_wifi_utils_nl80211, NM_TYPE_WIFI_UTILS)
static int
ack_handler(struct nl_msg *msg, void *arg)
ack_handler(const struct nl_msg *msg, void *arg)
{
int *done = arg;
*done = 1;
@ -66,7 +66,7 @@ ack_handler(struct nl_msg *msg, void *arg)
}
static int
finish_handler(struct nl_msg *msg, void *arg)
finish_handler(const struct nl_msg *msg, void *arg)
{
int *done = arg;
*done = 1;
@ -74,7 +74,7 @@ finish_handler(struct nl_msg *msg, void *arg)
}
static int
error_handler(struct sockaddr_nl *nla, struct nlmsgerr *err, void *arg)
error_handler(const struct sockaddr_nl *nla, const struct nlmsgerr *err, void *arg)
{
int *done = arg;
*done = err->error;
@ -106,7 +106,7 @@ nl80211_alloc_msg(NMWifiUtilsNl80211 *self, uint8_t cmd, uint16_t flags)
static int
nl80211_send_and_recv(NMWifiUtilsNl80211 *self,
struct nl_msg *msg,
int (*valid_handler)(struct nl_msg *, void *),
int (*valid_handler)(const struct nl_msg *, void *),
void *valid_data)
{
int err;
@ -167,7 +167,7 @@ struct nl80211_iface_info {
};
static int
nl80211_iface_info_handler(struct nl_msg *msg, void *arg)
nl80211_iface_info_handler(const struct nl_msg *msg, void *arg)
{
struct nl80211_iface_info *info = arg;
struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg));
@ -269,7 +269,7 @@ nla_put_failure:
}
static int
nl80211_get_wake_on_wlan_handler(struct nl_msg *msg, void *arg)
nl80211_get_wake_on_wlan_handler(const struct nl_msg *msg, void *arg)
{
_NMSettingWirelessWakeOnWLan *wowl = arg;
struct nlattr *attrs[NL80211_ATTR_MAX + 1];
@ -422,7 +422,7 @@ struct nl80211_station_info {
};
static int
nl80211_station_dump_handler(struct nl_msg *msg, void *arg)
nl80211_station_dump_handler(const struct nl_msg *msg, void *arg)
{
static const struct nla_policy stats_policy[] = {
[NL80211_STA_INFO_INACTIVE_TIME] = {.type = NLA_U32},
@ -576,7 +576,7 @@ struct nl80211_device_info {
#define WLAN_CIPHER_SUITE_SMS4 0x00147201
static int
nl80211_wiphy_info_handler(struct nl_msg *msg, void *arg)
nl80211_wiphy_info_handler(const struct nl_msg *msg, void *arg)
{
static const struct nla_policy freq_policy[] = {
[NL80211_FREQUENCY_ATTR_FREQ] = {.type = NLA_U32},
@ -816,7 +816,7 @@ struct nl80211_csme_conn_info {
};
static int
nl80211_csme_conn_event_handler(struct nl_msg *msg, void *arg)
nl80211_csme_conn_event_handler(const struct nl_msg *msg, void *arg)
{
struct nl80211_csme_conn_info *info = arg;
NMPlatformCsmeConnInfo *out_conn_info = info->conn_info;

View file

@ -51,7 +51,7 @@ G_DEFINE_TYPE(NMWpanUtils, nm_wpan_utils, G_TYPE_OBJECT)
/*****************************************************************************/
static int
ack_handler(struct nl_msg *msg, void *arg)
ack_handler(const struct nl_msg *msg, void *arg)
{
int *done = arg;
*done = 1;
@ -59,7 +59,7 @@ ack_handler(struct nl_msg *msg, void *arg)
}
static int
finish_handler(struct nl_msg *msg, void *arg)
finish_handler(const struct nl_msg *msg, void *arg)
{
int *done = arg;
*done = 1;
@ -67,7 +67,7 @@ finish_handler(struct nl_msg *msg, void *arg)
}
static int
error_handler(struct sockaddr_nl *nla, struct nlmsgerr *err, void *arg)
error_handler(const struct sockaddr_nl *nla, const struct nlmsgerr *err, void *arg)
{
int *done = arg;
*done = err->error;
@ -98,7 +98,7 @@ nl802154_alloc_msg(NMWpanUtils *self, uint8_t cmd, uint16_t flags)
static int
nl802154_send_and_recv(NMWpanUtils *self,
struct nl_msg *msg,
int (*valid_handler)(struct nl_msg *, void *),
int (*valid_handler)(const struct nl_msg *, void *),
void *valid_data)
{
int err;
@ -144,7 +144,7 @@ struct nl802154_interface {
};
static int
nl802154_get_interface_handler(struct nl_msg *msg, void *arg)
nl802154_get_interface_handler(const struct nl_msg *msg, void *arg)
{
static const struct nla_policy nl802154_policy[] = {
[NL802154_ATTR_PAN_ID] = {.type = NLA_U16},