diff options
| author | Kristian Høgsberg <krh@bitplanet.net> | 2012-10-15 17:16:30 -0400 |
|---|---|---|
| committer | Kristian Høgsberg <krh@bitplanet.net> | 2012-10-15 17:16:30 -0400 |
| commit | ad03a59f5cab9e853dc024c801b49aa3ef6d33ff (patch) | |
| tree | 534312919efc7c123e3f0f44bae7bc8a8415a6de /src/connection.c | |
| parent | connection: fix leaking FDs on buffer-overflow during read (diff) | |
| download | wayland-ad03a59f5cab9e853dc024c801b49aa3ef6d33ff.tar wayland-ad03a59f5cab9e853dc024c801b49aa3ef6d33ff.tar.gz wayland-ad03a59f5cab9e853dc024c801b49aa3ef6d33ff.tar.bz2 wayland-ad03a59f5cab9e853dc024c801b49aa3ef6d33ff.tar.lz wayland-ad03a59f5cab9e853dc024c801b49aa3ef6d33ff.tar.xz wayland-ad03a59f5cab9e853dc024c801b49aa3ef6d33ff.tar.zst wayland-ad03a59f5cab9e853dc024c801b49aa3ef6d33ff.zip | |
connection: Use uin32_t for circular buffer indexes
We rely on well-defined unsigned overflow behaviour so let's make the
index fields actually unsigned. Signed ints aren't guaranteed to have the
behavior we want (could be either ones or twos complement).
Diffstat (limited to 'src/connection.c')
| -rw-r--r-- | src/connection.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/connection.c b/src/connection.c index 15d264b..b00491e 100644 --- a/src/connection.c +++ b/src/connection.c @@ -44,7 +44,7 @@ struct wl_buffer { char data[4096]; - int head, tail; + uint32_t head, tail; }; #define MASK(i) ((i) & 4095) @@ -70,7 +70,7 @@ union wl_value { static void wl_buffer_put(struct wl_buffer *b, const void *data, size_t count) { - int head, size; + uint32_t head, size; head = MASK(b->head); if (head + count <= sizeof b->data) { @@ -87,7 +87,7 @@ wl_buffer_put(struct wl_buffer *b, const void *data, size_t count) static void wl_buffer_put_iov(struct wl_buffer *b, struct iovec *iov, int *count) { - int head, tail; + uint32_t head, tail; head = MASK(b->head); tail = MASK(b->tail); @@ -111,7 +111,7 @@ wl_buffer_put_iov(struct wl_buffer *b, struct iovec *iov, int *count) static void wl_buffer_get_iov(struct wl_buffer *b, struct iovec *iov, int *count) { - int head, tail; + uint32_t head, tail; head = MASK(b->head); tail = MASK(b->tail); @@ -135,7 +135,7 @@ wl_buffer_get_iov(struct wl_buffer *b, struct iovec *iov, int *count) static void wl_buffer_copy(struct wl_buffer *b, void *data, size_t count) { - int tail, size; + uint32_t tail, size; tail = MASK(b->tail); if (tail + count <= sizeof b->data) { @@ -147,7 +147,7 @@ wl_buffer_copy(struct wl_buffer *b, void *data, size_t count) } } -static int +static uint32_t wl_buffer_size(struct wl_buffer *b) { return b->head - b->tail; |
