From: Toni Wilen Date: Mon, 5 Mar 2018 19:25:01 +0000 (+0200) Subject: Fixed some code analyzer warnings. X-Git-Tag: 4000~156 X-Git-Url: https://git.unchartedbackwaters.co.uk/w/?a=commitdiff_plain;h=7a189c636f4799ec4db984c58542620d1a8e89ce;p=francis%2Fwinuae.git Fixed some code analyzer warnings. --- diff --git a/a2065.cpp b/a2065.cpp index 03a4607d..66128ed5 100644 --- 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) { diff --git a/a2091.cpp b/a2091.cpp index fd15d4b6..200d6428 100644 --- 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); diff --git a/akiko.cpp b/akiko.cpp index b68f99fa..d4dbb717 100644 --- 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++; } diff --git a/arcadia.cpp b/arcadia.cpp index b44a9c63..49890dfe 100644 --- a/arcadia.cpp +++ b/arcadia.cpp @@ -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)); } diff --git a/cd32_fmv.cpp b/cd32_fmv.cpp index c8253ef9..876a82b8 100644 --- a/cd32_fmv.cpp +++ b/cd32_fmv.cpp @@ -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; diff --git a/cfgfile.cpp b/cfgfile.cpp index bd350f8b..596a4760 100644 --- a/cfgfile.cpp +++ b/cfgfile.cpp @@ -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; diff --git a/custom.cpp b/custom.cpp index bcad358c..bcd9e920 100644 --- a/custom.cpp +++ b/custom.cpp @@ -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 diff --git a/epsonprinter.cpp b/epsonprinter.cpp index 84dd2cc2..15882b3e 100644 --- a/epsonprinter.cpp +++ b/epsonprinter.cpp @@ -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)) { diff --git a/inputdevice.cpp b/inputdevice.cpp index f780fe4c..0b13f134 100644 --- a/inputdevice.cpp +++ b/inputdevice.cpp @@ -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; } diff --git a/memory.cpp b/memory.cpp index 74c3c76f..21c2fd5d 100644 --- a/memory.cpp +++ b/memory.cpp @@ -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; } diff --git a/ncr_scsi.cpp b/ncr_scsi.cpp index 27ad170d..efd1534d 100644 --- a/ncr_scsi.cpp +++ b/ncr_scsi.cpp @@ -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 diff --git a/newcpu.cpp b/newcpu.cpp index ddc78c90..0d11f724 100644 --- a/newcpu.cpp +++ b/newcpu.cpp @@ -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 */ diff --git a/od-win32/blkdev_win32_ioctl.cpp b/od-win32/blkdev_win32_ioctl.cpp index df5473d2..7573b468 100644 --- a/od-win32/blkdev_win32_ioctl.cpp +++ b/od-win32/blkdev_win32_ioctl.cpp @@ -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; } diff --git a/od-win32/blkdev_win32_spti.cpp b/od-win32/blkdev_win32_spti.cpp index e87cbb70..f8259824 100644 --- a/od-win32/blkdev_win32_spti.cpp +++ b/od-win32/blkdev_win32_spti.cpp @@ -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) { diff --git a/od-win32/clipboard_win32.cpp b/od-win32/clipboard_win32.cpp index 3021d112..e196dba3 100644 --- a/od-win32/clipboard_win32.cpp +++ b/od-win32/clipboard_win32.cpp @@ -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[] = { diff --git a/od-win32/fsdb_mywin32.cpp b/od-win32/fsdb_mywin32.cpp index 9feb3119..39a96041 100644 --- a/od-win32/fsdb_mywin32.cpp +++ b/od-win32/fsdb_mywin32.cpp @@ -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; diff --git a/od-win32/picasso96_win.cpp b/od-win32/picasso96_win.cpp index b5086e2e..f72956f8 100644 --- a/od-win32/picasso96_win.cpp +++ b/od-win32/picasso96_win.cpp @@ -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) { diff --git a/od-win32/registry.cpp b/od-win32/registry.cpp index 8a36878b..e89abd66 100644 --- a/od-win32/registry.cpp +++ b/od-win32/registry.cpp @@ -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; diff --git a/od-win32/win32gui.cpp b/od-win32/win32gui.cpp index 4c6d1c49..889d7539 100644 --- a/od-win32/win32gui.cpp +++ b/od-win32/win32gui.cpp @@ -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 141e59a4..bcd6ceeb 100644 --- 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) { diff --git a/rommgr.cpp b/rommgr.cpp index 35bf0b40..62d5fd08 100644 --- a/rommgr.cpp +++ b/rommgr.cpp @@ -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 bc4578a3..64d53113 100644 --- 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) { diff --git a/sndboard.cpp b/sndboard.cpp index ae369db2..fad50b93 100644 --- a/sndboard.cpp +++ b/sndboard.cpp @@ -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) { diff --git a/uaeipc.cpp b/uaeipc.cpp index faeec5ce..8f861ae1 100644 --- a/uaeipc.cpp +++ b/uaeipc.cpp @@ -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) diff --git a/zfile.cpp b/zfile.cpp index 805381c6..5fe73af0 100644 --- 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); diff --git a/zfile_archive.cpp b/zfile_archive.cpp index 792e997b..c21b7a5d 100644 --- a/zfile_archive.cpp +++ b/zfile_archive.cpp @@ -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;