[Mesa-dev] [PATCH] mesa/main: Fix memset in formatquery.c

Gustaw Smolarczyk wielkiegie at gmail.com
Fri Mar 17 12:39:02 UTC 2017


17 mar 2017 10:01 "Alejandro Piñeiro" <apinheiro at igalia.com> napisał(a):

On 17/03/17 06:26, Edward O'Callaghan wrote:
> We memset number of elements without multiplication by the
> element size.
>
> Signed-off-by: Edward O'Callaghan <funfunctor at folklore1984.net>
> ---
>  src/mesa/main/formatquery.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/mesa/main/formatquery.c b/src/mesa/main/formatquery.c
> index 598d34d..50d7c31 100644
> --- a/src/mesa/main/formatquery.c
> +++ b/src/mesa/main/formatquery.c
> @@ -1564,7 +1564,7 @@ _mesa_GetInternalformati64v(GLenum target, GLenum
internalformat,
>      * no pname can return a negative value, we fill params32 with
negative
>      * values as reference values, that can be used to know what
copy-back to
>      * params */
> -   memset(params32, -1, 16);

Urgh. Yes, this code is wrong, sorry. When I wrote it the idea is
initialize params32 elements to -1. But memset initilizes byte-per-byte.
Im not even sure if the resulting GLint value is still negative as intended.


In 2s complement arithmetic, memsetting all bytes to -1 is the same as
setting all dwords to -1 since both have a representation of all 1 bits.
Though it's better to leave a memset transformation to the compiler.

Regards,
Gustaw
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20170317/c794ab9f/attachment.html>


More information about the mesa-dev mailing list