svn commit: r366388 - head/sys/net
Vincenzo Maffione
vmaffione at FreeBSD.org
Sat Oct 3 09:33:30 UTC 2020
Author: vmaffione
Date: Sat Oct 3 09:33:29 2020
New Revision: 366388
URL: https://svnweb.freebsd.org/changeset/base/366388
Log:
netmap: fix constness warnings generated by "-Wcast-qual"
Submitted by: milosz.kaniewski at gmail.com
MFC after: 3 days
Modified:
head/sys/net/netmap_user.h
Modified: head/sys/net/netmap_user.h
==============================================================================
--- head/sys/net/netmap_user.h Sat Oct 3 09:23:34 2020 (r366387)
+++ head/sys/net/netmap_user.h Sat Oct 3 09:33:29 2020 (r366388)
@@ -290,7 +290,7 @@ struct nm_desc {
* when the descriptor is open correctly, d->self == d
* Eventually we should also use some magic number.
*/
-#define P2NMD(p) ((struct nm_desc *)(p))
+#define P2NMD(p) ((const struct nm_desc *)(p))
#define IS_NETMAP_DESC(d) ((d) && P2NMD(d)->self == P2NMD(d))
#define NETMAP_FD(d) (P2NMD(d)->fd)
@@ -616,7 +616,7 @@ nm_parse(const char *ifname, struct nm_desc *d, char *
const char *vpname = NULL;
u_int namelen;
uint32_t nr_ringid = 0, nr_flags;
- char errmsg[MAXERRMSG] = "";
+ char errmsg[MAXERRMSG] = "", *tmp;
long num;
uint16_t nr_arg2 = 0;
enum { P_START, P_RNGSFXOK, P_GETNUM, P_FLAGS, P_FLAGSOK, P_MEMID } p_state;
@@ -713,12 +713,13 @@ nm_parse(const char *ifname, struct nm_desc *d, char *
port++;
break;
case P_GETNUM:
- num = strtol(port, (char **)&port, 10);
+ num = strtol(port, &tmp, 10);
if (num < 0 || num >= NETMAP_RING_MASK) {
snprintf(errmsg, MAXERRMSG, "'%ld' out of range [0, %d)",
num, NETMAP_RING_MASK);
goto fail;
}
+ port = tmp;
nr_ringid = num & NETMAP_RING_MASK;
p_state = P_RNGSFXOK;
break;
@@ -760,11 +761,12 @@ nm_parse(const char *ifname, struct nm_desc *d, char *
snprintf(errmsg, MAXERRMSG, "double setting of memid");
goto fail;
}
- num = strtol(port, (char **)&port, 10);
+ num = strtol(port, &tmp, 10);
if (num <= 0) {
snprintf(errmsg, MAXERRMSG, "invalid memid %ld, must be >0", num);
goto fail;
}
+ port = tmp;
nr_arg2 = num;
p_state = P_RNGSFXOK;
break;
@@ -1044,7 +1046,7 @@ nm_inject(struct nm_desc *d, const void *buf, size_t s
ring->slot[i].flags = NS_MOREFRAG;
nm_pkt_copy(buf, NETMAP_BUF(ring, idx), ring->nr_buf_size);
i = nm_ring_next(ring, i);
- buf = (char *)buf + ring->nr_buf_size;
+ buf = (const char *)buf + ring->nr_buf_size;
}
idx = ring->slot[i].buf_idx;
ring->slot[i].len = rem;
More information about the svn-src-all
mailing list