Browse Source

Fix a some more linux/GCC specific warnings

jp9000 11 years ago
parent
commit
8b8217f68e

+ 1 - 0
libobs-opengl/gl-x11.c

@@ -236,6 +236,7 @@ void device_leavecontext(device_t device)
 void gl_update(device_t device)
 {
 	/* I don't know of anything we can do here. */
+	UNUSED_PARAMETER(device);
 }
 
 void device_load_swapchain(device_t device, swapchain_t swap)

+ 2 - 2
libobs/media-io/audio-io.c

@@ -630,8 +630,8 @@ void audio_line_output(audio_line_t line, const struct audio_data *data)
 
 	} else {
 		blog(LOG_DEBUG, "Bad timestamp for audio line '%s', "
-		                "data->timestamp: %llu, "
-		                "line->base_timestamp: %llu.  This can "
+		                "data->timestamp: "PRIu64", "
+		                "line->base_timestamp: "PRIu64".  This can "
 		                "sometimes happen when there's a pause in "
 		                "the threads.", line->name, data->timestamp,
 		                line->base_timestamp);

+ 3 - 1
libobs/obs-source.c

@@ -15,6 +15,8 @@
     along with this program.  If not, see <http://www.gnu.org/licenses/>.
 ******************************************************************************/
 
+#include <inttypes.h>
+
 #include "media-io/format-conversion.h"
 #include "util/platform.h"
 #include "callback/calldata.h"
@@ -389,7 +391,7 @@ static inline void reset_audio_timing(obs_source_t source, uint64_t timetamp)
 static inline void handle_ts_jump(obs_source_t source, uint64_t ts,
 		uint64_t diff)
 {
-	blog(LOG_DEBUG, "Timestamp for source '%s' jumped by '%lld', "
+	blog(LOG_DEBUG, "Timestamp for source '%s' jumped by '"PRIu64"', "
 	                "resetting audio timing", source->name, diff);
 
 	/* if has video, ignore audio data until reset */

+ 1 - 1
libobs/util/c99defs.h

@@ -26,7 +26,7 @@
 #ifdef _MSC_VER
 #define FORCE_INLINE __forceinline
 #else
-#define FORCE_INLINE __attribute__((always_inline))
+#define FORCE_INLINE inline __attribute__((always_inline))
 #endif
 
 #ifdef _MSC_VER

+ 1 - 0
libobs/util/dstr.c

@@ -21,6 +21,7 @@
 #include <assert.h>
 #include <ctype.h>
 #include <wchar.h>
+#include <wctype.h>
 #include "c99defs.h"
 #include "dstr.h"
 #include "bmem.h"

+ 19 - 5
libobs/util/platform.c

@@ -82,17 +82,21 @@ size_t os_fread_mbs(FILE *file, char **pstr)
 
 	fseeko(file, 0, SEEK_END);
 	size = (size_t)ftello(file);
+	*pstr = NULL;
 
 	if (size > 0) {
 		char *mbstr = bmalloc(size+1);
 
 		fseeko(file, 0, SEEK_SET);
-		fread(mbstr, 1, size, file);
+		size = fread(mbstr, 1, size, file);
+		if (size == 0) {
+			bfree(mbstr);
+			return 0;
+		}
+
 		mbstr[size] = 0;
 		len = os_mbs_to_utf8(mbstr, size, pstr);
 		bfree(mbstr);
-	} else {
-		*pstr = NULL;
 	}
 
 	return len;
@@ -101,6 +105,7 @@ size_t os_fread_mbs(FILE *file, char **pstr)
 size_t os_fread_utf8(FILE *file, char **pstr)
 {
 	size_t size = 0;
+	size_t size_read;
 	size_t len = 0;
 
 	fseeko(file, 0, SEEK_END);
@@ -113,13 +118,22 @@ size_t os_fread_utf8(FILE *file, char **pstr)
 
 		/* remove the ghastly BOM if present */
 		fseeko(file, 0, SEEK_SET);
-		fread(bom, 1, 3, file);
+		size_read = fread(bom, 1, 3, file);
+		if (size_read != 3)
+			return 0;
+
 		offset = (astrcmp_n(bom, "\xEF\xBB\xBF", 3) == 0) ? 3 : 0;
 
 		size -= offset;
 		utf8str = bmalloc(size+1);
 		fseeko(file, offset, SEEK_SET);
-		fread(utf8str, 1, size, file);
+
+		size = fread(utf8str, 1, size, file);
+		if (size == 0) {
+			bfree(utf8str);
+			return 0;
+		}
+
 		utf8str[size] = 0;
 
 		*pstr = utf8str;

+ 2 - 1
obs/obs-app.cpp

@@ -15,6 +15,7 @@
     along with this program.  If not, see <http://www.gnu.org/licenses/>.
 ******************************************************************************/
 
+#include <inttypes.h>
 #include <sstream>
 #include <util/bmem.h>
 #include <util/dstr.h>
@@ -292,6 +293,6 @@ int main(int argc, char *argv[])
 		blog(LOG_ERROR, "%s", error);
 	}
 
-	blog(LOG_INFO, "Number of memory leaks: %llu", bnum_allocs());
+	blog(LOG_INFO, "Number of memory leaks: "PRIu64, bnum_allocs());
 	return ret;
 }

+ 1 - 0
plugins/obs-ffmpeg/obs-ffmpeg-output.c

@@ -20,6 +20,7 @@
 
 #include <libavformat/avformat.h>
 #include <libswscale/swscale.h>
+#include <libavutil/frame.h>
 
 struct ffmpeg_data {
 	AVStream           *video;