]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
Fixed some code analyzer warnings.
authorToni Wilen <twilen@winuae.net>
Mon, 5 Mar 2018 19:25:01 +0000 (21:25 +0200)
committerToni Wilen <twilen@winuae.net>
Mon, 5 Mar 2018 19:25:01 +0000 (21:25 +0200)
26 files changed:
a2065.cpp
a2091.cpp
akiko.cpp
arcadia.cpp
cd32_fmv.cpp
cfgfile.cpp
custom.cpp
epsonprinter.cpp
inputdevice.cpp
memory.cpp
ncr_scsi.cpp
newcpu.cpp
od-win32/blkdev_win32_ioctl.cpp
od-win32/blkdev_win32_spti.cpp
od-win32/clipboard_win32.cpp
od-win32/fsdb_mywin32.cpp
od-win32/picasso96_win.cpp
od-win32/registry.cpp
od-win32/win32gui.cpp
pci.cpp
rommgr.cpp
rtc.cpp
sndboard.cpp
uaeipc.cpp
zfile.cpp
zfile_archive.cpp

index 03a4607ded609db0aabd498197a30b92613bdac6..66128ed5ec28b619e7693284555b954cc444d5d1 100644 (file)
--- a/a2065.cpp
+++ b/a2065.cpp
@@ -200,7 +200,7 @@ static int mungepacket (uae_u8 *packet, int len)
                        int udpcrc = 0;
                        int sp = (data[0] << 8) | data[1];
                        int dp = (data[2] << 8) | data[3];
