Re: [hatari-devel] Re: Feature request: allow to specify "-d" with autostart |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/hatari-devel Archives
]
Hi,
On 06/14/2017 12:19 AM, Nicolas Pomarède wrote:
Le 13/06/2017 à 22:45, Eero Tamminen a écrit :
On 06/13/2017 04:52 PM, Nicolas Pomarède wrote:
Le 07/06/2017 à 22:57, Eero Tamminen a écrit :
Commited the change.
I noticed a small warning while updating sources :
/home/npomarede/src/hatari-int/src/inffile.c: In function
'INF_CreateOverride':
/home/npomarede/src/hatari-int/src/inffile.c:746:5: attention : 'format'
may be used uninitialized in this function [-Wmaybe-uninitialized]
fprintf(fp, format, prgname);
^
/home/npomarede/src/hatari-int/src/inffile.c:677:14: note: 'format' was
declared here
const char *format, *infname, *prgname;
^
'format' will be filled if prgname is not null, which might always be
the case ?
Yes, it's always valid when it's used, and I don't see this warning.
I think your compiler is buggy.
I have this warning with 2 versions of gcc : 4.9.2 and 5.4.0 . I don't
think they're buggy ?
I have (Debian version of) gcc 4.9.2 and it doesn't show that warning.
The warning can be seen also in antartica.no daily builds, using mingw
7.1.1 :
http://antarctica.no/~hatari/latest/windows/make-win32-release.8a5e30eb9796.log
Anyway, when looking at the code, I don't see how gcc could guess that
prgname is necessarily not null and that prg_format should be called ?
if (prgname)
format = prg_format(prgname);
If prgname is always valid, why this test ?
That's not what GCC should see.
GCC should see that "format" is set and used *only* if "prgname" is valid:
if (prgname)
format = prg_format(prgname);
....
if (prgname && contents[offset+1] == 'Z')
{
fwrite(contents+off_prg, offset-off_prg, 1, fp);
/* write only first #Z line, skip rest */
if (!off_prg)
fprintf(fp, format, prgname);
....
if (prgname && !off_prg)
{
off_prg = offset;
fprintf(fp, format, prgname);
}
And that prg_format() function always returns a valid "format"
value (pointer to either of the two const format strings).
- Eero