[Mesa-dev] [PATCH 4/4] main: avoid 'may be used uninitialized' warnings
Eric Engestrom
eric.engestrom at intel.com
Fri Nov 9 13:30:31 UTC 2018
On Tuesday, 2018-09-11 15:42:07 +0300, asimiklit.work at gmail.com wrote:
> From: Andrii Simiklit <andrii.simiklit at globallogic.com>
>
> 1. main/texcompress_etc.c:1314:12:
> warning: ‘*((void *)&dst+2)’ may be used uninitialized in this function
> 2. main/texcompress_etc.c:1354:12:
> warning: ‘*((void *)&dst+2)’ may be used uninitialized in this function
> 3. main/texcompress_etc.c:1293:12:
> warning: ‘dst’ may be used uninitialized in this function
> 4. main/texcompress_etc.c:1335:12:
> warning: ‘dst’ may be used uninitialized in this function
> 5. main/texcompress_etc.c:1460:12:
> warning: ‘*((void *)&dst+1)’ may be used uninitialized in this function
> 6. main/texcompress_s3tc_tmp.h:262:39:
> warning: ‘pixerrorcolorbest[2]’ may be used uninitialized in this function
>
> Signed-off-by: Andrii Simiklit <andrii.simiklit at globallogic.com>
> ---
> src/mesa/main/texcompress_etc.c | 12 ++++++------
> src/mesa/main/texcompress_s3tc_tmp.h | 2 +-
> 2 files changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/src/mesa/main/texcompress_etc.c b/src/mesa/main/texcompress_etc.c
> index b39ab33..b192708 100644
> --- a/src/mesa/main/texcompress_etc.c
> +++ b/src/mesa/main/texcompress_etc.c
> @@ -1290,7 +1290,7 @@ fetch_etc2_rgb8(const GLubyte *map,
> GLint rowStride, GLint i, GLint j, GLfloat *texel)
> {
> struct etc2_block block;
> - uint8_t dst[3];
> + uint8_t dst[3] = { 0 };
> const uint8_t *src;
>
> src = map + (((rowStride + 3) / 4) * (j / 4) + (i / 4)) * 8;
> @@ -1311,7 +1311,7 @@ fetch_etc2_srgb8(const GLubyte *map,
> GLint rowStride, GLint i, GLint j, GLfloat *texel)
> {
> struct etc2_block block;
> - uint8_t dst[3];
> + uint8_t dst[3] = { 0 };
> const uint8_t *src;
>
> src = map + (((rowStride + 3) / 4) * (j / 4) + (i / 4)) * 8;
> @@ -1332,7 +1332,7 @@ fetch_etc2_rgba8_eac(const GLubyte *map,
> GLint rowStride, GLint i, GLint j, GLfloat *texel)
> {
> struct etc2_block block;
> - uint8_t dst[4];
> + uint8_t dst[4] = { 0 };
> const uint8_t *src;
>
> src = map + (((rowStride + 3) / 4) * (j / 4) + (i / 4)) * 16;
> @@ -1351,7 +1351,7 @@ fetch_etc2_srgb8_alpha8_eac(const GLubyte *map,
> GLint rowStride, GLint i, GLint j, GLfloat *texel)
> {
> struct etc2_block block;
> - uint8_t dst[4];
> + uint8_t dst[4] = { 0 };
> const uint8_t *src;
>
> src = map + (((rowStride + 3) / 4) * (j / 4) + (i / 4)) * 16;
> @@ -1457,7 +1457,7 @@ fetch_etc2_rgb8_punchthrough_alpha1(const GLubyte *map,
> GLfloat *texel)
> {
> struct etc2_block block;
> - uint8_t dst[4];
> + uint8_t dst[4] = { 0 };
> const uint8_t *src;
>
> src = map + (((rowStride + 3) / 4) * (j / 4) + (i / 4)) * 8;
> @@ -1478,7 +1478,7 @@ fetch_etc2_srgb8_punchthrough_alpha1(const GLubyte *map,
> GLint i, GLint j, GLfloat *texel)
> {
> struct etc2_block block;
> - uint8_t dst[4];
> + uint8_t dst[4] = { 0 };
> const uint8_t *src;
>
> src = map + (((rowStride + 3) / 4) * (j / 4) + (i / 4)) * 8;
These should be fixed by adding `else unreachable();` at the end of
etc2_rgb8_fetch_texel() (and maybe other places).
> diff --git a/src/mesa/main/texcompress_s3tc_tmp.h b/src/mesa/main/texcompress_s3tc_tmp.h
> index 92316a7..bb1e37c 100644
> --- a/src/mesa/main/texcompress_s3tc_tmp.h
> +++ b/src/mesa/main/texcompress_s3tc_tmp.h
> @@ -194,7 +194,7 @@ static void fancybasecolorsearch( UNUSED GLubyte *blkaddr, GLubyte srccolors[4][
> GLuint pixerror, pixerrorred, pixerrorgreen, pixerrorblue, pixerrorbest;
> GLint colordist, blockerrlin[2][3];
> GLubyte nrcolor[2];
> - GLint pixerrorcolorbest[3];
> + GLint pixerrorcolorbest[3] = { 0 };
> GLubyte enc = 0;
> GLubyte cv[4][4];
> GLubyte testcolor[2][3];
This one is a bit too complicated for me so I'll abstain, but
simply initialising it is probably not the right thing to do.
> --
> 2.7.4
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
More information about the mesa-dev
mailing list