-                       int len = (data[4] << 8) | data[5];
+                       int len2 = (data[4] << 8) | data[5];
                        if (sp == 67 || sp == 68 || dp == 67 || dp == 68)
                                udpcrc |= dofakemac (data + 36); // DHCP CHADDR
                        if (udpcrc && (data[6] || data[7])) {
@@ -208,16 +208,16 @@ static int mungepacket (uae_u8 *packet, int len)
                                int i;
                                uae_u32 sum;
                                data[6] = data[7] = 0;
-                               data[len] = 0;
+                               data[len2] = 0;
                                sum = 0;
-                               for (i = 0; i < ((len + 1) & ~1); i += 2)
+                               for (i = 0; i < ((len2 + 1) & ~1); i += 2)
                                        sum += (data[i] << 8) | data[i + 1];
                                sum += (ipv4[12] << 8) | ipv4[13];
                                sum += (ipv4[14] << 8) | ipv4[15];
                                sum += (ipv4[16] << 8) | ipv4[17];
                                sum += (ipv4[18] << 8) | ipv4[19];
                                sum += 17;
-                               sum += len;
+                               sum += len2;
                                while (sum >> 16)
                                        sum = (sum & 0xFFFF) + (sum >> 16);
                                sum = ~sum;
@@ -892,7 +892,7 @@ static void a2065_bput2 (uaecptr addr, uae_u32 v)
 
 static uae_u32 REGPARAM2 a2065_wget (uaecptr addr)
 {
-       uae_u16 v;
+       uae_u16 v = 0;
        addr &= 65535;
 
        switch (romtype) {
index fd15d4b60007bc281f68f35d9f0f4e256262e752..200d6428f32553df35bade0ff3e3496448ed356d 100644 (file)
--- a/a2091.cpp
+++ b/a2091.cpp
@@ -695,7 +695,7 @@ static bool do_dma_commodore_8727(struct wd_state *wd, struct scsi_data *scsi)
                        if (!status)
                                status = scsi_receive_data(scsi, &v2, true);
                        put_word((wd->cdmac.dmac_acr << 1) & 0xffffff, (v1 << 8) | v2);
-                       if (wd->wc.wd_dataoffset < sizeof wd->wc.wd_data) {
+                       if (wd->wc.wd_dataoffset < sizeof wd->wc.wd_data - 1) {
                                wd->wc.wd_data[wd->wc.wd_dataoffset++] = v1;
                                wd->wc.wd_data[wd->wc.wd_dataoffset++] = v2;
                        }
@@ -723,7 +723,7 @@ static bool do_dma_commodore_8727(struct wd_state *wd, struct scsi_data *scsi)
                for (;;) {
                        int status;
                        uae_u16 v = get_word((wd->cdmac.dmac_acr << 1) & 0xffffff);
-                       if (wd->wc.wd_dataoffset < sizeof wd->wc.wd_data) {
+                       if (wd->wc.wd_dataoffset < sizeof wd->wc.wd_data - 1) {
                                wd->wc.wd_data[wd->wc.wd_dataoffset++] = v >> 8;
                                wd->wc.wd_data[wd->wc.wd_dataoffset++] = v;
                        }
@@ -4294,7 +4294,7 @@ static bool gvp_init(struct autoconfig_info *aci, bool series2, bool accel)
                        if (series2) {
                                int total = 0;
                                int seekpos = 0;
-                               int size = zfile_size(z);
+                               size = zfile_size(z);
                                if (size > 16384 + 4096) {
                                        zfile_fread(wd->rom, 64, 1, z);
                                        zfile_fseek(z, 16384, SEEK_SET);
index b68f99faec6bf36ff5fde671c72f1681af81ebf8..d4dbb717c01867caa6df97ac5a00a36e497f53fe 100644 (file)
--- a/akiko.cpp
+++ b/akiko.cpp
@@ -1110,7 +1110,7 @@ static void cdrom_run_command_run (void)
 /* DMA transfer one CD sector */
 static void cdrom_run_read (void)
 {
-       int i, sector, inc;
+       int sector, inc;
        int sec;
        int seccnt;
 
@@ -1142,9 +1142,9 @@ static void cdrom_run_read (void)
                        buf[1] = 0;
                        buf[2] = 0;
                        buf[3] = cdrom_sector_counter & 31;
-                       for (i = 0; i < 2352; i++)
+                       for (int i = 0; i < 2352; i++)
                                put_byte (cdrom_addressdata + seccnt * 4096 + i, buf[i]);
-                       for (i = 0; i < 73 * 2; i++)
+                       for (int i = 0; i < 73 * 2; i++)
                                put_byte (cdrom_addressdata + seccnt * 4096 + 0xc00 + i, 0);
                        cdrom_pbx &= ~(1 << seccnt);
                        set_status (CDINTERRUPT_PBX);
@@ -1328,7 +1328,7 @@ void AKIKO_hsync_handler (void)
 /* cdrom data buffering thread */
 static void *akiko_thread (void *null)
 {
-       int i;
+       int secnum;
        uae_u8 *tmp1;
        uae_u8 *tmp2;
        int tmp3;
@@ -1391,12 +1391,12 @@ static void *akiko_thread (void *null)
 
                uae_sem_wait (&akiko_sem);
                sector = cdrom_current_sector;
-               for (i = 0; i < SECTOR_BUFFER_SIZE; i++) {
-                       if (sector_buffer_info_1[i] == 0xff)
+               for (secnum = 0; secnum < SECTOR_BUFFER_SIZE; secnum++) {
+                       if (sector_buffer_info_1[secnum] == 0xff)
                                break;
                }
                if (sector >= 0 && is_valid_data_sector(sector) &&
-                       (sector_buffer_sector_1 < 0 || sector < sector_buffer_sector_1 || sector >= sector_buffer_sector_1 + SECTOR_BUFFER_SIZE * 2 / 3 || i != SECTOR_BUFFER_SIZE)) {
+                       (sector_buffer_sector_1 < 0 || sector < sector_buffer_sector_1 || sector >= sector_buffer_sector_1 + SECTOR_BUFFER_SIZE * 2 / 3 || secnum != SECTOR_BUFFER_SIZE)) {
                        int blocks;
                        memset (sector_buffer_info_2, 0, SECTOR_BUFFER_SIZE);
 #if AKIKO_DEBUG_IO_CMD
@@ -1417,10 +1417,10 @@ static void *akiko_thread (void *null)
                                if (!ok) {
                                        int offset = 0;
                                        while (offset < SECTOR_BUFFER_SIZE) {
-                                               int ok = 0;
+                                               int readok = 0;
                                                if (is_valid_data_sector(sector))
-                                                       ok = sys_command_cd_rawread (unitnum, sector_buffer_2 + offset * 2352, sector, 1, 2352);
-                                               sector_buffer_info_2[offset] = ok ? 3 : 0;
+                                                       readok = sys_command_cd_rawread (unitnum, sector_buffer_2 + offset * 2352, sector, 1, 2352);
+                                               sector_buffer_info_2[offset] = readok ? 3 : 0;
                                                offset++;
                                                sector++;
                                        }
index b44a9c6355b297a9a88b6eba735c04b93597e293..49890dfee450105fae0150039705675b9ab1d6ad 100644 (file)
@@ -1280,7 +1280,7 @@ static void cubo_write_pic(uae_u8 v)
                        cubo_pic_byte |= 1;
                if ((cubo_pic_bit_cnt & 7) == 7) {
                        int offset = cubo_pic_bit_cnt / 8;
-                       if (offset <= sizeof(cubo_pic_key)) {
+                       if (offset < sizeof(cubo_pic_key)) {
                                cubo_pic_key[offset] = cubo_pic_byte;
                                write_log(_T("Cubo PIC received %02x (%d/%d)\n"), cubo_pic_byte, offset, sizeof(cubo_pic_key));
                        }
index c8253ef996eff946adbdd1aaf7be8f38dc4c44f5..876a82b8f364e42186b594aee1d08a5db2d9f0b1 100644 (file)
@@ -1278,7 +1278,7 @@ static void io_wput(uaecptr addr, uae_u16 v)
 
 static uae_u32 REGPARAM2 fmv_wget (uaecptr addr)
 {
-       uae_u32 v;
+       uae_u32 v = 0;
        addr -= fmv_start & fmv_bank.mask;
        addr &= fmv_bank.mask;
        int mask = addr & BANK_MASK;
@@ -1309,7 +1309,7 @@ static uae_u32 REGPARAM2 fmv_lget (uaecptr addr)
 
 static uae_u32 REGPARAM2 fmv_bget (uaecptr addr)
 {
-       uae_u32 v;
+       uae_u32 v = 0;
        addr -= fmv_start & fmv_bank.mask;
        addr &= fmv_bank.mask;
        int mask = addr & BANK_MASK;
index bd350f8ba72a86ef48742750df6e4cdc88dbff95..596a476037d172108a27eddfc9221d94807980cb 100644 (file)
@@ -6800,6 +6800,7 @@ int cmdlineparser (const TCHAR *s, TCHAR *outp[], int max)
        prev = s;
        j = 0;
        outp[0] = 0;
+       tmp1[0] = 0;
        while (cnt < max) {
                TCHAR c = *s++;
                if (!c)
@@ -6874,6 +6875,7 @@ int cfgfile_searchconfig(const TCHAR *in, int index, TCHAR *out, int outsize)
        if (index < 0)
                zfile_fseek(configstore, 0, SEEK_SET);
 
+       tmp[0] = 0;
        for (;;) {
                uae_u8 b = 0;
 
index bcad358c0611cf2e51a914962e43c8f65fd8a28b..bcd9e920a80dc7d24613f49d8194938c7ee5ce14 100644 (file)
@@ -77,7 +77,7 @@ static void uae_abort (const TCHAR *format,...)
        TCHAR buffer[1000];
 
        va_start (parms, format);
-       _vsntprintf (buffer, sizeof (buffer) - 1, format, parms );
+       _vsntprintf (buffer, sizeof (buffer) / sizeof(TCHAR) - 1, format, parms );
        va_end (parms);
        if (nomore) {
                write_log (_T("%s\n"), buffer);
@@ -8162,7 +8162,7 @@ static void dmal_emu (uae_u32 v)
                last_custom_value1 = dat;
                AUDxDAT (nr, dat, pt);
        } else {
-               uae_u16 dat;
+               uae_u16 dat = 0;
                int w = v & 1;
                uaecptr pt = disk_getpt ();
                // disk_fifostatus() needed in >100% disk speed modes
@@ -9236,7 +9236,7 @@ static uae_u32 custom_wget2(uaecptr addr, bool byte)
        v = custom_wget_1 (hpos, addr, 0, byte);
 #ifdef ACTION_REPLAY
 #ifdef ACTION_REPLAY_COMMON
-       addr &= 0x1ff;
+       addr &= 0x1fe;
        ar_custom[addr + 0] = (uae_u8)(v >> 8);
        ar_custom[addr + 1] = (uae_u8)(v);
 #endif
index 84dd2cc225ffe4147c89d5a81b1e466dcac6dd0c..15882b3e289617fcc09e40572d584d30f48373be 100644 (file)
@@ -605,7 +605,7 @@ static void updateFont(void)
                        vertPoints *= (Real64)10/(Real64)cpi;
                }
 
-               if (!style & STYLE_PROP)
+               if (!(style & STYLE_PROP))
                {
                        if (cpi == 10 && (style & STYLE_CONDENSED))
                        {
index f780fe4c355c97a56d83e971aa3f19ee423c3c36..0b13f13473fea0227e1051fdd3cbd386087999e3 100644 (file)
@@ -721,12 +721,12 @@ static bool write_slot (TCHAR *p, struct uae_input_device *uid, int i, int j)
        if (ok && (flags & ID_FLAG_SAVE_MASK_QUALIFIERS)) {
                TCHAR *p2 = p + _tcslen (p);
                *p2++ = '.';
-               for (int i = 0; i < MAX_INPUT_QUALIFIERS * 2; i++) {
-                       if ((ID_FLAG_QUALIFIER1 << i) & flags) {
-                               if (i & 1)
-                                       _stprintf (p2, _T("%c"), 'a' + i / 2);
+               for (int k = 0; k < MAX_INPUT_QUALIFIERS * 2; k++) {
+                       if ((ID_FLAG_QUALIFIER1 << k) & flags) {
+                               if (k & 1)
+                                       _stprintf (p2, _T("%c"), 'a' + k / 2);
                                else
-                                       _stprintf (p2, _T("%c"), 'A' + i / 2);
+                                       _stprintf (p2, _T("%c"), 'A' + k / 2);
                                p2++;
                        }
                }
@@ -1798,12 +1798,12 @@ static void generate_jport_custom_item(struct uae_input_device *uid, int num, in
                                        if (flags & ID_FLAG_SAVE_MASK_QUALIFIERS) {
                                                TCHAR *p2 = p + _tcslen(p);
                                                *p2++ = '.';
-                                               for (int i = 0; i < MAX_INPUT_QUALIFIERS * 2; i++) {
-                                                       if ((ID_FLAG_QUALIFIER1 << i) & flags) {
-                                                               if (i & 1)
-                                                                       _stprintf(p2, _T("%c"), 'a' + i / 2);
+                                               for (int k = 0; k < MAX_INPUT_QUALIFIERS * 2; k++) {
+                                                       if ((ID_FLAG_QUALIFIER1 << k) & flags) {
+                                                               if (k & 1)
+                                                                       _stprintf(p2, _T("%c"), 'a' + k / 2);
                                                                else
-                                                                       _stprintf(p2, _T("%c"), 'A' + i / 2);
+                                                                       _stprintf(p2, _T("%c"), 'A' + k / 2);
                                                                p2++;
                                                        }
                                                }
@@ -7008,7 +7008,7 @@ static void matchdevices(struct uae_prefs *p, struct inputdevice_functions *inf,
                                                if (bname[0] && !_tcscmp (bname2, bname))
                                                        matched = true;
                                        }
-                                       if (matched && fullmatch && _tcscmp(aname1, bname1) != 0)
+                                       if (matched && fullmatch && aname1 && bname1 && _tcscmp(aname1, bname1) != 0)
                                                matched = false;
                                        if (matched) {
                                                if (match >= 0)
@@ -7387,7 +7387,7 @@ bool inputdevice_devicechange (struct uae_prefs *prefs)
                        TCHAR tmp[10];
                        _stprintf(tmp, _T("custom%d"), jportscustom[i]);
                        found = inputdevice_joyport_config(prefs, tmp, NULL, i, jportsmode[i], 0, true) != 0;
-               } else if (jports_name[i][0] || jports_configname[i][0]) {
+               } else if ((jports_name[i] && jports_name[i][0]) || (jports_configname[i] && jports_configname[i][0])) {
                        if (!inputdevice_joyport_config (prefs, jports_name[i], jports_configname[i], i, jportsmode[i], 1, true)) {
                                found = inputdevice_joyport_config (prefs, jports_name[i], NULL, i, jportsmode[i], 1, true) != 0;
                        }
index 74c3c76f256e0e7c8dde9b46f48bf135509a841a..21c2fd5d8bdbb13822d462f8da7a84366a1bd76d 100644 (file)
@@ -199,7 +199,7 @@ static bool maybe_map_boot_rom(uaecptr addr)
                        if (!check2) {
                                uae_u32 w = get_word(pc);
                                // JSR xxxxxxxx or JSR (an)
-                               if (w == 0x4eb9 || w == 0x4eb9)
+                               if (w == 0x4eb9 || (w & 0xfff8) == 0x4e90)
                                        check2 = true;
                        }
                        if (check2) {
@@ -2276,7 +2276,7 @@ static void fill_ce_banks (void)
        if (currprefs.cs_romisslow) {
                for (i = (0xe00000 >> 16); i < (0xe80000 >> 16); i++)
                        ce_banktype[i] = CE_MEMBANK_CHIP16;
-               for (i = (0xf80000 >> 16); i < (0x100000 >> 16); i++)
+               for (i = (0xf80000 >> 16); i < (0x1000000 >> 16); i++)
                        ce_banktype[i] = CE_MEMBANK_CHIP16;
        }
 
index 27ad170d1b52acde123a5157a57cb057ec6115da..efd1534d3802da0b9a3f27e3504fb7c6727c254f 100644 (file)
@@ -455,11 +455,11 @@ static uae_u32 ncr_bget2 (struct ncr_state *ncr, uaecptr addr)
        if (ncr->rom && addr >= ncr->rom_start && addr < ncr->rom_end)
                return read_rombyte (ncr, addr - ncr->rom_offset);
        if (addr == A4091_DIP_OFFSET) {
-               uae_u8 v = 0;
-               v |= ncr->rc->device_id;
-               v |= ncr->rc->device_settings << 3;
-               v ^= 0xff & ~7;
-               return v;
+               uae_u8 v2 = 0;
+               v2 |= ncr->rc->device_id;
+               v2 |= ncr->rc->device_settings << 3;
+               v2 ^= 0xff & ~7;
+               return v2;
        }
        if (ncr->io_end && (addr < ncr->io_start || addr >= ncr->io_end)) {
 #if NCR_DEBUG > 1
index ddc78c90342c8cdbabc6a7711e9a421e022569dd..0d11f7240fc4ba8d32014bc9620a6f37db2a9e13 100644 (file)
@@ -7410,14 +7410,14 @@ void m68k_disasm_2 (TCHAR *buf, int bufsize, uaecptr pc, uaecptr *nextpc, int cn
                        uae_u16 r = imm >> 12;
                        TCHAR regs[16];
                        const TCHAR *cname = _T("?");
-                       int i;
-                       for (i = 0; m2cregs[i].regname; i++) {
-                               if (m2cregs[i].regno == creg)
+                       int j;
+                       for (j = 0; m2cregs[j].regname; j++) {
+                               if (m2cregs[j].regno == creg)
                                        break;
                        }
                        _stprintf (regs, _T("%c%d"), r >= 8 ? 'A' : 'D', r >= 8 ? r - 8 : r);
-                       if (m2cregs[i].regname)
-                               cname = m2cregs[i].regname;
+                       if (m2cregs[j].regname)
+                               cname = m2cregs[j].regname;
                        if (lookup->mnemo == i_MOVE2C) {
                                _tcscat (instrname, regs);
                                _tcscat (instrname, _T(","));
@@ -8250,12 +8250,12 @@ uae_u8 *restore_cpu_trace (uae_u8 *src)
                        }
                        if (v & 8) {
                                // backwards compatibility
-                               uae_u32 v = restore_u32();
-                               cputrace.prefetch020[0] = v >> 16;
-                               cputrace.prefetch020[1] = (uae_u16)v;
-                               v = restore_u32();
-                               cputrace.prefetch020[2] = v >> 16;
-                               cputrace.prefetch020[3] = (uae_u16)v;
+                               uae_u32 v2 = restore_u32();
+                               cputrace.prefetch020[0] = v2 >> 16;
+                               cputrace.prefetch020[1] = (uae_u16)v2;
+                               v2 = restore_u32();
+                               cputrace.prefetch020[2] = v2 >> 16;
+                               cputrace.prefetch020[3] = (uae_u16)v2;
                                restore_u32();
                                restore_u32();
                                cputrace.prefetch020_valid[0] = true;
@@ -8356,7 +8356,7 @@ uae_u8 *save_cpu_extra (int *len, uae_u8 *dstptr)
 uae_u8 *save_cpu (int *len, uae_u8 *dstptr)
 {
        uae_u8 *dstbak, *dst;
-       int model, i, khz;
+       int model, khz;
 
        if (dstptr)
                dstbak = dst = dstptr;
@@ -8365,7 +8365,7 @@ uae_u8 *save_cpu (int *len, uae_u8 *dstptr)
        model = currprefs.cpu_model;
        save_u32 (model);                                       /* MODEL */
        save_u32(0x80000000 | 0x40000000 | 0x20000000 | 0x10000000 | 0x8000000 | 0x4000000 | (currprefs.address_space_24 ? 1 : 0)); /* FLAGS */
-       for (i = 0;i < 15; i++)
+       for (int i = 0;i < 15; i++)
                save_u32 (regs.regs[i]);                /* D0-D7 A0-A6 */
        save_u32 (m68k_getpc ());                       /* PC */
        save_u16 (regs.irc);                            /* prefetch */
index df5473d2519eb8d91d794331e4a0f920f89505cc..7573b46812e246cd3310fa384a33e71faf96acee 100644 (file)
@@ -131,7 +131,7 @@ static int mcierr (TCHAR *str, DWORD err)
        TCHAR es[1000];
        if (err == MMSYSERR_NOERROR)
                return MMSYSERR_NOERROR;
-       if (mciGetErrorString (err, es, sizeof es))
+       if (mciGetErrorString (err, es, sizeof es / sizeof(TCHAR)))
                write_log (_T("MCIErr: %s: %d = '%s'\n"), str, err, es);
        return err;
 }
index e87cbb7079a6d6b051ae89e0050116bbedf7ea5e..f8259824aab5ca855c9717d548472751066f611b 100644 (file)
@@ -236,8 +236,7 @@ static int execscsicmd_direct (int unitnum, struct amigascsi *as)
                        as->sensedata[sactual] = swb.SenseBuf[sactual];
                as->actual = 0; /* scsi_Actual */
        } else {
-               int i;
-               for (i = 0; i < as->sense_len; i++)
+               for (int i = 0; i < as->sense_len; i++)
                        as->sensedata[i] = 0;
                sactual = 0;
                if (status == 0) {
index 3021d112fe808cb6a23e4991c302ede381f16250..e196dba371c44dec928d12ee4e3189d60efa9509 100644 (file)
@@ -252,7 +252,7 @@ static void to_iff_ilbm(TrapContext *ctx, HBITMAP hbmp)
        BITMAP bmp;
        int bmpw, w, h, bpp, iffbpp, tsize, size, x, y, i;
        int iffsize, bodysize;
-       uae_u32 colors[256];
+       uae_u32 colors[256] = { 0 };
        int cnt;
        uae_u8 *iff, *p;
        uae_u8 iffilbm[] = {
index 9feb3119ba3266954a1ae2fb2d990beab5b08dfa..39a9604104c2908b5ec315093287de853833484f 100644 (file)
@@ -385,7 +385,7 @@ struct my_openfile_s *my_open (const TCHAR *name, int flags)
                CreationDisposition = OPEN_ALWAYS;
        if (flags & O_WRONLY)
                DesiredAccess = GENERIC_WRITE;
-       if (flags & O_RDONLY) {
+       if (flags == O_RDONLY) {
                DesiredAccess = GENERIC_READ;
                CreationDisposition = OPEN_EXISTING;
        }
@@ -524,7 +524,7 @@ int my_getvolumeinfo (const TCHAR *root)
        if (v & FILE_ATTRIBUTE_READONLY)
        ret |= MYVOLUMEINFO_READONLY;
        */
-       if (GetVolumePathName (root, volume, sizeof (volume))) {
+       if (GetVolumePathName (root, volume, sizeof (volume) / sizeof(TCHAR))) {
                TCHAR fsname[MAX_DPATH];
                DWORD comlen;
                DWORD flags;
index b5086e2e9f1a1f5af88c3dca8bdebcd2aeb069a6..f72956f86bc0e38879ca5c288cad6644ba7b5524 100644 (file)
@@ -637,7 +637,7 @@ static void do_fillrect_frame_buffer(struct RenderInfo *ri, int X, int Y, int Wi
                Pen |= Pen << 16;
                for (lines = 0; lines < Height; lines++, dst += bpr) {
                        uae_u32 *p = (uae_u32*)dst;
-                       for (cols = 0; cols < Width & ~15; cols += 16) {
+                       for (cols = 0; cols < (Width & ~15); cols += 16) {
                                *p++ = Pen;
                                *p++ = Pen;
                                *p++ = Pen;
@@ -668,7 +668,7 @@ static void do_fillrect_frame_buffer(struct RenderInfo *ri, int X, int Y, int Wi
                        if (same) {
                                memset(p, Pen & 0xff, Width * 3);
                        } else {
-                               for (cols = 0; cols < Width & ~7; cols += 8) {
+                               for (cols = 0; cols < (Width & ~7); cols += 8) {
                                        *p++ = Pen1;
                                        *p++ = Pen2;
                                        *p++ = Pen3;
@@ -697,7 +697,7 @@ static void do_fillrect_frame_buffer(struct RenderInfo *ri, int X, int Y, int Wi
        {
                for (lines = 0; lines < Height; lines++, dst += bpr) {
                        uae_u32 *p = (uae_u32*)dst;
-                       for (cols = 0; cols < Width & ~7; cols += 8) {
+                       for (cols = 0; cols < (Width & ~7); cols += 8) {
                                *p++ = Pen;
                                *p++ = Pen;
                                *p++ = Pen;
@@ -2171,7 +2171,7 @@ static int AssignModeID (int w, int h, int *unkcnt)
        }
        (*unkcnt)++;
        write_log (_T("P96: Non-unique mode %dx%d"), w, h);
-       if (256 - (*unkcnt) == mi[i - 1].id + 1) {
+       if (i > 0 && 256 - (*unkcnt) == mi[i - 1].id + 1) {
                (*unkcnt) = 256 - 127;
                write_log(_T(" (Skipped reserved)"));
        } else if (256 - (*unkcnt) == 11) {
index 8a36878b660240f2c4decf3d00728aefa365e7a7..e89abd66d3b93f5ca51d5430252a6570304562ec 100644 (file)
@@ -73,7 +73,6 @@ int regqueryint (UAEREG *root, const TCHAR *name, int *val)
        if (inimode) {
                int ret = 0;
                TCHAR *tmp = NULL;
-               int size = sizeof tmp / sizeof(TCHAR);
                if (ini_getstring(inidata, gs(root), name, &tmp)) {
                        *val = _tstol (tmp);
                        ret = 1;
@@ -113,7 +112,6 @@ int regquerylonglong (UAEREG *root, const TCHAR *name, ULONGLONG *val)
        if (inimode) {
                int ret = 0;
                TCHAR *tmp = NULL;
-               int size = sizeof tmp / sizeof(TCHAR);
                if (ini_getstring(inidata, gs(root), name, &tmp)) {
                        *val = _tstoi64 (tmp);
                        ret = 1;
index 4c6d1c4940118c01137e4e59ad19e3f997a287d7..889d7539d018912f56f1329f9d528a164967a4d7 100644 (file)
@@ -453,7 +453,7 @@ static BOOL GetFileDialog (OPENFILENAME *opn, const GUID *guid, int mode)
        if (isfullscreen () > 0)
                guid = &fsdialogguid;
 
-       hr = -1;
+       hr = E_FAIL;
        ret = 0;
        pSHCreateItemFromParsingName = (SHCREATEITEMFROMPARSINGNAME)GetProcAddress (
                GetModuleHandle (_T("shell32.dll")), "SHCreateItemFromParsingName");
@@ -2118,10 +2118,10 @@ static struct ConfigStruct *getconfigstorefrompath (TCHAR *path, TCHAR *out, int
                if (((configstore[i]->Type == 0 || configstore[i]->Type == 3) && type == 0) || (configstore[i]->Type == type)) {
                        TCHAR path2[MAX_DPATH];
                        _tcscpy (path2, configstore[i]->Path);
-                       _tcsncat (path2, configstore[i]->Name, MAX_DPATH);
+                       _tcsncat (path2, configstore[i]->Name, MAX_DPATH - _tcslen(path2));
                        if (!_tcscmp (path, path2)) {
                                _tcscpy (out, configstore[i]->Fullpath);
-                               _tcsncat (out, configstore[i]->Name, MAX_DPATH);
+                               _tcsncat (out, configstore[i]->Name, MAX_DPATH - _tcslen(out));
                                return configstore[i];
                        }
                }
@@ -3317,8 +3317,8 @@ static void GetConfigPath (TCHAR *path, struct ConfigStruct *parent, int noroot)
        }
        if (parent) {
                GetConfigPath (path, parent->Parent, noroot);
-               _tcsncat (path, parent->Name, MAX_DPATH);
-               _tcsncat (path, _T("\\"), MAX_DPATH);
+               _tcsncat (path, parent->Name, MAX_DPATH - _tcslen(path));
+               _tcsncat (path, _T("\\"), MAX_DPATH - _tcslen(path));
        }
 }
 
@@ -3347,7 +3347,7 @@ static void FreeConfigStore (void)
 static void getconfigcache (TCHAR *dst, const TCHAR *path)
 {
        _tcscpy (dst, path);
-       _tcsncat (dst, _T("configuration.cache"), MAX_DPATH);
+       _tcsncat (dst, _T("configuration.cache"), MAX_DPATH - _tcslen(dst));
 }
 
 static void deleteconfigcache(void)
@@ -3718,7 +3718,7 @@ static struct ConfigStruct *GetConfigs (struct ConfigStruct *configparent, int u
        GetConfigPath (path, configparent, FALSE);
        GetConfigPath (shortpath, configparent, TRUE);
        _tcscpy (path2, path);
-       _tcsncat (path2, _T("*.*"), MAX_DPATH);
+       _tcsncat (path2, _T("*.*"), MAX_DPATH - _tcslen(path2));
 
        if (*level == 0) {
                if (flushcache) {
@@ -3776,7 +3776,7 @@ static struct ConfigStruct *GetConfigs (struct ConfigStruct *configparent, int u
                                TCHAR path3[MAX_DPATH];
                                if (_tcslen (find_data.cFileName) > 4 && !strcasecmp (find_data.cFileName + _tcslen (find_data.cFileName) - 4, _T(".uae"))) {
                                        _tcscpy (path3, path);
-                                       _tcsncat (path3, find_data.cFileName, MAX_DPATH);
+                                       _tcsncat (path3, find_data.cFileName, MAX_DPATH - _tcslen(path3));
                                        config->Artpath[0] = 0;
                                        struct uae_prefs *p = cfgfile_open(path3, &config->Type);
                                        if (p) {
@@ -3867,7 +3867,7 @@ static TCHAR *HandleConfiguration (HWND hDlg, int flag, struct ConfigStruct *con
        } else {
                fetch_configurationpath (path, sizeof (path) / sizeof (TCHAR));
        }
-       _tcsncat (path, name, MAX_DPATH);
+       _tcsncat (path, name, MAX_DPATH - _tcslen(path));
        _tcscpy (full_path, path);
        switch (flag)
        {
@@ -5212,7 +5212,7 @@ static void InitializeConfig (HWND hDlg, struct ConfigStruct *config)
                        if ((j == 0 && cs->Type == CONFIG_TYPE_HOST) || (j == 1 && cs->Type == CONFIG_TYPE_HARDWARE)) {
                                TCHAR tmp2[MAX_DPATH];
                                _tcscpy (tmp2, configstore[i]->Path);
-                               _tcsncat (tmp2, configstore[i]->Name, MAX_DPATH);
+                               _tcsncat (tmp2, configstore[i]->Name, MAX_DPATH - _tcslen(tmp2));
                                SendDlgItemMessage (hDlg, IDC_CONFIGLINK, CB_ADDSTRING, 0, (LPARAM)tmp2);
                                if (config && (!_tcsicmp (tmp2, config->HardwareLink) || !_tcsicmp (tmp2, config->HostLink)))
                                        idx2 = idx1;
@@ -5262,7 +5262,7 @@ static void ConfigToRegistry (struct ConfigStruct *config, int type)
        if (config) {
                TCHAR path[MAX_DPATH];
                _tcscpy (path, config->Path);
-               _tcsncat (path, config->Name, MAX_DPATH);
+               _tcsncat (path, config->Name, MAX_DPATH - _tcslen(path));
                regsetstr (NULL, configreg[type], path);
        }
 }
@@ -6440,7 +6440,7 @@ static void init_quickstartdlg (HWND hDlg)
        for (i = 0; i < configstoresize; i++) {
                if (configstore[i]->Type == CONFIG_TYPE_HOST) {
                        _tcscpy (tmp2, configstore[i]->Path);
-                       _tcsncat (tmp2, configstore[i]->Name, MAX_DPATH);
+                       _tcsncat (tmp2, configstore[i]->Name, MAX_DPATH - _tcslen(tmp2));
                        if (!_tcscmp (tmp2, hostconf))
                                idx = j;
                        SendDlgItemMessage (hDlg, IDC_QUICKSTART_HOSTCONFIG, CB_ADDSTRING, 0, (LPARAM)tmp2);
@@ -11828,6 +11828,7 @@ static void values_from_cpudlg (HWND hDlg)
                        workprefs.cpu_clock_multiplier = (1 << 8) << idx;
                } else {
                        TCHAR txt[20];
+                       txt[0] = 0;
                        SendDlgItemMessage (hDlg, IDC_CPU_FREQUENCY2, WM_GETTEXT, (WPARAM)sizeof (txt) / sizeof (TCHAR), (LPARAM)txt);
                        workprefs.cpu_clock_multiplier = 0;
                        workprefs.cpu_frequency = (int)(_tstof (txt) * 1000000.0);
@@ -12243,6 +12244,7 @@ static void values_from_sounddlg (HWND hDlg)
        if (idx >= 0) {
                workprefs.sound_freq = soundfreqs[idx];
        } else {
+               txt[0] = 0;
                SendDlgItemMessage (hDlg, IDC_SOUNDFREQ, WM_GETTEXT, (WPARAM)sizeof (txt) / sizeof (TCHAR), (LPARAM)txt);
                workprefs.sound_freq = _tstol (txt);
        }
@@ -13039,7 +13041,7 @@ static void updatehdfinfo (HWND hDlg, bool force, bool defaults)
                                bsize = hfd.virtsize;
                                current_hfdlg.size = hfd.virtsize;
                                if (!memcmp (id, "RDSK", 4) || !memcmp (id, "CDSK", 4)) {
-                                       int blocksize = (id[16] << 24)  | (id[17] << 16) | (id[18] << 8) | (id[19] << 0);
+                                       blocksize = (id[16] << 24)  | (id[17] << 16) | (id[18] << 8) | (id[19] << 0);
                                        break;
                                }
                        }
@@ -17103,7 +17105,7 @@ static void fillinputmapadd (HWND hDlg)
                for (int k = 0; axistable[k] >= 0; k += 3) {
                        if (evt == axistable[k] || evt == axistable[k + 1] || evt == axistable[k + 2]) {
                                for (int l = 0; inputlist[l] >= 0; l++) {
-                                       if (inputlist[l] == axistable[k] || inputlist[l] == axistable[k + 1] || inputlist[l] == axistable[k + 1]) {
+                                       if (inputlist[l] == axistable[k] || inputlist[l] == axistable[k + 1] || inputlist[l] == axistable[k + 2]) {
                                                ignore = true;
                                        }
                                }
@@ -18020,6 +18022,7 @@ static float getfiltermult (HWND hDlg, DWORD dlg)
 
        if (v != CB_ERR)
                return filtermults[v];
+       tmp[0] = 0;
        SendDlgItemMessage (hDlg, dlg, WM_GETTEXT, (WPARAM)sizeof tmp / sizeof (TCHAR), (LPARAM)tmp);
        if (!_tcsicmp (tmp, _T("FS")))
                return 0.0f;
@@ -19151,7 +19154,7 @@ static INT_PTR CALLBACK AVIOutputDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LP
                                        AVIOutput_End ();
                                if(ischecked (hDlg, IDC_AVIOUTPUT_VIDEO)) {
                                        avioutput_video = AVIOutput_ChooseVideoCodec (hDlg, tmp, sizeof tmp / sizeof (TCHAR));
-                                       if (avioutput_audio = AVIAUDIO_WAV)
+                                       if (avioutput_audio == AVIAUDIO_WAV)
                                                avioutput_audio = 0;
                                        enable_for_avioutputdlg (hDlg);
                                } else {
@@ -19428,7 +19431,7 @@ static BOOL CALLBACK childenumproc (HWND hwnd, LPARAM lParam)
                *p++ = 0;
                *p++ = 0;
                if (p[0] == ' ')
-                       *p++;
+                       *p++ = 0;
                tmp[_tcslen (tmp) - 1] = 0;
                SendMessage (hwnd, WM_SETTEXT, 0, (LPARAM)tmp);
                ti.cbSize = sizeof (TOOLINFO);
@@ -20075,7 +20078,7 @@ int dragdrop (HWND hDlg, HDROP hd, struct uae_prefs *prefs, int currentpage)
                        } else {
                                rd = scan_arcadia_rom (file, 0);
                                if (rd) {
-                                       if (rd->type == ROMTYPE_ARCADIABIOS || ROMTYPE_ALG)
+                                       if (rd->type == ROMTYPE_ARCADIABIOS || rd->type == ROMTYPE_ALG)
                                                _tcscpy (prefs->romextfile, file);
                                        else if (rd->type == ROMTYPE_ARCADIAGAME)
                                                _tcscpy (prefs->cartfile, file);
diff --git a/pci.cpp b/pci.cpp
index 141e59a48612c328f8cf1de8a711177e730310fe..bcd6ceeba1e74f4657727fd273fd4747722da5e7 100644 (file)
--- a/pci.cpp
+++ b/pci.cpp
@@ -1277,7 +1277,7 @@ static void pci_dump_region(addrbank *bank, uaecptr *start, uaecptr *end)
        *start = 0;
        *end = 0;
        for (int i = 0; i < 65536 + 1; i++) {
-               addrbank *a = mem_banks[i];
+               addrbank *a = i < 65536 ? mem_banks[i] : NULL;
                if (*start == 0 && a == bank)
                        *start = i << 16;
                if (*start && a != bank) {
index 35bf0b40b8480c0c58976bf4b62854461c82e4e8..62d5fd089e56546950cee214bbe5412eeeaba9b7 100644 (file)
@@ -942,7 +942,7 @@ struct romdata *getarcadiarombyname (const TCHAR *name)
 {
        int i;
        for (i = 0; roms[i].name; i++) {
-               if (roms[i].group == 0 && (roms[i].type == ROMTYPE_ARCADIAGAME || roms[i].type == ROMTYPE_ARCADIAGAME)) {
+               if (roms[i].group == 0 && (roms[i].type == ROMTYPE_ARCADIABIOS || roms[i].type == ROMTYPE_ARCADIAGAME)) {
                        const TCHAR *p = roms[i].name;
                        p = p + _tcslen (p) + 1;
                        if (_tcslen (name) >= _tcslen (p) + 4) {
diff --git a/rtc.cpp b/rtc.cpp
index bc4578a33baffc37e8e21a10114036c3fd8865cb..64d53113d67b1d10d8ec769696cb3d4b18999f38 100644 (file)
--- a/rtc.cpp
+++ b/rtc.cpp
@@ -13,7 +13,7 @@
 
 uae_u8 get_clock_msm(struct rtc_msm_data *data, int addr, struct tm *ct)
 {
-       uae_u8 v;
+       uae_u8 v = 0;
        int year;
 
        if (!ct) {
index ae369db2b72e06c064a77025c508774286d81866..fad50b9314e01398a6996d4d49ee97ab2c3d109d 100644 (file)
@@ -1287,7 +1287,7 @@ static bool audio_state_sndboard_toccata(int streamid)
                if ((data->fifo_half & STATUS_FIFO_PLAY) && (data->toccata_status & STATUS_PLAY_INTENA) && (data->toccata_status & STATUS_FIFO_PLAY)) {
                        data->toccata_irq |= STATUS_READ_PLAY_HALF;
                }
-               if ((data->fifo_half & STATUS_FIFO_RECORD) && (data->toccata_status & STATUS_FIFO_RECORD) && (data->toccata_status & STATUS_FIFO_RECORD)) {
+               if ((data->fifo_half & STATUS_FIFO_RECORD) && (data->toccata_status & STATUS_RECORD_INTENA) && (data->toccata_status & STATUS_FIFO_RECORD)) {
                        data->toccata_irq |= STATUS_READ_RECORD_HALF;
                }
                if (old != data->toccata_irq) {
index faeec5ce45c87a6239e2eef1583a4da882b9a6b0..8f861ae1d72972d27434f40e86e14ae4898010f2 100644 (file)
@@ -84,7 +84,7 @@ static void parsemessage(TCHAR *in, struct uae_prefs *p, TCHAR *out, int outsize
                for (;;) {
                        int ret;
                        tmpout[0] = 0;
-                       ret = cfgfile_modify (index, in, _tcslen (in), tmpout, sizeof (tmpout) * sizeof (TCHAR));
+                       ret = cfgfile_modify (index, in, _tcslen (in), tmpout, sizeof (tmpout) / sizeof (TCHAR));
                        index++;
                        if (_tcslen (tmpout) > 0) {
                                if (_tcslen (out) == 0)
index 805381c6bf889a058d42c21937cd583287702b71..5fe73af023a963db46ada0c687aa33dc9e198fcb 100644 (file)
--- a/zfile.cpp
+++ b/zfile.cpp
@@ -606,6 +606,7 @@ static struct zfile *zfile_gunzip (struct zfile *z, int *retcode)
        zs.next_out = z2->data;
        zs.avail_out = size;
        first = 1;
+       ret = Z_STREAM_ERROR;
        do {
                zs.next_in = buffer;
                zs.avail_in = zfile_fread (buffer, 1, sizeof (buffer), z);
index 792e997b098bf4892e87a6720ab2f25cf686dd89..c21b7a5d0f1f35f1dac248517357901b6d8bed77 100644 (file)
@@ -984,7 +984,7 @@ struct zvolume *archive_directory_arcacc (struct zfile *z, unsigned int id)
 
 static struct zfile *archive_access_arcacc (struct znode *zn)
 {
-       struct zfile *zf;
+       struct zfile *zf = NULL;
        struct zfile *z = zn->volume->archive;
        int status, id_r, id_w;
        aaHandle ah;