diff options
author | Marc-André Lureau <marcandre.lureau@redhat.com> | 2019-11-21 14:57:09 +0400 |
---|---|---|
committer | Marc-André Lureau <marcandre.lureau@redhat.com> | 2019-11-22 10:18:13 +0400 |
commit | 8716c0e45855ffa6c089fbd23011d927534bd000 (patch) | |
tree | 24a9ab457a214cf5761a3c82f8e8dde7f254f952 | |
parent | a4412bae3282fde36e1beafdf5046ba32734b9fb (diff) | |
download | slirp-8716c0e45855ffa6c089fbd23011d927534bd000.zip slirp-8716c0e45855ffa6c089fbd23011d927534bd000.tar.gz slirp-8716c0e45855ffa6c089fbd23011d927534bd000.tar.bz2 |
sbuf: use unsigned types
Negative values wouldn't make sense in those functions and could lead
to weird results.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
-rw-r--r-- | src/sbuf.c | 7 | ||||
-rw-r--r-- | src/sbuf.h | 10 |
2 files changed, 8 insertions, 9 deletions
@@ -12,7 +12,7 @@ void sbfree(struct sbuf *sb) g_free(sb->sb_data); } -bool sbdrop(struct sbuf *sb, int num) +bool sbdrop(struct sbuf *sb, size_t num) { int limit = sb->sb_datalen / 2; @@ -32,7 +32,7 @@ bool sbdrop(struct sbuf *sb, int num) return false; } -void sbreserve(struct sbuf *sb, int size) +void sbreserve(struct sbuf *sb, size_t size) { if (sb->sb_data) { /* Already alloced, realloc if necessary */ @@ -153,11 +153,10 @@ static void sbappendsb(struct sbuf *sb, struct mbuf *m) * Don't update the sbuf rptr, this will be * done in sbdrop when the data is acked */ -void sbcopy(struct sbuf *sb, int off, int len, char *to) +void sbcopy(struct sbuf *sb, size_t off, size_t len, char *to) { char *from; - g_assert(len >= 0); g_assert(len + off <= sb->sb_cc); from = sb->sb_rptr + off; @@ -18,10 +18,10 @@ struct sbuf { char *sb_data; /* Actual data */ }; -void sbfree(struct sbuf *); -bool sbdrop(struct sbuf *, int); -void sbreserve(struct sbuf *, int); -void sbappend(struct socket *, struct mbuf *); -void sbcopy(struct sbuf *, int, int, char *); +void sbfree(struct sbuf *sb); +bool sbdrop(struct sbuf *sb, size_t len); +void sbreserve(struct sbuf *sb, size_t size); +void sbappend(struct socket *sb, struct mbuf *mb); +void sbcopy(struct sbuf *sb, size_t off, size_t len, char *p); #endif |