libstand: Fix loop with undefined optimized behavior
authorJohn Marino <draco@marino.st>
Tue, 10 Feb 2015 09:32:02 +0000 (10:32 +0100)
committerJohn Marino <draco@marino.st>
Tue, 10 Feb 2015 09:32:02 +0000 (10:32 +0100)
commitcd1536fbca174a8f9715ff773c2e45370b7cda08
tree8fdf777eec52ccc919c226e6d06248abfaec5117
parent92ca11d9df6c00c52dd039fd5090d399522f554e
libstand: Fix loop with undefined optimized behavior

With gcc 4.8+, libstand fails to build with "interation 8u involved in
undefined behavior [-Werror=aggressive-loop-optimizations]".  I figured
out that problem was the code was intentionally defining two fields in
the same structure with a single loop.

The "name" field is an array of size 8 while the "ext" field is an array
of size 3.  The loop in question iterated 11 times to initialize both,
relying on contiguous memory to work.  Apparently this leads to undefined
behavior, so I altered the line to explicitly define the correct element
on the correct field.
lib/libstand/dosfs.c