<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">r487 | r2d | 2016-01-10 20:36:06 +0000 (Sun, 10 Jan 2016) | 1 line
Changed paths:
   M /libmpc/trunk/mpcchap/mpcchap.c
   M /libmpc/trunk/mpcenc/mpcenc.c
   M /libmpc/trunk/mpcgain/mpcgain.c

removed some new gcc warnings
------------------------------------------------------------------------
Index: mpcchap/mpcchap.c
===================================================================
diff --git a/mpcchap/mpcchap.c b/libmpc/mpcchap/mpcchap.c
--- a/mpcchap/mpcchap.c	(revision 486)
+++ b/mpcchap/mpcchap.c	(revision 487)
@@ -22,6 +22,7 @@
 #include "../libmpcenc/libmpcenc.h"
 #include "iniparser.h"
 
+#include &lt;inttypes.h&gt;
 #include &lt;sys/stat.h&gt;
 
 #include &lt;cuetools/cuefile.h&gt;
@@ -82,6 +83,7 @@
 	int chap_pos, end_pos, chap_size, i, nchap;
 	char * tmp_buff;
 	dictionary * dict;
+    mpc_status ret = MPC_STATUS_OK;
 
 	chap_pos = (demux-&gt;chap_pos &gt;&gt; 3) + si-&gt;header_position;
 	end_pos = mpc_demux_pos(demux) &gt;&gt; 3;
@@ -89,9 +91,13 @@
 
 	stat(mpc_file, &amp;stbuf);
 	tmp_buff = malloc(stbuf.st_size - chap_pos - chap_size);
+
 	in_file = fopen( mpc_file, "r+b" );
 	fseek(in_file, chap_pos + chap_size, SEEK_SET);
-	fread(tmp_buff, 1, stbuf.st_size - chap_pos - chap_size, in_file);
+    if (1 != fread(tmp_buff, stbuf.st_size - chap_pos - chap_size, 1, in_file)) {
+        ret = MPC_STATUS_FAIL;
+        goto error_read_in_file;
+    }
 	fseek(in_file, chap_pos, SEEK_SET);
 
 	dict = iniparser_load(chap_file);
@@ -104,8 +110,8 @@
 		mpc_int64_t chap_pos = atoll(chap_sec);
 
 		if (chap_pos &gt; si-&gt;samples - si-&gt;beg_silence)
-			fprintf(stderr, "warning : chapter %i starts @ %lli samples after the end of the stream (%lli)\n",
-			        i + 1, chap_pos, si-&gt;samples - si-&gt;beg_silence);
+            fprintf(stderr, "warning : chapter %i starts @ %" PRId64 " samples after the end of the stream (%" PRId64 ")\n",
+                    i + 1, chap_pos, si-&gt;samples - si-&gt;beg_silence);
 
 		Init_Tags();
 
@@ -141,13 +147,15 @@
 	}
 
 	fwrite(tmp_buff, 1, stbuf.st_size - chap_pos - chap_size, in_file);
-	ftruncate(fileno(in_file), ftell(in_file));
+    if (0 != ftruncate(fileno(in_file), ftell(in_file)))
+        ret = MPC_STATUS_FAIL;
 
-	fclose(in_file);
-	free(tmp_buff);
-	iniparser_freedict(dict);
+    iniparser_freedict(dict);
+error_read_in_file:
+    fclose(in_file);
+    free(tmp_buff);
 
-	return MPC_STATUS_OK;
+    return ret;
 }
 
 mpc_status add_chaps_cue(char * mpc_file, char * chap_file, mpc_demux * demux, mpc_streaminfo * si)
@@ -158,6 +166,7 @@
 	FILE * in_file;
 	int chap_pos, end_pos, chap_size, i;
 	char * tmp_buff;
+    mpc_status ret = MPC_STATUS_OK;
 
 	if (0 == (cd = cf_parse(chap_file, &amp;format))) {
 		fprintf(stderr, "%s: input file error\n", chap_file);
@@ -172,7 +181,10 @@
 	tmp_buff = malloc(stbuf.st_size - chap_pos - chap_size);
 	in_file = fopen( mpc_file, "r+b" );
 	fseek(in_file, chap_pos + chap_size, SEEK_SET);
-	fread(tmp_buff, 1, stbuf.st_size - chap_pos - chap_size, in_file);
+    if (1 != fread(tmp_buff, stbuf.st_size - chap_pos - chap_size, 1, in_file)) {
+        ret = MPC_STATUS_FAIL;
+        goto error_read_in_file;
+    }
 	fseek(in_file, chap_pos, SEEK_SET);
 
 	nchap = cd_get_ntrack(cd);
@@ -190,7 +202,7 @@
 		chap_pos = (mpc_int64_t) si-&gt;sample_freq * track_get_start (track) / 75;
 
 		if (chap_pos &gt; si-&gt;samples - si-&gt;beg_silence)
-			fprintf(stderr, "warning : chapter %i starts @ %lli samples after the end of the stream (%lli)\n",
+            fprintf(stderr, "warning : chapter %i starts @ %" PRId64 " samples after the end of the stream (%" PRId64 ")\n",
 			        i, chap_pos, si-&gt;samples - si-&gt;beg_silence);
 
 		Init_Tags();
@@ -224,12 +236,14 @@
 	}
 
 	fwrite(tmp_buff, 1, stbuf.st_size - chap_pos - chap_size, in_file);
-	ftruncate(fileno(in_file), ftell(in_file));
+    if (0 != ftruncate(fileno(in_file), ftell(in_file)))
+        ret = MPC_STATUS_FAIL;
 
+error_read_in_file:
 	fclose(in_file);
 	free(tmp_buff);
 
-	return MPC_STATUS_OK;
+    return ret;
 }
 
 mpc_status dump_chaps(mpc_demux * demux, char * chap_file, int chap_nb)
