[v2,4/5] main: avoid 'may be used uninitialized' warnings

Submitted by andrey simiklit on Nov. 13, 2018, 12:19 p.m.

Details

Message ID 20181113121932.6424-5-asimiklit.work@gmail.com
State New
Headers show
Series "mesa: fix against several compilation warnings" ( rev: 2 ) in Mesa

Not browsing as part of any series.

Commit Message

andrey simiklit Nov. 13, 2018, 12:19 p.m.
From: Andrii Simiklit <andrii.simiklit@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

v2: Fixed by adding the unreachable case to the etc2_rgb8_fetch_texel
       ( Eric Engestrom <eric.engestrom@intel.com> )
    Changes for warning 'pixerrorcolorbest' were removed.

Signed-off-by: Andrii Simiklit <andrii.simiklit@globallogic.com>
---
 src/mesa/main/texcompress_etc.c | 1 +
 1 file changed, 1 insertion(+)

Patch hide | download patch | download mbox

diff --git a/src/mesa/main/texcompress_etc.c b/src/mesa/main/texcompress_etc.c
index b39ab33d36..f1da4d0f11 100644
--- a/src/mesa/main/texcompress_etc.c
+++ b/src/mesa/main/texcompress_etc.c
@@ -548,6 +548,7 @@  etc2_rgb8_fetch_texel(const struct etc2_block *block,
       if (punchthrough_alpha)
          dst[3] = 255;
    }
+   else unreachable("unhandled block mode");
 }
 
 static void

Comments

On Tuesday, 2018-11-13 14:19:31 +0200, asimiklit.work@gmail.com wrote:
> From: Andrii Simiklit <andrii.simiklit@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
> 
> v2: Fixed by adding the unreachable case to the etc2_rgb8_fetch_texel
>        ( Eric Engestrom <eric.engestrom@intel.com> )
>     Changes for warning 'pixerrorcolorbest' were removed.
> 
> Signed-off-by: Andrii Simiklit <andrii.simiklit@globallogic.com>

This is the right way of fixing this code-wise, but I'm not 100% sure we
can actually guarantee this logic-wise, so I'll let someone else review
(and push) this patch.

Acked-by: Eric Engestrom <eric.engestrom@intel.com>

> ---
>  src/mesa/main/texcompress_etc.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/src/mesa/main/texcompress_etc.c b/src/mesa/main/texcompress_etc.c
> index b39ab33d36..f1da4d0f11 100644
> --- a/src/mesa/main/texcompress_etc.c
> +++ b/src/mesa/main/texcompress_etc.c
> @@ -548,6 +548,7 @@ etc2_rgb8_fetch_texel(const struct etc2_block *block,
>        if (punchthrough_alpha)
>           dst[3] = 255;
>     }
> +   else unreachable("unhandled block mode");
>  }
>  
>  static void
> -- 
> 2.17.1
>