[Skiboot] [PATCH] external/gard: Fix uninitialised variable warning
Cyril Bur
cyrilbur at gmail.com
Tue Jul 28 15:26:05 AEST 2015
On Tue, 28 Jul 2015 11:18:02 +0800
Jeremy Kerr <jk at ozlabs.org> wrote:
> gcc -g -O3 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -m64 -Werror -Wall -g2 -ggdb -D_FORTIFY_SOURCE=2 -I. -I../../ -c gard.c -o gard.o
> gard.c: In function ‘main’:
> gard.c:741:5: error: ‘i’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
> if (i == ARRAY_SIZE(actions)) {
> ^
> cc1: all warnings being treated as errors
>
> If we 'goto out;', we'll perform the check on 'i' without having
> initialised it.
Thanks Jeremy!
>
> Signed-off-by: Jeremy Kerr <jk at ozlabs.org>
Reviewed-by: Cyril Bur <cyril.bur at au1.ibm.com>
>
> ---
> external/gard/gard.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/external/gard/gard.c b/external/gard/gard.c
> index c4e8676..d84e098 100644
> --- a/external/gard/gard.c
> +++ b/external/gard/gard.c
> @@ -620,7 +620,7 @@ int main(int argc, char **argv)
> const char *fdt_flash_path = FDT_ACTIVE_FLASH_PATH;
> char *filename = NULL;
> struct gard_ctx _ctx, *ctx;
> - int i, rc;
> + int rc, i = 0;
> bool part = 0;
> bool ecc = 0;
>
More information about the Skiboot
mailing list