[Mesa-dev] [PATCH] glsl: there is no need to check for < 0

tournier.elie tournier.elie at gmail.com
Sat Jan 21 18:24:45 UTC 2017


Reviewed-by: Elie Tournier <tournier.elie at gmail.com>

2017-01-20 23:20 GMT+01:00 Christian Gmeiner <christian.gmeiner at gmail.com>:

> size_t is defined in the C Standard section 4.1.5 as an
> 'unsigned integral type'.
>
> Fixes the following clang compile warning:
>
> glsl/blob.c:110:15: warning: comparison of unsigned expression < 0 is
> always false [-Wtautological-compare]
>    if (offset < 0 || blob->size - offset < to_write)
>        ~~~~~~ ^ ~
>
> Signed-off-by: Christian Gmeiner <christian.gmeiner at gmail.com>
> ---
>  src/compiler/glsl/blob.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/compiler/glsl/blob.c b/src/compiler/glsl/blob.c
> index dd4341b..ef17255 100644
> --- a/src/compiler/glsl/blob.c
> +++ b/src/compiler/glsl/blob.c
> @@ -107,7 +107,7 @@ blob_overwrite_bytes(struct blob *blob,
>                       size_t to_write)
>  {
>     /* Detect an attempt to overwrite data out of bounds. */
> -   if (offset < 0 || blob->size - offset < to_write)
> +   if (blob->size - offset < to_write)
>        return false;
>
>     memcpy(blob->data + offset, bytes, to_write);
> --
> 2.9.3
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20170121/336fbb59/attachment.html>


More information about the mesa-dev mailing list