summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndre Weissflog <floooh@gmail.com>2019-12-05 13:38:11 +0100
committerAndre Weissflog <floooh@gmail.com>2019-12-05 13:38:11 +0100
commit89f270395a958604cf1af4d5e2b5d0a75b6cc496 (patch)
treefb5025c8d9ccdd1ae8dbb477d14ca82f6ec9389c
parentbc80da357ad3913dc87b6ba46f089c3ddf0f0e9a (diff)
Fix MSVC 2017 /W4 warnings
-rw-r--r--sokol_app.h3
-rw-r--r--sokol_fetch.h69
-rw-r--r--sokol_gfx.h14
3 files changed, 45 insertions, 41 deletions
diff --git a/sokol_app.h b/sokol_app.h
index 0ef4d705..7f5843a4 100644
--- a/sokol_app.h
+++ b/sokol_app.h
@@ -879,6 +879,7 @@ SOKOL_API_DECL const void* sapp_android_get_native_activity(void);
#pragma warning(disable:4054) /* 'type cast': from function pointer */
#pragma warning(disable:4055) /* 'type cast': from data pointer */
#pragma warning(disable:4505) /* unreferenced local function has been removed */
+#pragma warning(disable:4115) /* /W4: 'ID3D11ModuleInstance': named type definition in parentheses (in d3d11.h) */
#endif
#include <string.h> /* memset */
@@ -4679,7 +4680,7 @@ _SOKOL_PRIVATE void _sapp_run(const sapp_desc* desc) {
static char** _sapp_win32_command_line_to_utf8_argv(LPWSTR w_command_line, int* o_argc) {
int argc = 0;
- char** argv;
+ char** argv = 0;
char* args;
LPWSTR* w_argv = CommandLineToArgvW(w_command_line, &argc);
diff --git a/sokol_fetch.h b/sokol_fetch.h
index 309b7d68..1641856c 100644
--- a/sokol_fetch.h
+++ b/sokol_fetch.h
@@ -1663,7 +1663,7 @@ _SOKOL_PRIVATE bool _sfetch_thread_init(_sfetch_thread_t* thread, _sfetch_thread
EnterCriticalSection(&thread->running_critsec);
const SIZE_T stack_size = 512 * 1024;
- thread->thread = CreateThread(NULL, 512*1024, thread_func, thread_arg, 0, NULL);
+ thread->thread = CreateThread(NULL, stack_size, thread_func, thread_arg, 0, NULL);
thread->valid = (NULL != thread->thread);
LeaveCriticalSection(&thread->running_critsec);
return thread->valid;
@@ -2271,38 +2271,41 @@ _SOKOL_PRIVATE void _sfetch_channel_dowork(_sfetch_channel_t* chn, _sfetch_pool_
/*=== private high-level functions ===========================================*/
_SOKOL_PRIVATE bool _sfetch_validate_request(_sfetch_t* ctx, const sfetch_request_t* req) {
#if defined(SOKOL_DEBUG)
- if (req->channel >= ctx->desc.num_channels) {
- SOKOL_LOG("_sfetch_validate_request: request.num_channels too big!");
- return false;
- }
- if (!req->path) {
- SOKOL_LOG("_sfetch_validate_request: request.path is null!");
- return false;
- }
- if (strlen(req->path) >= (SFETCH_MAX_PATH-1)) {
- SOKOL_LOG("_sfetch_validate_request: request.path is too long (must be < SFETCH_MAX_PATH-1)");
- return false;
- }
- if (!req->callback) {
- SOKOL_LOG("_sfetch_validate_request: request.callback missing");
- return false;
- }
- if (req->chunk_size > req->buffer_size) {
- SOKOL_LOG("_sfetch_validate_request: request.stream_size is greater request.buffer_size)");
- return false;
- }
- if (req->user_data_ptr && (req->user_data_size == 0)) {
- SOKOL_LOG("_sfetch_validate_request: request.user_data_ptr is set, but req.user_data_size is null");
- return false;
- }
- if (!req->user_data_ptr && (req->user_data_size > 0)) {
- SOKOL_LOG("_sfetch_validate_request: request.user_data_ptr is null, but req.user_data_size is not");
- return false;
- }
- if (req->user_data_size > SFETCH_MAX_USERDATA_UINT64 * sizeof(uint64_t)) {
- SOKOL_LOG("_sfetch_validate_request: request.user_data_size is too big (see SFETCH_MAX_USERDATA_UINT64");
- return false;
- }
+ if (req->channel >= ctx->desc.num_channels) {
+ SOKOL_LOG("_sfetch_validate_request: request.num_channels too big!");
+ return false;
+ }
+ if (!req->path) {
+ SOKOL_LOG("_sfetch_validate_request: request.path is null!");
+ return false;
+ }
+ if (strlen(req->path) >= (SFETCH_MAX_PATH-1)) {
+ SOKOL_LOG("_sfetch_validate_request: request.path is too long (must be < SFETCH_MAX_PATH-1)");
+ return false;
+ }
+ if (!req->callback) {
+ SOKOL_LOG("_sfetch_validate_request: request.callback missing");
+ return false;
+ }
+ if (req->chunk_size > req->buffer_size) {
+ SOKOL_LOG("_sfetch_validate_request: request.stream_size is greater request.buffer_size)");
+ return false;
+ }
+ if (req->user_data_ptr && (req->user_data_size == 0)) {
+ SOKOL_LOG("_sfetch_validate_request: request.user_data_ptr is set, but req.user_data_size is null");
+ return false;
+ }
+ if (!req->user_data_ptr && (req->user_data_size > 0)) {
+ SOKOL_LOG("_sfetch_validate_request: request.user_data_ptr is null, but req.user_data_size is not");
+ return false;
+ }
+ if (req->user_data_size > SFETCH_MAX_USERDATA_UINT64 * sizeof(uint64_t)) {
+ SOKOL_LOG("_sfetch_validate_request: request.user_data_size is too big (see SFETCH_MAX_USERDATA_UINT64");
+ return false;
+ }
+ #else
+ /* silence unused warnings in release*/
+ (void)(ctx && req);
#endif
return true;
}
diff --git a/sokol_gfx.h b/sokol_gfx.h
index 9249ad8b..0ce5b07d 100644
--- a/sokol_gfx.h
+++ b/sokol_gfx.h
@@ -2175,6 +2175,13 @@ SOKOL_API_DECL void sg_discard_context(sg_context ctx_id);
#define SG_DEFAULT_CLEAR_STENCIL (0)
#endif
+#ifdef _MSC_VER
+#pragma warning(push)
+#pragma warning(disable:4201) /* nonstandard extension used: nameless struct/union */
+#pragma warning(disable:4115) /* named type definition in parentheses */
+#pragma warning(disable:4505) /* unreferenced local function has been removed */
+#endif
+
#if defined(SOKOL_GLCORE33) || defined(SOKOL_GLES2) || defined(SOKOL_GLES3)
#ifndef GL_UNSIGNED_INT_2_10_10_10_REV
#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368
@@ -2323,13 +2330,6 @@ SOKOL_API_DECL void sg_discard_context(sg_context ctx_id);
#endif
#endif
-#ifdef _MSC_VER
-#pragma warning(push)
-#pragma warning(disable:4201) /* nonstandard extension used: nameless struct/union */
-#pragma warning(disable:4115) /* named type definition in parentheses */
-#pragma warning(disable:4505) /* unreferenced local function has been removed */
-#endif
-
/*=== PRIVATE DECLS ==========================================================*/
/* resource pool slots */