From 5dfecab15c32db91569d91b16318c2ecdc47ae59 Mon Sep 17 00:00:00 2001 From: jp9000 Date: Sun, 8 Feb 2015 15:40:51 -0800 Subject: [PATCH] Fix windows printf format warnings (from mingw) --- libobs-opengl/gl-windows.c | 20 +++++++++---------- libobs/util/platform-windows.c | 2 +- plugins/obs-outputs/librtmp/rtmp.c | 6 +++--- plugins/win-capture/game-capture.c | 10 +++++----- .../get-graphics-offsets.c | 18 ++++++++--------- plugins/win-capture/graphics-hook-info.h | 2 +- .../win-capture/graphics-hook/graphics-hook.c | 8 ++++---- plugins/win-capture/hook-helpers.h | 4 ++-- plugins/win-wasapi/win-wasapi.cpp | 2 +- 9 files changed, 36 insertions(+), 36 deletions(-) diff --git a/libobs-opengl/gl-windows.c b/libobs-opengl/gl-windows.c index b03c78d9c..d7c082605 100644 --- a/libobs-opengl/gl-windows.c +++ b/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"); } } diff --git a/libobs/util/platform-windows.c b/libobs/util/platform-windows.c index 514a8141d..85091c1c0 100644 --- a/libobs/util/platform-windows.c +++ b/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; diff --git a/plugins/obs-outputs/librtmp/rtmp.c b/plugins/obs-outputs/librtmp/rtmp.c index e5f6b653b..d97be101f 100644 --- a/plugins/obs-outputs/librtmp/rtmp.c +++ b/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) diff --git a/plugins/win-capture/game-capture.c b/plugins/win-capture/game-capture.c index b591f6c51..2d7e4af06 100644 --- a/plugins/win-capture/game-capture.c +++ b/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) { diff --git a/plugins/win-capture/get-graphics-offsets/get-graphics-offsets.c b/plugins/win-capture/get-graphics-offsets/get-graphics-offsets.c index 091973954..d05a4e98a 100644 --- a/plugins/win-capture/get-graphics-offsets/get-graphics-offsets.c +++ b/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; diff --git a/plugins/win-capture/graphics-hook-info.h b/plugins/win-capture/graphics-hook-info.h index ea4bbc390..3240c9091 100644 --- a/plugins/win-capture/graphics-hook-info.h +++ b/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); diff --git a/plugins/win-capture/graphics-hook/graphics-hook.c b/plugins/win-capture/graphics-hook/graphics-hook.c index b61706d59..2e769e73c 100644 --- a/plugins/win-capture/graphics-hook/graphics-hook.c +++ b/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()) { diff --git a/plugins/win-capture/hook-helpers.h b/plugins/win-capture/hook-helpers.h index f0e7610b4..b7febd483 100644 --- a/plugins/win-capture/hook-helpers.h +++ b/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); } diff --git a/plugins/win-wasapi/win-wasapi.cpp b/plugins/win-wasapi/win-wasapi.cpp index 4e0dab2fd..9ca7711d7 100644 --- a/plugins/win-wasapi/win-wasapi.cpp +++ b/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()); }