浏览代码

Fix windows printf format warnings (from mingw)

jp9000 10 年之前
父节点
当前提交
5dfecab15c

+ 10 - 10
libobs-opengl/gl-windows.c

@@ -132,7 +132,7 @@ static inline bool wgl_make_current(HDC hdc, HGLRC hglrc)
 	bool success = wglMakeCurrent(hdc, hglrc);
 	if (!success)
 		blog(LOG_ERROR, "wglMakeCurrent failed, GetLastError "
-		                "returned %u", GetLastError());
+		                "returned %lu", GetLastError());
 
 	return success;
 }
@@ -141,7 +141,7 @@ static inline HGLRC gl_init_basic_context(HDC hdc)
 {
 	HGLRC hglrc = wglCreateContext(hdc);
 	if (!hglrc) {
-		blog(LOG_ERROR, "wglCreateContext failed, %u", GetLastError());
+		blog(LOG_ERROR, "wglCreateContext failed, %lu", GetLastError());
 		return NULL;
 	}
 
@@ -168,8 +168,8 @@ static inline HGLRC gl_init_context(HDC hdc)
 	if (GLAD_WGL_ARB_create_context) {
 		HGLRC hglrc = wglCreateContextAttribsARB(hdc, 0, attribs);
 		if (!hglrc) {
-			blog(LOG_ERROR, "wglCreateContextAttribsARB failed, %u",
-					GetLastError());
+			blog(LOG_ERROR, "wglCreateContextAttribsARB failed, "
+					"%lu", GetLastError());
 			return NULL;
 		}
 
@@ -202,13 +202,13 @@ static bool gl_dummy_context_init(struct dummy_context *dummy)
 	init_dummy_pixel_format(&pfd);
 	format_index = ChoosePixelFormat(dummy->hdc, &pfd);
 	if (!format_index) {
-		blog(LOG_ERROR, "Dummy ChoosePixelFormat failed, %u",
+		blog(LOG_ERROR, "Dummy ChoosePixelFormat failed, %lu",
 				GetLastError());
 		return false;
 	}
 
 	if (!SetPixelFormat(dummy->hdc, format_index, &pfd)) {
-		blog(LOG_ERROR, "Dummy SetPixelFormat failed, %u",
+		blog(LOG_ERROR, "Dummy SetPixelFormat failed, %lu",
 				GetLastError());
 		return false;
 	}
@@ -297,7 +297,7 @@ static int gl_choose_pixel_format(HDC hdc, const struct gs_init_data *info)
 	success = wglChoosePixelFormatARB(hdc, attribs.array, NULL, 1, &format,
 				&num_formats);
 	if (!success || !num_formats) {
-		blog(LOG_ERROR, "wglChoosePixelFormatARB failed, %u",
+		blog(LOG_ERROR, "wglChoosePixelFormatARB failed, %lu",
 				GetLastError());
 		format = 0;
 	}
@@ -316,7 +316,7 @@ static inline bool gl_getpixelformat(HDC hdc, const struct gs_init_data *info,
 	*format = gl_choose_pixel_format(hdc, info);
 
 	if (!DescribePixelFormat(hdc, *format, sizeof(*pfd), pfd)) {
-		blog(LOG_ERROR, "DescribePixelFormat failed, %u",
+		blog(LOG_ERROR, "DescribePixelFormat failed, %lu",
 				GetLastError());
 		return false;
 	}
@@ -328,7 +328,7 @@ static inline bool gl_setpixelformat(HDC hdc, int format,
 		PIXELFORMATDESCRIPTOR *pfd)
 {
 	if (!SetPixelFormat(hdc, format, pfd)) {
-		blog(LOG_ERROR, "SetPixelFormat failed, %u", GetLastError());
+		blog(LOG_ERROR, "SetPixelFormat failed, %lu", GetLastError());
 		return false;
 	}
 
@@ -514,7 +514,7 @@ void device_present(gs_device_t *device)
 {
 	if (!SwapBuffers(device->cur_swap->wi->hdc)) {
 		blog(LOG_ERROR, "SwapBuffers failed, GetLastError "
-				"returned %u", GetLastError());
+				"returned %lu", GetLastError());
 		blog(LOG_ERROR, "device_present (GL) failed");
 	}
 }

+ 1 - 1
libobs/util/platform-windows.c

@@ -67,7 +67,7 @@ void *os_dlopen(const char *path)
 	dstr_free(&dll_name);
 
 	if (!h_library)
-		blog(LOG_INFO, "LoadLibrary failed for '%s', error: %u",
+		blog(LOG_INFO, "LoadLibrary failed for '%s', error: %ld",
 				path, GetLastError());
 
 	return h_library;

+ 3 - 3
plugins/obs-outputs/librtmp/rtmp.c

@@ -3536,7 +3536,7 @@ RTMP_ReadPacket(RTMP *r, RTMPPacket *packet)
     // int didAlloc = FALSE;
     int extendedTimestamp = 0;
 
-    RTMP_Log(RTMP_LOGDEBUG2, "%s: fd=%d", __FUNCTION__, r->m_sb.sb_socket);
+    RTMP_Log(RTMP_LOGDEBUG2, "%s: fd=%d", __FUNCTION__, (int)r->m_sb.sb_socket);
 
     if (ReadN(r, (char *)hbuf, 1) == 0)
     {
@@ -3860,7 +3860,7 @@ RTMP_SendChunk(RTMP *r, RTMPChunk *chunk)
     int wrote;
     char hbuf[RTMP_MAX_HEADER_SIZE];
 
-    RTMP_Log(RTMP_LOGDEBUG2, "%s: fd=%d, size=%d", __FUNCTION__, r->m_sb.sb_socket,
+    RTMP_Log(RTMP_LOGDEBUG2, "%s: fd=%d, size=%d", __FUNCTION__, (int)r->m_sb.sb_socket,
              chunk->c_chunkSize);
     RTMP_LogHexString(RTMP_LOGDEBUG2, (uint8_t *)chunk->c_header, chunk->c_headerSize);
     if (chunk->c_chunkSize)
@@ -4004,7 +4004,7 @@ RTMP_SendPacket(RTMP *r, RTMPPacket *packet, int queue)
     buffer = packet->m_body;
     nChunkSize = r->m_outChunkSize;
 
-    RTMP_Log(RTMP_LOGDEBUG2, "%s: fd=%d, size=%d", __FUNCTION__, r->m_sb.sb_socket,
+    RTMP_Log(RTMP_LOGDEBUG2, "%s: fd=%d, size=%d", __FUNCTION__, (int)r->m_sb.sb_socket,
              nSize);
     /* send all chunks in one HTTP request */
     if (r->Link.protocol & RTMP_FEATURE_HTTP)

+ 5 - 5
plugins/win-capture/game-capture.c

@@ -352,14 +352,14 @@ static inline HANDLE create_event_id(bool manual_reset, bool initial_state,
 		const char *name, DWORD process_id)
 {
 	char new_name[128];
-	sprintf(new_name, "%s%d", name, process_id);
+	sprintf(new_name, "%s%lu", name, process_id);
 	return CreateEventA(NULL, manual_reset, initial_state, new_name);
 }
 
 static inline HANDLE open_event_id(const char *name, DWORD process_id)
 {
 	char new_name[128];
-	sprintf(new_name, "%s%d", name, process_id);
+	sprintf(new_name, "%s%lu", name, process_id);
 	return OpenEventA(EVENT_ALL_ACCESS, false, new_name);
 }
 
@@ -542,7 +542,7 @@ static void pipe_log(void *param, uint8_t *data, size_t size)
 static inline bool init_pipe(struct game_capture *gc)
 {
 	char name[64];
-	sprintf(name, "%s%d", PIPE_NAME, gc->process_id);
+	sprintf(name, "%s%lu", PIPE_NAME, gc->process_id);
 
 	if (!ipc_pipe_server_start(&gc->pipe, name, pipe_log, gc)) {
 		warn("init_pipe: failed to start pipe");
@@ -738,7 +738,7 @@ static void try_hook(struct game_capture *gc)
 
 		if (!gc->thread_id || !gc->process_id) {
 			warn("error acquiring, failed to get window "
-					"thread/process ids: %d",
+					"thread/process ids: %lu",
 					GetLastError());
 			gc->error_acquiring = true;
 			return;
@@ -963,7 +963,7 @@ static void game_capture_tick(void *data, float seconds)
 		close_handle(&gc->injector_process);
 
 		if (exit_code != 0) {
-			warn("inject process failed: %d", exit_code);
+			warn("inject process failed: %lu", exit_code);
 			gc->error_acquiring = true;
 
 		} else if (!gc->capturing) {

+ 9 - 9
plugins/win-capture/get-graphics-offsets/get-graphics-offsets.c

@@ -26,17 +26,17 @@ int main(int argc, char *argv[])
 	get_dxgi_offsets(&dxgi);
 
 	printf("[d3d8]\n");
-	printf("present=0x%"PRIxPTR"\n", d3d8.present);
-	printf("reset=0x%"PRIxPTR"\n", d3d8.reset);
+	printf("present=0x%"PRIx32"\n", d3d8.present);
+	printf("reset=0x%"PRIx32"\n", d3d8.reset);
 	printf("[d3d9]\n");
-	printf("present=0x%"PRIxPTR"\n", d3d9.present);
-	printf("present_ex=0x%"PRIxPTR"\n", d3d9.present_ex);
-	printf("present_swap=0x%"PRIxPTR"\n", d3d9.present_swap);
-	printf("reset=0x%"PRIxPTR"\n", d3d9.reset);
-	printf("reset_ex=0x%"PRIxPTR"\n", d3d9.reset_ex);
+	printf("present=0x%"PRIx32"\n", d3d9.present);
+	printf("present_ex=0x%"PRIx32"\n", d3d9.present_ex);
+	printf("present_swap=0x%"PRIx32"\n", d3d9.present_swap);
+	printf("reset=0x%"PRIx32"\n", d3d9.reset);
+	printf("reset_ex=0x%"PRIx32"\n", d3d9.reset_ex);
 	printf("[dxgi]\n");
-	printf("present=0x%"PRIxPTR"\n", dxgi.present);
-	printf("resize=0x%"PRIxPTR"\n", dxgi.resize);
+	printf("present=0x%"PRIx32"\n", dxgi.present);
+	printf("resize=0x%"PRIx32"\n", dxgi.resize);
 
 	(void)argc;
 	(void)argv;

+ 1 - 1
plugins/win-capture/graphics-hook-info.h

@@ -106,7 +106,7 @@ static inline HANDLE get_hook_info(DWORD id)
 {
 	HANDLE handle;
 	char new_name[64];
-	sprintf(new_name, "%s%d", SHMEM_HOOK_INFO, id);
+	sprintf(new_name, "%s%lu", SHMEM_HOOK_INFO, id);
 
 	handle = CreateFileMappingA(INVALID_HANDLE_VALUE, NULL,
 			PAGE_READWRITE, 0, sizeof(struct hook_info), new_name);

+ 4 - 4
plugins/win-capture/graphics-hook/graphics-hook.c

@@ -60,10 +60,10 @@ static inline void wait_for_dll_main_finish(HANDLE thread_handle)
 	}
 }
 
-static inline bool init_pipe(void)
+bool init_pipe(void)
 {
 	char new_name[64];
-	sprintf(new_name, "%s%d", PIPE_NAME, GetCurrentProcessId());
+	sprintf(new_name, "%s%lu", PIPE_NAME, GetCurrentProcessId());
 
 	if (!ipc_pipe_client_open(&pipe, new_name)) {
 		DbgOut("Failed to open pipe\n");
@@ -86,7 +86,7 @@ static HANDLE init_mutex(const char *name, DWORD pid)
 	char new_name[64];
 	HANDLE handle;
 
-	sprintf(new_name, "%s%d", name, pid);
+	sprintf(new_name, "%s%lu", name, pid);
 
 	handle = OpenMutexA(MUTEX_ALL_ACCESS, false, new_name);
 	if (!handle)
@@ -186,7 +186,7 @@ static inline bool init_hook(HANDLE thread_handle)
 {
 	wait_for_dll_main_finish(thread_handle);
 
-	sprintf(keepalive_name, "%s%d", EVENT_HOOK_KEEPALIVE,
+	sprintf(keepalive_name, "%s%lu", EVENT_HOOK_KEEPALIVE,
 			GetCurrentProcessId());
 
 	if (!init_pipe()) {

+ 2 - 2
plugins/win-capture/hook-helpers.h

@@ -25,14 +25,14 @@ static inline HANDLE get_mutex(const char *name)
 static inline HANDLE get_event_plus_id(const char *name, DWORD id)
 {
 	char new_name[64];
-	sprintf(new_name, "%s%d", name, id);
+	sprintf(new_name, "%s%lu", name, id);
 	return get_event(new_name);
 }
 
 static inline HANDLE get_mutex_plus_id(const char *name, DWORD id)
 {
 	char new_name[64];
-	sprintf(new_name, "%s%d", name, id);
+	sprintf(new_name, "%s%lu", name, id);
 	return get_mutex(new_name);
 }
 

+ 1 - 1
plugins/win-wasapi/win-wasapi.cpp

@@ -299,7 +299,7 @@ void WASAPISource::Reconnect()
 
 	if (!reconnectThread.Valid())
 		blog(LOG_WARNING, "[WASAPISource::Reconnect] "
-		                "Failed to intiialize reconnect thread: %d",
+		                "Failed to intiialize reconnect thread: %lu",
 		                 GetLastError());
 }