dottedmag/x2x

Scary clang uninitialized variable warnings

Opened this issue · 1 comments

These can be replicated with ./configure CC=clang.

$ clang -Wall -c x2x.c
x2x.c:1047:7: warning: variable 'xoff' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
  if (doEdge) { /* edge triggers x2x */
      ^~~~~~
x2x.c:1254:22: note: uninitialized use occurs here
  xsh->x           = xoff;
                     ^~~~
x2x.c:1047:3: note: remove the 'if' if its condition is always false
  if (doEdge) { /* edge triggers x2x */
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
x2x.c:930:17: note: initialize the variable 'xoff' to silence this warning
  int       xoff, yoff; /* window offsets */
                ^
                 = 0
x2x.c:1047:7: warning: variable 'yoff' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
  if (doEdge) { /* edge triggers x2x */
      ^~~~~~
x2x.c:1255:22: note: uninitialized use occurs here
  xsh->y           = yoff;
                     ^~~~
x2x.c:1047:3: note: remove the 'if' if its condition is always false
  if (doEdge) { /* edge triggers x2x */
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
x2x.c:930:23: note: initialize the variable 'yoff' to silence this warning
  int       xoff, yoff; /* window offsets */
                      ^
                       = 0
x2x.c:1047:7: warning: variable 'width' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
  if (doEdge) { /* edge triggers x2x */
      ^~~~~~
x2x.c:1256:22: note: uninitialized use occurs here
  xsh->base_width  = width;
                     ^~~~~
x2x.c:1047:3: note: remove the 'if' if its condition is always false
  if (doEdge) { /* edge triggers x2x */
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
x2x.c:931:21: note: initialize the variable 'width' to silence this warning
  unsigned int width, height; /* window width, height */
                    ^
                     = 0
x2x.c:1047:7: warning: variable 'height' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
  if (doEdge) { /* edge triggers x2x */
      ^~~~~~
x2x.c:1257:22: note: uninitialized use occurs here
  xsh->base_height = height;
                     ^~~~~~
x2x.c:1047:3: note: remove the 'if' if its condition is always false
  if (doEdge) { /* edge triggers x2x */
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
x2x.c:931:29: note: initialize the variable 'height' to silence this warning
  unsigned int width, height; /* window width, height */
                            ^
                             = 0
4 warnings generated.

Thanks. Looks harmless, but is worth fixing anyway.