Skip to content

Commit

Permalink
Merge pull request luigirizzo#728 from mkaniewski/master
Browse files Browse the repository at this point in the history
Fix constness warnings generated when "-Wcast-qual" compiler option is used.
  • Loading branch information
giuseppelettieri authored Sep 28, 2020
2 parents 197bf99 + e12dda6 commit 924ed6a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion share/man/man4/netmap.4
Original file line number Diff line number Diff line change
Expand Up @@ -1038,7 +1038,7 @@ void receiver(void)
for (;;) {
poll(&fds, 1, -1);
while ( (buf = nm_nextpkt(d, &h)) )
consume_pkt(buf, h->len);
consume_pkt(buf, h.len);
}
nm_close(d);
}
Expand Down
15 changes: 7 additions & 8 deletions sys/net/netmap_user.h
Original file line number Diff line number Diff line change
Expand Up @@ -307,13 +307,10 @@ 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)




/*
* The callback, invoked on each received packet. Same as libpcap
*/
Expand Down Expand Up @@ -638,7 +635,7 @@ nm_parse(const char *ifname, struct nm_desc *d, char *err)
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;
Expand Down Expand Up @@ -735,12 +732,13 @@ nm_parse(const char *ifname, struct nm_desc *d, char *err)
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;
Expand Down Expand Up @@ -782,11 +780,12 @@ nm_parse(const char *ifname, struct nm_desc *d, char *err)
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;
Expand Down Expand Up @@ -1068,7 +1067,7 @@ nm_inject(struct nm_desc *d, const void *buf, size_t size)
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;
Expand Down

0 comments on commit 924ed6a

Please sign in to comment.