src: gen-image: Fix compiler warning
PATCH 1/1 src: gen-image: Fix compiler warning
Fix compiler warning for maybe uninitialized.
--- src/gen-image.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
src/gen-image.c +1 -1
@@ -386,7 +386,7 @@ static int pnm_read_integer(int fd)static struct image *pnm_read (const char *filename) { -struct image *image; +struct image *image =NULL ;unsigned int width;unsigned int height;char buffer[2 ];
Signature · 1 line
2.47.3
Hi Paul,
Thank you for the patch.
Quoted 1 line · Paul Elder
Fix compiler warning for maybe uninitialized.
It's useful to record more detailed information when working around compiler issues. I'll expand the commit message to
gcc reports an uninitialized variable when compiling with '-Os':
In function ‘process’,
inlined from ‘main’ at ../src/gen-image.c:2359:8:
../src/gen-image.c:1722:12: error: ‘image’ may be used uninitialized [-Werror=maybe-uninitialized]
1722 | if (!input) {
| ^../src/gen-image.c: In function ‘main’:../src/gen-image.c:389:23: note: ‘image’ was declared here
389 | struct image *image;
| ^~~~~
This appears to be a false positive. Work around it by initializing the image variable to NULL when declaring it.
Quoted 1 line
Signed-off-by Paul Elder <[email protected]>
Quoted 17 lines
--- src/gen-image.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)src/gen-image.c +1
-1@@ -386,7 +386,7 @@ static int pnm_read_integer(int fd)static struct image *pnm_read (const char *filename) { -struct image *image; +struct image *image =NULL ;unsigned int width;unsigned int height;char buffer[2 ];
Signature · 3 lines
Regards, Laurent Pinchart