[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v3 06/25] gdbstub: Use size_t to hold GDBState::last
From: |
Philippe Mathieu-Daudé |
Subject: |
[Qemu-devel] [PATCH v3 06/25] gdbstub: Use size_t to hold GDBState::last_packet_len |
Date: |
Wed, 20 Feb 2019 02:02:13 +0100 |
In put_packet_binary() we have:
uint8_t *p;
for(;;) {
p = s->last_packet;
*(p++) = ...
s->last_packet_len = p - s->last_packet;
put_buffer(s, (uint8_t *)s->last_packet, s->last_packet_len);
The 'p' pointer start at s->last_packet, then is only incremented.
Since we have "p >= s->last_packet", we are sure than
"p - s->last_packet >= 0", thus "p - s->last_packet" is positive.
The few other places where s->last_packet_len is set is with constant
positive values.
It makes sense to use size_t to hold last_packet_len values.
Signed-off-by: Philippe Mathieu-Daudé <address@hidden>
---
gdbstub.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gdbstub.c b/gdbstub.c
index 76eca3bb7e..69340d7cd1 100644
--- a/gdbstub.c
+++ b/gdbstub.c
@@ -323,7 +323,7 @@ typedef struct GDBState {
int line_sum; /* running checksum */
int line_csum; /* checksum at the end of the packet */
uint8_t last_packet[MAX_PACKET_LENGTH + 4];
- int last_packet_len;
+ size_t last_packet_len;
int signal;
#ifdef CONFIG_USER_ONLY
int fd;
--
2.20.1
- [Qemu-devel] [PATCH v3 12/25] xen: Let buffer_append() return the size consumed, (continued)
- [Qemu-devel] [PATCH v3 12/25] xen: Let buffer_append() return the size consumed, Philippe Mathieu-Daudé, 2019/02/19
- [Qemu-devel] [PATCH v3 14/25] virtio-serial: Let VirtIOSerialPortClass::have_data() use size_t, Philippe Mathieu-Daudé, 2019/02/19
- [Qemu-devel] [PATCH v3 09/25] vhost-user: Express sizeof with size_t, Philippe Mathieu-Daudé, 2019/02/19
- [Qemu-devel] [PATCH v3 07/25] gdbstub: Let put_buffer() use size_t, Philippe Mathieu-Daudé, 2019/02/19
- [Qemu-devel] [RFC PATCH v3 13/25] xen: Let buffer_append() return a size_t, Philippe Mathieu-Daudé, 2019/02/19
- [Qemu-devel] [PATCH v3 06/25] gdbstub: Use size_t to hold GDBState::last_packet_len,
Philippe Mathieu-Daudé <=
- [Qemu-devel] [PATCH v3 05/25] gdbstub: Use size_t for strlen() return value, Philippe Mathieu-Daudé, 2019/02/19
- [Qemu-devel] [PATCH v3 08/25] ui/gtk: Remove pointless cast, Philippe Mathieu-Daudé, 2019/02/19
- [Qemu-devel] [PATCH v3 11/25] xen: Let xencons_send() take a 'size' argument, Philippe Mathieu-Daudé, 2019/02/19
- [Qemu-devel] [PATCH v3 03/25] chardev/wctablet: Use unsigned type to hold unsigned value, Philippe Mathieu-Daudé, 2019/02/19