From 189c83566c24a5df4c4cdbc1d3b8aac62b7c1049 Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Fri, 29 Apr 2022 21:17:21 +0300 Subject: [PATCH] Warning fixes. --- archivers/chd/astring.cpp | 2 +- archivers/lha/crcio.cpp | 2 +- archivers/lha/header.cpp | 18 +++++++++--------- archivers/lha/huf.cpp | 4 ++-- archivers/lha/shuf.cpp | 2 +- archivers/lha/uae_lha.cpp | 2 +- archivers/lzx/unlzx.cpp | 16 ++++++++-------- archivers/mp2/kjmp2.cpp | 2 +- archivers/zip/ioapi.cpp | 2 +- archivers/zip/unzip.cpp | 2 +- genblitter.cpp | 30 ++++++++++++++++++------------ mame/mameglue.h | 2 ++ moduleripper.cpp | 4 ++-- 13 files changed, 48 insertions(+), 40 deletions(-) diff --git a/archivers/chd/astring.cpp b/archivers/chd/astring.cpp index e04dbd2e..1139892e 100644 --- a/archivers/chd/astring.cpp +++ b/archivers/chd/astring.cpp @@ -53,7 +53,7 @@ bool astring::ensure_room(int length) // swap in the new buffer and free the old one char *oldbuf = (m_text == m_smallbuf) ? NULL : m_text; m_text = strcpy(newbuf, m_text); - m_len = strlen(m_text); + m_len = uaestrlen(m_text); m_alloclen = alloclen; delete[] oldbuf; diff --git a/archivers/lha/crcio.cpp b/archivers/lha/crcio.cpp index 3d1b2672..70a33f52 100644 --- a/archivers/lha/crcio.cpp +++ b/archivers/lha/crcio.cpp @@ -152,7 +152,7 @@ putbits(n, x) /* Write rightmost n bits of x */ int fread_crc(unsigned char *p, int n, struct zfile *fp) { - n = zfile_fread(p, 1, n, fp); + n = (int)zfile_fread(p, 1, n, fp); calccrc(p, n); return n; diff --git a/archivers/lha/header.cpp b/archivers/lha/header.cpp index 69def200..7cb93a34 100644 --- a/archivers/lha/header.cpp +++ b/archivers/lha/header.cpp @@ -18,7 +18,7 @@ static char *get_ptr; /* ------------------------------------------------------------------------ */ int calc_sum(char *p, int len) { - register int sum; + int sum; for (sum = 0; len; len--) sum += *p++; @@ -67,7 +67,7 @@ static void put_longword(long v) /* ------------------------------------------------------------------------ */ static void msdos_to_unix_filename(char *name, int len) { - register int i; + int i; #ifdef MULTIBYTE_CHAR for (i = 0; i < len; i++) { @@ -92,7 +92,7 @@ static void msdos_to_unix_filename(char *name, int len) /* ------------------------------------------------------------------------ */ static void generic_to_unix_filename(char *name, int len) { - register int i; + int i; boolean lower_case_used = FALSE; #ifdef MULTIBYTE_CHAR @@ -133,7 +133,7 @@ static void generic_to_unix_filename(char *name, int len) static void macos_to_unix_filename(char *name, int len) { - register int i; + int i; for (i = 0; i < len; i++) { if (name[i] == ':') @@ -147,7 +147,7 @@ macos_to_unix_filename(char *name, int len) static void unix_to_generic_filename(char *name, int len) { - register int i; + int i; for (i = 0; i < len; i++) { if (name[i] == '/') @@ -539,7 +539,7 @@ boolean get_header(struct zfile *fp, LzHeader *hdr) hdr->extend_type == EXTEND_HUMAN || hdr->extend_type == EXTEND_AMIGAOS || hdr->extend_type == EXTEND_GENERIC) - hdr->attribute = get_word (); + hdr->attribute = (unsigned char)get_word (); break; case 0x50: /* @@ -585,8 +585,8 @@ boolean get_header(struct zfile *fp, LzHeader *hdr) } } if (hdr->header_level != 2 && get_ptr - ptr != 2) { - hdr->packed_size -= get_ptr - ptr - 2; - hdr->header_size += get_ptr - ptr - 2; + hdr->packed_size -= (long)(get_ptr - ptr - 2); + hdr->header_size += (unsigned char)(get_ptr - ptr - 2); } } @@ -654,7 +654,7 @@ void init_header(char *name, struct stat *v_stat, LzHeader *hdr) hdr->attribute = GENERIC_ATTRIBUTE; hdr->header_level = header_level; strcpy(hdr->name, name); - len = strlen(name); + len = uaestrlen(name); hdr->crc = 0x0000; hdr->extend_type = EXTEND_UNIX; hdr->unix_last_modified_stamp = v_stat->st_mtime; diff --git a/archivers/lha/huf.cpp b/archivers/lha/huf.cpp index dec8868c..cb996f4e 100644 --- a/archivers/lha/huf.cpp +++ b/archivers/lha/huf.cpp @@ -317,9 +317,9 @@ static void read_pt_len(short nn, short nbit, short i_special) { int i, c, n; - n = getbits(nbit); + n = getbits((unsigned char)nbit); if (n == 0) { - c = getbits(nbit); + c = getbits((unsigned char)nbit); for (i = 0; i < nn; i++) pt_len[i] = 0; for (i = 0; i < 256; i++) diff --git a/archivers/lha/shuf.cpp b/archivers/lha/shuf.cpp index e9102cfc..8b7ef3e2 100644 --- a/archivers/lha/shuf.cpp +++ b/archivers/lha/shuf.cpp @@ -113,7 +113,7 @@ static void read_tree_p(void) i = 0; while (i < NP) { - pt_len[i] = getbits(LENFIELD); + pt_len[i] = (unsigned char)getbits(LENFIELD); if (++i == 3 && pt_len[0] == 1 && pt_len[1] == 1 && pt_len[2] == 1) { #ifdef SUPPORT_LH7 c = getbits(MAX_DICBIT - 7); diff --git a/archivers/lha/uae_lha.cpp b/archivers/lha/uae_lha.cpp index acc9d64f..c1aa2f27 100644 --- a/archivers/lha/uae_lha.cpp +++ b/archivers/lha/uae_lha.cpp @@ -84,7 +84,7 @@ struct zfile *archive_access_lha (struct znode *zn) lhinterface.dicbit = 13; /* method + 8; -lh5- */ lhinterface.infile = zf; lhinterface.outfile = out; - lhinterface.original = zn->size; + lhinterface.original = (unsigned long)zn->size; lhinterface.packed = zn->packedsize; switch (zn->method) { diff --git a/archivers/lzx/unlzx.cpp b/archivers/lzx/unlzx.cpp index f32d84f8..7b5abb05 100644 --- a/archivers/lzx/unlzx.cpp +++ b/archivers/lzx/unlzx.cpp @@ -493,13 +493,13 @@ static int read_literal_table(struct lzxdata *d) } symbol = table_four[d->literal_len[pos] + 17 - symbol]; while((pos < max_symbol) && (count--)) - d->literal_len[pos++] = symbol; + d->literal_len[pos++] = (unsigned char)symbol; break; } default: { symbol = table_four[d->literal_len[pos] + 17 - symbol]; - d->literal_len[pos++] = symbol; + d->literal_len[pos++] = (unsigned char)symbol; break; } } @@ -576,7 +576,7 @@ static void decrunch(struct lzxdata *d) } if(symbol < 256) { - *d->destination++ = symbol; + *d->destination++ = (unsigned char)symbol; } else { @@ -656,12 +656,12 @@ struct zfile *archive_access_lzx (struct znode *zn) if (!zt || zt->offset != 0) break; znfirst = zt; - unpsize += znfirst->size; + unpsize += (unsigned int)znfirst->size; } /* find last file in compressed block */ znlast = zn; while (znlast) { - unpsize += znlast->size; + unpsize += (unsigned int)znlast->size; if (znlast->offset != 0) break; znlast = znlast->next; @@ -765,7 +765,7 @@ struct zvolume *archive_directory_lzx (struct zfile *in_file) do { abort = 1; /* assume an error */ - actual = zfile_fread(archive_header, 1, 31, in_file); + actual = (int)zfile_fread(archive_header, 1, 31, in_file); if(!zfile_ferror(in_file)) { if(actual) /* 0 is normal and means EOF */ @@ -780,7 +780,7 @@ struct zvolume *archive_directory_lzx (struct zfile *in_file) archive_header[26] = 0; crc_calc(&d, archive_header, 31); temp = archive_header[30]; /* filename length */ - actual = zfile_fread(header_filename, 1, temp, in_file); + actual = (int)zfile_fread(header_filename, 1, temp, in_file); if(!zfile_ferror(in_file)) { if(actual == temp) @@ -788,7 +788,7 @@ struct zvolume *archive_directory_lzx (struct zfile *in_file) header_filename[temp] = 0; crc_calc(&d, (unsigned char*)header_filename, temp); temp = archive_header[14]; /* comment length */ - actual = zfile_fread(header_comment, 1, temp, in_file); + actual = (int)zfile_fread(header_comment, 1, temp, in_file); if(!zfile_ferror(in_file)) { if(actual == temp) diff --git a/archivers/mp2/kjmp2.cpp b/archivers/mp2/kjmp2.cpp index bd943fd4..6c8d0cfa 100644 --- a/archivers/mp2/kjmp2.cpp +++ b/archivers/mp2/kjmp2.cpp @@ -283,7 +283,7 @@ static const struct quantizer_spec* FASTCALL read_allocation(int sb, int b2_tabl static void FASTCALL read_samples(const struct quantizer_spec *q, int scalefactor, int *sample) { int idx, adj, scale; - register int val; + int val; if (!q) { // no bits allocated for this subband sample[0] = sample[1] = sample[2] = 0; diff --git a/archivers/zip/ioapi.cpp b/archivers/zip/ioapi.cpp index 9734d49a..3b17b245 100644 --- a/archivers/zip/ioapi.cpp +++ b/archivers/zip/ioapi.cpp @@ -205,7 +205,7 @@ static long ZCALLBACK fseek64_file_func (voidpf opaque, voidpf stream, ZPOS64_T } ret = 0; - if(FSEEKO_FUNC((FILE *)stream, offset, fseek_origin) != 0) + if(FSEEKO_FUNC((FILE *)stream, (long)offset, fseek_origin) != 0) ret = -1; return ret; diff --git a/archivers/zip/unzip.cpp b/archivers/zip/unzip.cpp index 81281c7e..b9d77682 100644 --- a/archivers/zip/unzip.cpp +++ b/archivers/zip/unzip.cpp @@ -138,7 +138,7 @@ typedef struct local int unzlocal_getByte(struct zfile *fin,int *pi) { unsigned char c; - int err = zfile_fread(&c, 1, 1, fin); + int err = (int)zfile_fread(&c, 1, 1, fin); if (err==1) { *pi = (int)c; diff --git a/genblitter.cpp b/genblitter.cpp index 49c93e6f..81678025 100644 --- a/genblitter.cpp +++ b/genblitter.cpp @@ -58,16 +58,19 @@ static void generate_func(void) printf("uae_u32 dstd=0;\n"); printf("uaecptr dstp = 0;\n"); printf("for (j = 0; j < b->vblitsize; j++) {\n"); - printf("\tfor (i = 0; i < b->hblitsize; i++) {\n\t\tuae_u32 bltadat, srca;\n\n"); - if (c_is_on) printf("\t\tif (ptc) { srcc = chipmem_wget_indirect (ptc); ptc += 2; }\n"); - if (b_is_on) printf("\t\tif (ptb) {\n\t\t\tuae_u32 bltbdat = b->bltbdat = chipmem_wget_indirect (ptb); ptb += 2;\n"); + printf("\tfor (i = 0; i < b->hblitsize; i++) {\n"); + if (a_is_on) { + printf("\t\tuae_u32 bltadat, srca;\n"); + } + if (c_is_on) printf("\t\tif (ptc) { srcc = chipmem_wget_indirect(ptc); ptc += 2; }\n"); + if (b_is_on) printf("\t\tif (ptb) {\n\t\t\tuae_u32 bltbdat = b->bltbdat = chipmem_wget_indirect(ptb); ptb += 2;\n"); if (b_is_on) printf("\t\t\tsrcb = (((uae_u32)b->bltbold << 16) | bltbdat) >> bshift;\n"); if (b_is_on) printf("\t\t\tb->bltbold = bltbdat;\n\t\t}\n"); - if (a_is_on) printf("\t\tif (pta) { bltadat = b->bltadat = chipmem_wget_indirect (pta); pta += 2; } else { bltadat = b->bltadat; }\n"); + if (a_is_on) printf("\t\tif (pta) { bltadat = b->bltadat = chipmem_wget_indirect(pta); pta += 2; } else { bltadat = b->bltadat; }\n"); if (a_is_on) printf("\t\tbltadat &= blit_masktable[i];\n"); if (a_is_on) printf("\t\tsrca = (((uae_u32)b->bltaold << 16) | bltadat) >> ashift;\n"); if (a_is_on) printf("\t\tb->bltaold = bltadat;\n"); - printf("\t\tif (dstp) chipmem_wput_indirect (dstp, dstd);\n"); + printf("\t\tif (dstp) chipmem_wput_indirect(dstp, dstd);\n"); printf("\t\tdstd = (%s) & 0xFFFF;\n", blitops[blttbl[i]].s); printf("\t\ttotald |= dstd;\n"); printf("\t\tif (ptd) { dstp = ptd; ptd += 2; }\n"); @@ -79,7 +82,7 @@ static void generate_func(void) printf("}\n"); if (b_is_on) printf("b->bltbhold = srcb;\n"); if (c_is_on) printf("b->bltcdat = srcc;\n"); - printf("\t\tif (dstp) chipmem_wput_indirect (dstp, dstd);\n"); + printf("\t\tif (dstp) chipmem_wput_indirect(dstp, dstd);\n"); printf("if (totald != 0) b->blitzero = 0;\n"); printf("}\n"); @@ -94,16 +97,19 @@ static void generate_func(void) printf("uae_u32 dstd = 0;\n"); printf("uaecptr dstp = 0;\n"); printf("for (j = 0; j < b->vblitsize; j++) {\n"); - printf("\tfor (i = 0; i < b->hblitsize; i++) {\n\t\tuae_u32 bltadat, srca;\n"); - if (c_is_on) printf("\t\tif (ptc) { srcc = chipmem_wget_indirect (ptc); ptc -= 2; }\n"); - if (b_is_on) printf("\t\tif (ptb) {\n\t\t\tuae_u32 bltbdat = b->bltbdat = chipmem_wget_indirect (ptb); ptb -= 2;\n"); + printf("\tfor (i = 0; i < b->hblitsize; i++) {\n"); + if (a_is_on) { + printf("\t\tuae_u32 bltadat, srca;\n"); + } + if (c_is_on) printf("\t\tif (ptc) { srcc = chipmem_wget_indirect(ptc); ptc -= 2; }\n"); + if (b_is_on) printf("\t\tif (ptb) {\n\t\t\tuae_u32 bltbdat = b->bltbdat = chipmem_wget_indirect(ptb); ptb -= 2;\n"); if (b_is_on) printf("\t\t\tsrcb = ((bltbdat << 16) | b->bltbold) >> bshift;\n"); if (b_is_on) printf("\t\t\tb->bltbold = bltbdat;\n\t\t}\n"); - if (a_is_on) printf("\t\tif (pta) { bltadat = b->bltadat = chipmem_wget_indirect (pta); pta -= 2; } else { bltadat = b->bltadat; }\n"); + if (a_is_on) printf("\t\tif (pta) { bltadat = b->bltadat = chipmem_wget_indirect(pta); pta -= 2; } else { bltadat = b->bltadat; }\n"); if (a_is_on) printf("\t\tbltadat &= blit_masktable[i];\n"); if (a_is_on) printf("\t\tsrca = (((uae_u32)bltadat << 16) | b->bltaold) >> ashift;\n"); if (a_is_on) printf("\t\tb->bltaold = bltadat;\n"); - printf("\t\tif (dstp) chipmem_wput_indirect (dstp, dstd);\n"); + printf("\t\tif (dstp) chipmem_wput_indirect(dstp, dstd);\n"); printf("\t\tdstd = (%s) & 0xFFFF;\n", blitops[blttbl[i]].s); printf("\t\ttotald |= dstd;\n"); printf("\t\tif (ptd) { dstp = ptd; ptd -= 2; }\n"); @@ -115,7 +121,7 @@ static void generate_func(void) printf("}\n"); if (b_is_on) printf("b->bltbhold = srcb;\n"); if (c_is_on) printf("b->bltcdat = srcc;\n"); - printf("\t\tif (dstp) chipmem_wput_indirect (dstp, dstd);\n"); + printf("\t\tif (dstp) chipmem_wput_indirect(dstp, dstd);\n"); printf("if (totald != 0) b->blitzero = 0;\n"); printf("}\n"); } diff --git a/mame/mameglue.h b/mame/mameglue.h index 96621e2f..988845a9 100644 --- a/mame/mameglue.h +++ b/mame/mameglue.h @@ -25,7 +25,9 @@ extern void activate_debugger(void); typedef unsigned long offs_t; #define FALSE 0 +#ifndef TRUE #define TRUE 1 +#endif #define TIMER_CALLBACK_MEMBER(x) int x(void *p, int param, int param2) extern void standard_irq_callback(int); diff --git a/moduleripper.cpp b/moduleripper.cpp index cdf926ba..a14af12b 100644 --- a/moduleripper.cpp +++ b/moduleripper.cpp @@ -91,7 +91,7 @@ static void namesplit(TCHAR *s) { int l; - l = _tcslen(s) - 1; + l = uaetcslen(s) - 1; while (l >= 0) { if (s[l] == '.') s[l] = 0; @@ -102,7 +102,7 @@ static void namesplit(TCHAR *s) l--; } if (l > 0) - memmove(s, s + l, (_tcslen(s + l) + 1) * sizeof (TCHAR)); + memmove(s, s + l, (uaetcslen(s + l) + 1) * sizeof (TCHAR)); } static void moduleripper_filename(const char *aname, TCHAR *out, bool fullpath) -- 2.47.3