Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net/netmap_user.h: make netmap applications compile with -Wsign-conversion #541

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions sys/net/netmap_user.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
nifp, (nifp)->ring_ofs[index] )

#define NETMAP_RXRING(nifp, index) _NETMAP_OFFSET(struct netmap_ring *, \
nifp, (nifp)->ring_ofs[index + (nifp)->ni_tx_rings + 1] )
nifp, (nifp)->ring_ofs[((size_t)index) + (nifp)->ni_tx_rings + 1] )

#define NETMAP_BUF(ring, index) \
((char *)(ring) + (ring)->buf_ofs + ((index)*(ring)->nr_buf_size))
Expand Down Expand Up @@ -140,10 +140,10 @@ nm_tx_pending(struct netmap_ring *r)
static inline uint32_t
nm_ring_space(struct netmap_ring *ring)
{
int ret = ring->tail - ring->cur;
int ret = ((int)ring->tail) - ((int)ring->cur);
if (ret < 0)
ret += ring->num_slots;
return ret;
ret += ((int)ring->num_slots);
return (uint32_t)ret;
}


Expand Down Expand Up @@ -278,7 +278,7 @@ nm_pkt_copy(const void *_src, void *_dst, int l)
uint64_t *dst = (uint64_t *)_dst;

if (unlikely(l >= 1024 || l % 64)) {
memcpy(dst, src, l);
memcpy(dst, src, (size_t)l);
return;
}
for (; likely(l > 0); l-=64) {
Expand Down Expand Up @@ -1021,7 +1021,7 @@ nm_mmap(struct nm_desc *d, const struct nm_desc *parent)
static int
nm_inject(struct nm_desc *d, const void *buf, size_t size)
{
u_int c, n = d->last_tx_ring - d->first_tx_ring + 1,
u_int c, n = (u_int)d->last_tx_ring - (u_int)d->first_tx_ring + 1,
ri = d->cur_tx_ring;

for (c = 0; c < n ; c++, ri++) {
Expand All @@ -1046,7 +1046,7 @@ nm_inject(struct nm_desc *d, const void *buf, size_t size)
idx = ring->slot[i].buf_idx;
ring->slot[i].len = ring->nr_buf_size;
ring->slot[i].flags = NS_MOREFRAG;
nm_pkt_copy(buf, NETMAP_BUF(ring, idx), ring->nr_buf_size);
nm_pkt_copy(buf, NETMAP_BUF(ring, idx), (int)ring->nr_buf_size);
i = nm_ring_next(ring, i);
buf = (char *)buf + ring->nr_buf_size;
}
Expand Down