[Spice-devel] [PATCH spice-common] Fix harmless warnings in quic_encode()

Alon Levy alevy at redhat.com
Wed Mar 28 04:56:31 PDT 2012


On Wed, Mar 28, 2012 at 01:33:22PM +0200, Marc-André Lureau wrote:

ACK.

> The quic code has been changed recently this way:
> 
> -    ASSERT(encoder->usr, line);
> +    if (line == NULL) {
> +        spice_warn_if_reached();
> +        return QUIC_ERROR;
> +    }
> 
> It appears that the only caller of quic_encode() gives a NULL line and
> rely on the more_lines() callback to return new lines instead.
> 
> Adjust the code accordingly, adding a few more checks to verify the
> caller gives/returns correct values.
> ---
>  common/quic.c |    6 +++---
>  1 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/common/quic.c b/common/quic.c
> index 27f637b..3e7c802 100644
> --- a/common/quic.c
> +++ b/common/quic.c
> @@ -1194,7 +1194,7 @@ static void quic_image_params(Encoder *encoder, QuicImageType type, int *channel
>  #define FILL_LINES() {                                                  \
>      if (line == lines_end) {                                            \
>          int n = encoder->usr->more_lines(encoder->usr, &line);          \
> -        if (n <= 0) {                                                   \
> +        if (n <= 0 || line == NULL) {                                   \
>              encoder->usr->error(encoder->usr, "more lines failed\n");   \
>          }                                                               \
>          lines_end = line + n * stride;                                  \
> @@ -1238,11 +1238,11 @@ int quic_encode(QuicContext *quic, QuicImageType type, int width, int height,
>      int i;
>  #endif
>  
> -    if (line == NULL) {
> +    lines_end = line + num_lines * stride;
> +    if (line == NULL && lines_end != line) {
>          spice_warn_if_reached();
>          return QUIC_ERROR;
>      }
> -    lines_end = line + num_lines * stride;
>  
>      quic_image_params(encoder, type, &channels, &bpc);
>  
> -- 
> 1.7.7.6
> 
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/spice-devel


More information about the Spice-devel mailing list