@@ -247,7 +261,7 @@
 
 	for (i = 0; i &lt; chap_nb; i++) {
 		chap = mpc_demux_chap(demux, i);
-		fprintf(out_file, "[%lli]\ngain=%i\npeak=%i\n", chap-&gt;sample, chap-&gt;gain, chap-&gt;peak);
+        fprintf(out_file, "[%" PRId64 "]\ngain=%i\npeak=%i\n", chap-&gt;sample, chap-&gt;gain, chap-&gt;peak);
 		if (chap-&gt;tag_size &gt; 0) {
 			int item_count, j;
 			char const * tag = chap-&gt;tag;
Index: mpcgain/mpcgain.c
===================================================================
diff --git a/mpcgain/mpcgain.c b/libmpc/mpcgain/mpcgain.c
--- a/mpcgain/mpcgain.c	(revision 486)
+++ b/mpcgain/mpcgain.c	(revision 487)
@@ -115,7 +115,7 @@
 
 	while (1) {
 		fseek(file, next_chap_pos, SEEK_SET);
-		fread(buffer, 1, MAX_HEAD_SIZE, file);
+        if (0 == fread(buffer, 1, MAX_HEAD_SIZE, file)) break;
 		r.buff = buffer;
 		r.count = 8;
 		size = mpc_bits_get_block(&amp;r, &amp;b);
@@ -182,7 +182,7 @@
 		chap_nb = mpc_demux_chap_nb(demux);
 		mpc_demux_seek_sample(demux, 0);
 		if (chap_nb &gt; 0) {
-			mpc_chap_info * chap_info = mpc_demux_chap(demux, chap);
+            const mpc_chap_info * chap_info = mpc_demux_chap(demux, chap);
 			next_chap_sample = chap_info-&gt;sample;
 			chap_gain = malloc(sizeof(mpc_uint16_t) * 2 * chap_nb);
 			chap_peak = chap_gain + chap_nb;
@@ -215,7 +215,7 @@
 				i += sample_nb;
 				cur_sample = next_chap_sample;
 				if (chap &lt; chap_nb) {
-					mpc_chap_info * chap_info = mpc_demux_chap(demux, chap);
+                    const mpc_chap_info * chap_info = mpc_demux_chap(demux, chap);
 					next_chap_sample = chap_info-&gt;sample;
 				} else
 					next_chap_sample = mpc_int64_max;
@@ -260,8 +260,8 @@
 			continue;
 		}
 		fseek(file, header_pos[j] - 4, SEEK_SET);
-		fread(buffer, 1, 16, file);
-		if (memcmp(buffer, "MPCK", 4) != 0) {
+
+        if (fread(buffer, 1, 16, file) != 16 || memcmp(buffer, "MPCK", 4) != 0) {
 			fprintf(stderr, "Unsupported file format, not a sv8 file : %s\n", argv[j + 1]);
 			fclose(file);
 			continue;
@@ -276,7 +276,7 @@
 			if (memcmp(b.key, "RG", 2) == 0) break;
 			header_pos[j] += b.size + size;
 			fseek(file, header_pos[j], SEEK_SET);
-			fread(buffer, 1, 16, file);
+            if (0 == fread(buffer, 1, 16, file)) break;
 			r.buff = buffer;
 			r.count = 8;
 		}
@@ -286,7 +286,7 @@
 			fclose(file);
 			continue;
 		}
-		header_pos[j] += size;
+        header_pos[j] += size;
 
 		buffer[size] = 1; // replaygain version
 		buffer[size + 1] = title_gain[j] &gt;&gt; 8;
Index: mpcenc/mpcenc.c
===================================================================
diff --git a/mpcenc/mpcenc.c b/libmpc/mpcenc/mpcenc.c
--- a/mpcenc/mpcenc.c	(revision 486)
+++ b/mpcenc/mpcenc.c	(revision 487)
@@ -1023,7 +1023,7 @@
         }
         else if ( 0 == strcmp ( arg, "stderr") ) {                                      // Offset for threshold in quiet
             if ( ++k &gt;= argc ) { stderr_printf ( errmsg, arg ); return -1; }
-            freopen ( argv[k], "a", stderr );
+            stderr = freopen ( argv[k], "a", stderr );
         }
         else if ( 0 == strcmp ( arg, "ltq")  ||  0 == strcmp ( arg, "ath") ) {          // threshold in quiet
             if ( ++k &gt;= argc ) { stderr_printf ( errmsg, arg ); return -1; }
@@ -1208,11 +1208,12 @@
             p = strchr ( argv[k], '=' );
             if ( p == NULL ) {
                 stderr_printf (" Enter value for tag key '%s': ", argv[k] );
-                fgets ( buff, sizeof buff, stdin );
-                len = strlen (buff);
-                while ( len &gt; 0  &amp;&amp;  (buff [len-1] == '\r'  ||  buff [len-1] == '\n') )
-                    len--;
-                addtag ( arg, strlen(arg), buff, len, NoUnicode*6, 0 );
+                if (0 != fgets ( buff, sizeof buff, stdin )) {
+                    len = strlen (buff);
+                    while ( len &gt; 0  &amp;&amp;  (buff [len-1] == '\r'  ||  buff [len-1] == '\n') )
+                        len--;
+                    addtag ( arg, strlen(arg), buff, len, NoUnicode*6, 0 );
+                }
             }
             else {
                 fp = fopen ( p+1, "rb" );
</pre></body></html>