Fix -Wsign-compare warnings

This commit is contained in:
Allofich 2021-09-18 21:12:22 +09:00
parent 9e00ce1f4c
commit e4c17e8f6a
7 changed files with 28 additions and 24 deletions

View File

@ -73,7 +73,7 @@ typedef struct Render_t {
} src;
struct {
int count;
int max;
unsigned int max;
Bitu index;
uint8_t hadSkip[RENDER_SKIP_CACHE];
} frameskip;
@ -127,7 +127,7 @@ typedef struct {
int pointsize;
int height; // height of character cell
int width; // width
int cursor;
unsigned int cursor;
int lins; // number of lines 24-60
int cols; // number of columns 80-160
bool fullScrn; // in fake fullscreen

View File

@ -1178,7 +1178,7 @@ bool CDROM_Interface_Image::LoadChdFile(char* chdfile)
track.skip = 0;
currPregap = 0;
prestart = -1;
for (int i = 0; i < tokens.size(); i++) {
for (unsigned int i = 0; i < tokens.size(); i++) {
// "TRACK:1" > "TRACK" "1"
std::vector<string> track_meta = split_string_to_list(tokens[i], ":");
std::string key = track_meta[0];

View File

@ -3743,8 +3743,9 @@ bool setColors(const char *colorArray, int n) {
}
bool readTTFStyle(unsigned long& size, void*& font, FILE * fh) {
size = ftell(fh);
if (size != -1L) {
long pos = ftell(fh);
if (pos != -1L) {
size = pos;
font = malloc((size_t)size);
if (font && !fseek(fh, 0, SEEK_SET) && fread(font, 1, (size_t)size, fh) == (size_t)size) {
fclose(fh);
@ -4806,7 +4807,7 @@ void GFX_EndTextLines(bool force=false) {
#endif
}
if (ttf.cursor >= 0 && ttf.cursor < ttf.cols*ttf.lins) // hide/restore (previous) cursor-character if we had one
if (ttf.cursor < ttf.cols*ttf.lins) // hide/restore (previous) cursor-character if we had one
// if (cursor_enabled && (vga.draw.cursor.sline > vga.draw.cursor.eline || vga.draw.cursor.sline > 15))
// if (ttf.cursor != vga.draw.cursor.address>>1 || (vga.draw.cursor.enabled != cursor_enabled) || vga.draw.cursor.sline > vga.draw.cursor.eline || vga.draw.cursor.sline > 15)
@ -4891,8 +4892,8 @@ void GFX_EndTextLines(bool force=false) {
// NTS: Additional fix is needed for the cursor in PC-98 mode; also expect further cleanup
bcount++;
if (vga.draw.cursor.enabled && vga.draw.cursor.sline <= vga.draw.cursor.eline && vga.draw.cursor.sline <= 16 && blinkCursor) { // Draw cursor?
int newPos = (int)(vga.draw.cursor.address>>1);
if (newPos >= 0 && newPos < ttf.cols*ttf.lins) { // If on screen
unsigned int newPos = (unsigned int)(vga.draw.cursor.address>>1);
if (newPos < ttf.cols*ttf.lins) { // If on screen
int y = newPos/ttf.cols;
int x = newPos%ttf.cols;
if (IS_JEGA_ARCH) {
@ -8658,7 +8659,7 @@ static bool bScanCodeMapInited = false;
static void PasteInitMapSCToSDLKey()
{
/* Map the DIK scancodes to SDL keysyms */
for (int i = 0; i<SDL_arraysize(aryScanCodeToSDLKey); ++i)
for (unsigned int i = 0; i<SDL_arraysize(aryScanCodeToSDLKey); ++i)
aryScanCodeToSDLKey[i] = SDLK_UNKNOWN;
/* Defined DIK_* constants */

View File

@ -593,7 +593,7 @@ static Sint32 opus_seek(Sound_Sample* sample, const Uint32 ms)
const ogg_int64_t desired_pcm = ms * OPUS_SAMPLE_RATE_PER_MS;
// Is our stream already positioned at the requested offset?
if (d->of_pcm == desired_pcm){
if (d->of_pcm == (ogg_uint64_t)desired_pcm){
SNDDBG(("Opus seek avoided: "
"{requested_time: '%02d:%02d:%.2f', becomes_opus_pcm: %ld, actual_pcm_pos: %ld}\n",
@ -615,7 +615,7 @@ static Sint32 opus_seek(Sound_Sample* sample, const Uint32 ms)
//
// Is the requested pcm offset within our decoded range?
if (desired_pcm >= pcm_start && desired_pcm <= pcm_end) {
if ((ogg_uint64_t)desired_pcm >= pcm_start && (ogg_uint64_t)desired_pcm <= pcm_end) {
SNDDBG(("Opus seek avoided: "
"{requested_time: '%02d:%02d:%.2f', becomes_opus_pcm: %ld, buffer_start: %ld, buffer_end: %ld}\n",

View File

@ -1164,7 +1164,7 @@ static inline int chd_compressed(chd_header* header) {
static chd_error decompress_v5_map(chd_file* chd, chd_header* header)
{
int result = 0;
int hunknum;
unsigned int hunknum;
int repcount = 0;
uint8_t lastcomp = 0;
uint32_t last_self = 0;
@ -1348,7 +1348,7 @@ CHD_EXPORT chd_error chd_open_file(core_file *file, int mode, chd_file *parent,
{
chd_file *newchd = NULL;
chd_error err;
int intfnum;
unsigned int intfnum;
/* verify parameters */
if (file == NULL)
@ -1611,7 +1611,7 @@ CHD_EXPORT void chd_close(chd_file *chd)
}
else
{
int i;
unsigned int i;
/* Free the codecs */
for (i = 0 ; i < ARRAY_LENGTH(chd->codecintf); i++)
{
@ -1870,7 +1870,7 @@ CHD_EXPORT const char *chd_get_codec_name(UINT32 codec)
static chd_error header_validate(const chd_header *header)
{
int intfnum;
unsigned int intfnum;
/* require a valid version */
if (header->version == 0 || header->version > CHD_HEADER_VERSION)
@ -2100,7 +2100,7 @@ static chd_error header_read(chd_file *chd, chd_header *header)
static UINT8* hunk_read_compressed(chd_file *chd, UINT64 offset, size_t size)
{
ssize_t bytes;
size_t bytes;
if (chd->file_cache != NULL)
{
return chd->file_cache + offset;
@ -2122,7 +2122,7 @@ static UINT8* hunk_read_compressed(chd_file *chd, UINT64 offset, size_t size)
static chd_error hunk_read_uncompressed(chd_file *chd, UINT64 offset, size_t size, UINT8 *dest)
{
ssize_t bytes;
size_t bytes;
if (chd->file_cache != NULL)
{
memcpy(dest, chd->file_cache + offset, size);
@ -2370,7 +2370,7 @@ static chd_error map_read(chd_file *chd)
UINT8 cookie[MAP_ENTRY_SIZE];
UINT32 count;
chd_error err;
int i;
unsigned int i;
/* first allocate memory */
chd->map = (map_entry *)malloc(sizeof(chd->map[0]) * chd->header.totalhunks);

View File

@ -289,7 +289,8 @@ FLAC__StreamDecoderWriteStatus flac_decoder_write_callback_static(const FLAC__St
FLAC__StreamDecoderWriteStatus flac_decoder_write_callback(void *client_data, const FLAC__Frame *frame, const FLAC__int32 * const buffer[])
{
int sampnum, chan;
int sampnum;
unsigned int chan;
int shift, blocksize;
flac_decoder * decoder = (flac_decoder *)client_data;

View File

@ -179,7 +179,8 @@ uint32_t huffman_decode_one(struct huffman_decoder* decoder, struct bitstream* b
enum huffman_error huffman_import_tree_rle(struct huffman_decoder* decoder, struct bitstream* bitbuf)
{
int numbits, curnode;
int numbits;
unsigned int curnode;
enum huffman_error error;
/* bits per entry depends on the maxbits */
@ -245,7 +246,7 @@ enum huffman_error huffman_import_tree_huffman(struct huffman_decoder* decoder,
int last = 0;
int count = 0;
int index;
int curcode;
unsigned int curcode;
uint8_t rlefullbits = 0;
uint32_t temp;
enum huffman_error error;
@ -315,7 +316,7 @@ enum huffman_error huffman_import_tree_huffman(struct huffman_decoder* decoder,
enum huffman_error huffman_compute_tree_from_histo(struct huffman_decoder* decoder)
{
int i;
unsigned int i;
uint32_t lowerweight;
uint32_t upperweight;
/* compute the number of data items in the histogram */
@ -379,7 +380,7 @@ static int huffman_tree_node_compare(const void *item1, const void *item2)
int huffman_build_tree(struct huffman_decoder* decoder, uint32_t totaldata, uint32_t totalweight)
{
int curcode;
unsigned int curcode;
int nextalloc;
int listitems = 0;
int maxbits = 0;
@ -476,7 +477,8 @@ int huffman_build_tree(struct huffman_decoder* decoder, uint32_t totaldata, uint
enum huffman_error huffman_assign_canonical_codes(struct huffman_decoder* decoder)
{
int curcode, codelen;
unsigned int curcode;
int codelen;
uint32_t curstart = 0;
/* build up a histogram of bit lengths */
uint32_t bithisto[33] = { 0 };