]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
Silence GCC 8 compiler warning in ShowEA()
authorThomas Huth <huth@tuxfamily.org>
Mon, 21 May 2018 03:20:08 +0000 (05:20 +0200)
committerThomas Huth <huth@tuxfamily.org>
Mon, 21 May 2018 03:43:54 +0000 (05:43 +0200)
The current version of GCC has gained the possibility to do some additional
checks for string operation buffer overflows. It is using the size of
source arrays for the check, so in ShowEA it is currently reporting (output
taken from Hatari build):

newcpu.c: In function 'ShowEA.constprop':
newcpu.c:2440:26: warning: '%s' directive writing up to 79 bytes into a
 region of size between 73 and 75 [-Wformat-overflow=]
    _stprintf (buffer, _T("(A%d, %s) == $%08x"), reg, offtxt, addr);

The offtxt array is only storing a string for a short displacement, so
80 characters is way too big here. Decreasing the size of the array to
less characters silences the compiler warning for me.

newcpu.cpp

index d5b7c1b8c99be2b5f03a69efb9ebb0562d4d461a..610b356df647818f0cfe40df7b4de33ef51385be 100644 (file)
@@ -2283,7 +2283,7 @@ static uaecptr ShowEA (void *f, uaecptr pc, uae_u16 opcode, int reg, amodes mode
                break;
        case Ad16:
                {
-                       TCHAR offtxt[80];
+                       TCHAR offtxt[8];
                        disp16 = get_iword_debug (pc); pc += 2;
                        if (disp16 < 0)
                                _stprintf (offtxt, _T("-$%04x"), -disp16);