[hatari-devel] Cmake warnings

Eero Tamminen eerot at users.berlios.de
Mon Jan 18 23:24:51 CET 2010


Hi,

On Monday 18 January 2010, Laurent Sallafranque wrote:
> I've compiled the latest Hatari version with cmake;make
>
> I've got the following warnings :
>
> [ 3%] Building C object src/falcon/CMakeFiles/Falcon.dir/dsp_cpu.c.o
> /home/laurent/Atari/hatari/src/falcon/dsp_cpu.c: In function
> ‘dsp_jsset_pp’:
> /home/laurent/Atari/hatari/src/falcon/dsp_cpu.c:890: warning: array
> subscript is above array bounds

The sizes of arrays are:

---- dsp_core.h -------
        /* External ram[] (mapped to p:) */
        Uint32  ramext[DSP_RAMSIZE];

        /* rom[0] is x:, rom[1] is y: */
        Uint32  rom[2][512];

        /* Internal ram[0] is x:, ram[1] is y:, ram[2] is p: */
        Uint32  ramint[3][512];
--------------------


The code accessing them is:

------- dsp_cpu.c ---------
static Uint32 cur_inst;
...
static Uint32 read_memory(int space, Uint16 address)
{
...
        /* Internal ROM ? */
        if (address < 0x200) {
                if (dsp_core->registers[DSP_REG_OMR] & (1<<DSP_OMR_DE)) {
890                     return dsp_core->rom[space][address] & BITMASK(24);
----------------------
I.e. issue is in rom array offsets.


Then all of the functions gcc complains about have the same code to
call read_memory():
static void dsp_jsset_pp(void)
static void dsp_jsclr_pp(void)
static void dsp_btst_pp(void)
static void dsp_jset_pp(void)
static void dsp_jclr_pp(void)
------------
        Uint32 memspace, addr, value, numbit, newaddr;

        memspace = (cur_inst>>6) & 1;
        value = (cur_inst>>8) & BITMASK(6);
...
        addr = 0xffc0 + value;
        value = read_memory(memspace, addr);
-------------

0xffc0 = 1111111111000000 i.e. last six bits are empty.
"value" is a positive integer with at max six bits.  This means
that addr value will be 0xffc0 - 0xffff.

Which clearly doesn't fit into the 512 addresses rom array has.

I.e. to me it seems a real bug.


I'll check the errors for my code later.


	- Eero



More information about the hatari-devel mailing list