diff options
author | Philippe Mathieu-Daudé <philmd@redhat.com> | 2020-04-30 09:34:08 +0200 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2020-06-01 13:17:09 +0200 |
commit | 6826a991668cbd4ef813efa7536500725ae044a7 (patch) | |
tree | 82d193079c72cc794ee885d7d786b5167818cd06 | |
parent | bcaaa53a7527734917753887238967a698647ac2 (diff) | |
download | slirp-6826a991668cbd4ef813efa7536500725ae044a7.zip slirp-6826a991668cbd4ef813efa7536500725ae044a7.tar.gz slirp-6826a991668cbd4ef813efa7536500725ae044a7.tar.bz2 |
Fix constness warnings
Fix the following GCC warnings:
src/ncsi.c: In function ‘ncsi_input’:
src/ncsi.c:139:31: error: cast discards ‘const’ qualifier from pointer target type [-Werror=cast-qual]
139 | struct ncsi_pkt_hdr *nh = (struct ncsi_pkt_hdr *)(pkt + ETH_HLEN);
| ^
src/dnssearch.c: In function ‘translate_dnssearch’:
src/dnssearch.c:242:33: error: cast discards ‘const’ qualifier from pointer target type [-Werror=cast-qual]
242 | num_domains = g_strv_length((GStrv)names);
| ^
src/slirp.c: In function ‘arp_input’:
src/slirp.c:747:31: error: cast discards ‘const’ qualifier from pointer target type [-Werror=cast-qual]
747 | struct slirp_arphdr *ah = (struct slirp_arphdr *)(pkt + ETH_HLEN);
| ^
src/dnssearch.c: In function ‘translate_dnssearch’:
src/dnssearch.c:242:33: error: cast discards ‘const’ qualifier from pointer target type [-Werror=cast-qual]
242 | num_domains = g_strv_length((const GStrv)names);
| ^
src/slirp.c: In function ‘arp_input’:
src/slirp.c:764:48: error: passing argument 3 of ‘arp_table_add’ discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
764 | arp_table_add(slirp, ah->ar_sip, ah->ar_sha);
| ~~^~~~~~~~
In file included from src/slirp.c:25:
src/slirp.h:101:60: note: expected ‘uint8_t *’ {aka ‘unsigned char *’} but argument is of type ‘const unsigned char *’
101 | void arp_table_add(Slirp *slirp, uint32_t ip_addr, uint8_t ethaddr[ETH_ALEN]);
| ~~~~~~~~^~~~~~~~~~~~~~~~~
src/slirp.c:783:48: error: passing argument 3 of ‘arp_table_add’ discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
783 | arp_table_add(slirp, ah->ar_sip, ah->ar_sha);
| ~~^~~~~~~~
In file included from src/slirp.c:25:
src/slirp.h:101:60: note: expected ‘uint8_t *’ {aka ‘unsigned char *’} but argument is of type ‘const unsigned char *’
101 | void arp_table_add(Slirp *slirp, uint32_t ip_addr, uint8_t ethaddr[ETH_ALEN]);
| ~~~~~~~~^~~~~~~~~~~~~~~~~
src/slirp.c:804:44: error: passing argument 3 of ‘arp_table_add’ discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
804 | arp_table_add(slirp, ah->ar_sip, ah->ar_sha);
| ~~^~~~~~~~
In file included from src/slirp.c:25:
src/slirp.h:101:60: note: expected ‘uint8_t *’ {aka ‘unsigned char *’} but argument is of type ‘const unsigned char *’
101 | void arp_table_add(Slirp *slirp, uint32_t ip_addr, uint8_t ethaddr[ETH_ALEN]);
| ~~~~~~~~^~~~~~~~~~~~~~~~~
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
-rw-r--r-- | src/arp_table.c | 3 | ||||
-rw-r--r-- | src/dnssearch.c | 2 | ||||
-rw-r--r-- | src/ncsi.c | 3 | ||||
-rw-r--r-- | src/slirp.c | 3 | ||||
-rw-r--r-- | src/slirp.h | 3 |
5 files changed, 9 insertions, 5 deletions
diff --git a/src/arp_table.c b/src/arp_table.c index 054fbf5..959e5b9 100644 --- a/src/arp_table.c +++ b/src/arp_table.c @@ -27,7 +27,8 @@ #include <string.h> -void arp_table_add(Slirp *slirp, uint32_t ip_addr, uint8_t ethaddr[ETH_ALEN]) +void arp_table_add(Slirp *slirp, uint32_t ip_addr, + const uint8_t ethaddr[ETH_ALEN]) { const uint32_t broadcast_addr = ~slirp->vnetwork_mask.s_addr | slirp->vnetwork_addr.s_addr; diff --git a/src/dnssearch.c b/src/dnssearch.c index e8f14e3..55497e8 100644 --- a/src/dnssearch.c +++ b/src/dnssearch.c @@ -239,7 +239,7 @@ int translate_dnssearch(Slirp *s, const char **names) uint8_t *result = NULL, *outptr; CompactDomain *domains = NULL; - num_domains = g_strv_length((GStrv)names); + num_domains = g_strv_length((GStrv)(void *)names); if (num_domains == 0) { return -2; } @@ -136,7 +136,8 @@ static const struct ncsi_rsp_handler { void ncsi_input(Slirp *slirp, const uint8_t *pkt, int pkt_len) { - struct ncsi_pkt_hdr *nh = (struct ncsi_pkt_hdr *)(pkt + ETH_HLEN); + const struct ncsi_pkt_hdr *nh = + (const struct ncsi_pkt_hdr *)(pkt + ETH_HLEN); uint8_t ncsi_reply[ETH_HLEN + NCSI_MAX_LEN]; struct ethhdr *reh = (struct ethhdr *)ncsi_reply; struct ncsi_rsp_pkt_hdr *rnh = diff --git a/src/slirp.c b/src/slirp.c index 4053d34..aa1b74d 100644 --- a/src/slirp.c +++ b/src/slirp.c @@ -751,7 +751,8 @@ void slirp_pollfds_poll(Slirp *slirp, int select_error, static void arp_input(Slirp *slirp, const uint8_t *pkt, int pkt_len) { - struct slirp_arphdr *ah = (struct slirp_arphdr *)(pkt + ETH_HLEN); + const struct slirp_arphdr *ah = + (const struct slirp_arphdr *)(pkt + ETH_HLEN); uint8_t arp_reply[MAX(ETH_HLEN + sizeof(struct slirp_arphdr), 64)]; struct ethhdr *reh = (struct ethhdr *)arp_reply; struct slirp_arphdr *rah = (struct slirp_arphdr *)(arp_reply + ETH_HLEN); diff --git a/src/slirp.h b/src/slirp.h index 47d861b..4f8b133 100644 --- a/src/slirp.h +++ b/src/slirp.h @@ -98,7 +98,8 @@ typedef struct ArpTable { int next_victim; } ArpTable; -void arp_table_add(Slirp *slirp, uint32_t ip_addr, uint8_t ethaddr[ETH_ALEN]); +void arp_table_add(Slirp *slirp, uint32_t ip_addr, + const uint8_t ethaddr[ETH_ALEN]); bool arp_table_search(Slirp *slirp, uint32_t ip_addr, uint8_t out_ethaddr[ETH_ALEN]); |