shithub: dumb

Download patch

ref: d9b1453cedbe0406701e152016bcf466c578d59d
parent: 63d3efa74bda5ba6259f16ce77f687e4bd17aa9e
author: Christopher Snowhill <kode54@gmail.com>
date: Sat Sep 23 12:44:27 EDT 2017

Resolved all Xcode warnings with current warning level.

--- a/include/internal/it.h
+++ b/include/internal/it.h
@@ -385,7 +385,7 @@
 struct IT_PATTERN
 {
 	int n_rows;
-	int n_entries;
+	size_t n_entries;
 	IT_ENTRY *entry;
 };
 
@@ -918,9 +918,9 @@
 void _dumb_it_interleave_stereo_sample(IT_SAMPLE *sample);
 
 /* Calling either of these is optional */
-void _dumb_init_cubic();
+void _dumb_init_cubic(void);
 #ifdef _USE_SSE
-void _dumb_init_sse();
+void _dumb_init_sse(void);
 #endif
 
 #endif /* INTERNAL_IT_H */
--- a/src/core/readduh.c
+++ b/src/core/readduh.c
@@ -81,7 +81,7 @@
 		return NULL;
 	}
 
-	duh->n_signals = dumbfile_igetl(f);
+	duh->n_signals = (int) dumbfile_igetl(f);
 	if (dumbfile_error(f) || duh->n_signals <= 0) {
 		free(duh);
 		return NULL;
--- a/src/helpers/clickrem.c
+++ b/src/helpers/clickrem.c
@@ -145,7 +145,7 @@
 
 	while (click) {
 		DUMB_CLICK *next = click->next;
-		int end = click->pos * step;
+		long end = click->pos * step;
 		ASSERT(end <= length);
 		offset = cr->offset;
 		if (offset < 0) {
--- a/src/helpers/resamp2.inc
+++ b/src/helpers/resamp2.inc
@@ -62,12 +62,12 @@
 			if (resampler->overshot >= 3 && resampler->pos+3 >= resampler->start) COPYSRC(resampler->X, 0, src, resampler->pos+3);
 			if (resampler->overshot >= 2 && resampler->pos+2 >= resampler->start) COPYSRC(resampler->X, 1, src, resampler->pos+2);
 			if (resampler->overshot >= 1 && resampler->pos+1 >= resampler->start) COPYSRC(resampler->X, 2, src, resampler->pos+1);
-			resampler->overshot = resampler->start - resampler->pos - 1;
+			resampler->overshot = (int)(resampler->start - resampler->pos - 1);
 		} else {
 			if (resampler->overshot >= 3 && resampler->pos-3 < resampler->end) COPYSRC(resampler->X, 0, src, resampler->pos-3);
 			if (resampler->overshot >= 2 && resampler->pos-2 < resampler->end) COPYSRC(resampler->X, 1, src, resampler->pos-2);
 			if (resampler->overshot >= 1 && resampler->pos-1 < resampler->end) COPYSRC(resampler->X, 2, src, resampler->pos-1);
-			resampler->overshot = resampler->pos - resampler->end;
+			resampler->overshot = (int)(resampler->pos - resampler->end);
 		}
 
 		if (resampler->overshot < 0) {
--- a/src/it/readam.c
+++ b/src/it/readam.c
@@ -24,17 +24,17 @@
 #include "internal/it.h"
 #include "internal/riff.h"
 
-static int it_riff_am_process_sample( IT_SAMPLE * sample, DUMBFILE * f, int len, int ver )
+static int it_riff_am_process_sample( IT_SAMPLE * sample, DUMBFILE * f, size_t len, int ver )
 {
-	int header_length;
+	size_t header_length;
 	int default_pan;
 	int default_volume;
 	int flags;
-	int length;
-	int length_bytes;
-	int loop_start;
-	int loop_end;
-    int sample_rate;
+	size_t length;
+	size_t length_bytes;
+	size_t loop_start;
+	size_t loop_end;
+    size_t sample_rate;
 
     long start = dumbfile_pos( f );
 
@@ -145,7 +145,7 @@
 	return 0;
 }
 
-static int it_riff_am_process_pattern( IT_PATTERN * pattern, DUMBFILE * f, int len, int ver )
+static int it_riff_am_process_pattern( IT_PATTERN * pattern, DUMBFILE * f, size_t len, int ver )
 {
     int nrows, row;
     long start, end;
@@ -266,7 +266,8 @@
 {
 	DUMB_IT_SIGDATA *sigdata;
 
-    int n, o, p, found;
+    int n, found;
+    size_t o, p;
 
 	if ( ! stream ) goto error;
 
@@ -300,7 +301,7 @@
         case DUMB_ID( 'P', 'A', 'T', 'T' ):
             if ( dumbfile_seek( f, c->offset, DFS_SEEK_SET ) ) goto error_sd;
             o = dumbfile_getc( f );
-            if ( o >= sigdata->n_patterns ) sigdata->n_patterns = o + 1;
+            if ( o >= sigdata->n_patterns ) sigdata->n_patterns = (int)(o + 1);
             o = dumbfile_igetl( f );
             if ( (unsigned)o + 5 > c->size ) goto error_sd;
 			break;
@@ -310,13 +311,13 @@
 				if ( c->size < 0xE1 ) goto error_sd;
                 if ( dumbfile_seek( f, c->offset + 1, DFS_SEEK_SET ) ) goto error_sd;
                 o = dumbfile_getc( f );
-                if ( o >= sigdata->n_samples ) sigdata->n_samples = o + 1;
+                if ( o >= sigdata->n_samples ) sigdata->n_samples = (int)(o + 1);
                 if ( c->size >= 0x121 )
                 {
                     if ( dumbfile_seek( f, c->offset + 0xE1, DFS_SEEK_SET ) ) goto error_sd;
                     if ( dumbfile_mgetl( f ) == DUMB_ID('S','A','M','P') )
                     {
-                        unsigned size = dumbfile_igetl( f );
+                        size_t size = dumbfile_igetl( f );
                         if ( size + 0xE1 + 8 > c->size ) goto error_sd;
                     }
 				}
@@ -436,7 +437,7 @@
                     if ( dumbfile_seek( f, c->offset + 0xE1, DFS_SEEK_SET ) ) goto error_usd;
                     if ( dumbfile_mgetl( f ) == DUMB_ID('S','A','M','P') )
                     {
-                        unsigned size = dumbfile_igetl( f );
+                        size_t size = dumbfile_igetl( f );
                         if ( it_riff_am_process_sample( sample, f, size, 0 ) ) goto error_usd;
                         break;
                     }
@@ -466,7 +467,8 @@
 {
 	DUMB_IT_SIGDATA *sigdata;
 
-	int n, o, p, found;
+	int n, found;
+    size_t o, p;
 
     if ( ! f || ! stream ) goto error;
 
@@ -500,7 +502,7 @@
 		case DUMB_ID( 'P', 'A', 'T', 'T' ):
             if ( dumbfile_seek( f, c->offset, DFS_SEEK_SET ) ) goto error_sd;
             o = dumbfile_getc( f );
-            if ( o >= sigdata->n_patterns ) sigdata->n_patterns = o + 1;
+            if ( o >= sigdata->n_patterns ) sigdata->n_patterns = (int)(o + 1);
             o = dumbfile_igetl( f );
             if ( (unsigned)o + 5 > c->size ) goto error_sd;
 			break;
@@ -519,7 +521,7 @@
 						case DUMB_ID( 'I', 'N', 'S', 'T' ):
 							{
 								struct riff * temp;
-								unsigned size;
+								size_t size;
 								unsigned sample_found;
                                 if ( dumbfile_seek( f, chk->offset, DFS_SEEK_SET ) ) goto error_sd;
                                 size = dumbfile_igetl( f );
@@ -527,7 +529,7 @@
 								sample_found = 0;
                                 dumbfile_skip( f, 1 );
                                 p = dumbfile_getc( f );
-                                if ( p >= sigdata->n_samples ) sigdata->n_samples = p + 1;
+                                if ( p >= sigdata->n_samples ) sigdata->n_samples = (int)(p + 1);
                                 temp = riff_parse( f, chk->offset + 4 + size, chk->size - size - 4, 1 );
 								if ( temp )
 								{
@@ -675,7 +677,7 @@
 						case DUMB_ID( 'I', 'N', 'S', 'T' ):
 							{
 								struct riff * temp;
-								unsigned size;
+								size_t size;
 								unsigned sample_found;
 								IT_SAMPLE * sample;
                                 if ( dumbfile_seek( f, chk->offset, DFS_SEEK_SET ) ) goto error_usd;
--- a/src/it/readmod.c
+++ b/src/it/readmod.c
@@ -367,7 +367,7 @@
 					sigdata->n_samples = 15;
 				}
 			} else if ((fft & 0x00FFFFFFL) == DUMB_ID(0,'C','H','N')) {
-				n_channels = (fft >> 24) - '0';
+				n_channels = (int)((fft >> 24) - '0');
 				if ((unsigned int)(n_channels - 1) >= 9) {
 					/* Character was '0' or it wasn't a digit */
 					n_channels = 4;
@@ -505,7 +505,7 @@
         }
 
 		if (remain > total_sample_size) {
-			sigdata->n_patterns = ( remain - total_sample_size + 4 ) / ( 256 * sigdata->n_pchannels );
+			sigdata->n_patterns = (int)(( remain - total_sample_size + 4 ) / ( 256 * sigdata->n_pchannels ));
 			if (fft == DUMB_ID('M',0,0,0) || fft == DUMB_ID('8',0,0,0)) {
 				remain -= sigdata->n_patterns * 256 * sigdata->n_pchannels;
 				if (dumbfile_skip(f, remain - total_sample_size)) {
--- a/src/it/readokt.c
+++ b/src/it/readokt.c
@@ -227,8 +227,8 @@
 		bytes_read = dumbfile_mgetl( f );
 		if ( bytes_read < 0 ) break;
 
-		chunk->type = bytes_read;
-		chunk->size = dumbfile_mgetl( f );
+		chunk->type = (unsigned int)bytes_read;
+		chunk->size = (unsigned int)dumbfile_mgetl( f );
 
 		if ( dumbfile_error( f ) ) break;
 
@@ -247,7 +247,7 @@
 				free( chunk->data );
 				break;
 			} else {
-				chunk->size = bytes_read;
+				chunk->size = (unsigned int)bytes_read;
 				mod->chunk_count++;
 				break;
 			}
--- a/src/it/readpsm.c
+++ b/src/it/readpsm.c
@@ -37,7 +37,7 @@
 typedef struct _PSMCHUNK
 {
 	int id;
-	int len;
+	size_t len;
 	unsigned char * data;
 } PSMCHUNK;
 
@@ -56,7 +56,7 @@
 #define PSM_EVENT_CHANGE_PAN       13
 #define PSM_EVENT_CHANGE_VOL       14
 
-static int it_psm_process_sample(IT_SAMPLE * sample, const unsigned char * data, int len, int id, int version) {
+static int it_psm_process_sample(IT_SAMPLE * sample, const unsigned char * data, size_t len, int id, int version) {
 	int flags;
 	int insno;
 	int length;
@@ -142,7 +142,7 @@
 	return 0;
 }
 
-static int it_psm_process_pattern(IT_PATTERN * pattern, const unsigned char * data, int len, int speed, int bpm, const unsigned char * pan, const int * vol, int version) {
+static int it_psm_process_pattern(IT_PATTERN * pattern, const unsigned char * data, size_t len, int speed, int bpm, const unsigned char * pan, const int * vol, int version) {
 	int length, nrows, row, rowlen, pos;
 	unsigned flags, chan;
 	IT_ENTRY * entry;
@@ -474,13 +474,14 @@
 
 	unsigned char * ptr;
 
-	int n, length, o;
+	size_t n, length;
+    int o;
 
 	int found;
 
 	int n_patterns = 0;
 
-	int first_pattern_line = -1;
+	long first_pattern_line = -1;
 	int first_pattern;
 
 	int speed, bpm;
@@ -497,10 +498,10 @@
 
 	while (length >= 8) {
 		if (n_chunks >= 768) goto error_fc;
-		chunk[n_chunks].id = dumbfile_mgetl(f);
+		chunk[n_chunks].id = (unsigned int) dumbfile_mgetl(f);
 		n = dumbfile_igetl(f);
 		length -= 8;
-		if (n < 0 || n > length)
+		if ((signed int)n <= 0 || n > length)
 			goto error_fc;
 		chunk[n_chunks].len = n;
 		if (n) {
@@ -575,7 +576,7 @@
 	}
 
 	if (n == n_chunks) return NULL;
-	subsong = n;
+	subsong = (int) n;
 
 	/*for (n = 0; n < n_chunks; n++) {
 		PSMCHUNK * c = &chunk[n];
@@ -597,7 +598,7 @@
 					songchunk[n_song_chunks].id = DUMB_ID(ptr[0], ptr[1], ptr[2], ptr[3]);
 					n = ptr[4] | (ptr[5] << 8) | (ptr[6] << 16) | (ptr[7] << 24);
 					length -= 8;
-					if (n < 0 || n > length) goto error_sc;
+					if ((signed int)n < 0 || n > length) goto error_sc;
 					songchunk[n_song_chunks].len = n;
 					songchunk[n_song_chunks].data = ptr + 8;
 					n_song_chunks++;
@@ -813,7 +814,7 @@
 							if (it_psm_process_pattern(&sigdata->pattern[n_patterns], ptr, length, speed, bpm, pan, vol, found)) goto error_ev;
 							if (first_pattern_line < 0) {
 								first_pattern_line = n;
-								first_pattern = o;
+								first_pattern = (int)o;
 							}
 							e->data[0] = n_patterns;
 							e->data[1] = n_patterns >> 8;
@@ -826,7 +827,7 @@
 							if (it_psm_process_pattern(&sigdata->pattern[n_patterns], ptr, length, speed, bpm, pan, vol, found)) goto error_ev;
 							if (first_pattern_line < 0) {
 								first_pattern_line = n;
-								first_pattern = o;
+								first_pattern = (int)o;
 							}
 							e->data[0] = n_patterns;
 							e->data[1] = n_patterns >> 8;
@@ -1192,7 +1193,8 @@
 }
 
 int dumb_get_psm_subsong_count(DUMBFILE *f) {
-	int length, subsongs;
+	size_t length;
+    int subsongs;
 	long l;
 	
 	if (dumbfile_mgetl(f) != DUMB_ID('P','S','M',' ')) return 0;
@@ -1220,13 +1222,14 @@
 /* Eww */
 int pattcmp( const unsigned char * a, const unsigned char * b, size_t l )
 {
-    size_t i, j, na, nb;
+    int i;
+    unsigned long j, na, nb;
 	char * p;
 
 	na = nb = 0;
 
 	i = memcmp( a, b, l );
-	if ( !i ) return i;
+	if ( !i ) return 0;
 
 	/* damnit */
 
@@ -1258,7 +1261,7 @@
 	i = memcmp( a, b, j );
 	if ( i ) return i;
 
-	return na - nb;
+	return (int)(na - nb);
 }
 
 
--- a/src/it/readptm.c
+++ b/src/it/readptm.c
@@ -149,7 +149,7 @@
 
 
 
-static int it_ptm_read_pattern(IT_PATTERN *pattern, DUMBFILE *f, unsigned char *buffer, int length)
+static int it_ptm_read_pattern(IT_PATTERN *pattern, DUMBFILE *f, unsigned char *buffer, size_t length)
 {
 	int buflen = 0;
 	int bufpos = 0;
@@ -313,8 +313,8 @@
 
 static int ptm_component_compare(const void *e1, const void *e2)
 {
-	return ((const PTM_COMPONENT *)e1)->offset -
-	       ((const PTM_COMPONENT *)e2)->offset;
+	return (int)(((const PTM_COMPONENT *)e1)->offset -
+	       ((const PTM_COMPONENT *)e2)->offset);
 }
 
 
--- a/src/it/reads3m.c
+++ b/src/it/reads3m.c
@@ -426,8 +426,8 @@
 
 static int s3m_component_compare(const void *e1, const void *e2)
 {
-	return ((const S3M_COMPONENT *)e1)->offset -
-	       ((const S3M_COMPONENT *)e2)->offset;
+	return (int)(((const S3M_COMPONENT *)e1)->offset -
+	       ((const S3M_COMPONENT *)e2)->offset);
 }
 
 
--- a/src/it/readxm.c
+++ b/src/it/readxm.c
@@ -422,7 +422,7 @@
 static size_t limit_xm_getnc(char *ptr, size_t n, void *f)
 {
 	LIMITED_XM *lx = f;
-	int left;
+	long left;
 	left = lx->allocated - lx->ptr;
 	if (n > left) {
 		if (left > 0) {
@@ -818,7 +818,7 @@
 	DUMB_IT_SIGDATA *sigdata;
 	char id_text[18];
 
-	int header_size;
+	size_t header_size;
 	int flags;
 	int n_channels;
 	int total_samples;
@@ -911,7 +911,7 @@
 
 	/* sanity checks */
 	// XXX
-	i = header_size - 4 - 2 * 8; /* Maximum number of orders expected */
+	i = (int)(header_size - 4 - 2 * 8); /* Maximum number of orders expected */
 	if (dumbfile_error(f) || sigdata->n_orders <= 0 || sigdata->n_orders > i || !sigdata->n_patterns || sigdata->n_patterns > 256 || !sigdata->n_instruments || sigdata->n_instruments > 256 || n_channels > DUMB_IT_N_CHANNELS) {
 		_dumb_it_unload_sigdata(sigdata);
 		return NULL;