qemu-s390x
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [qemu-s390x] [PATCH v3 06/25] gdbstub: Use size_t to hold GDBState::


From: Marc-André Lureau
Subject: Re: [qemu-s390x] [PATCH v3 06/25] gdbstub: Use size_t to hold GDBState::last_packet_len
Date: Wed, 20 Feb 2019 11:59:16 +0100

On Wed, Feb 20, 2019 at 2:04 AM Philippe Mathieu-Daudé
<address@hidden> wrote:
>
> 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>

Reviewed-by: Marc-André Lureau <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
>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]