From ef0d5e3ec9f99003af3ff326384816c02850ea3f Mon Sep 17 00:00:00 2001 From: Borislav Stanimirov Date: Thu, 25 Apr 2024 17:24:07 +0300 Subject: [PATCH] build: fix and ignore msvc warnings (ggml/805) --- ggml-backend.c | 4 ++-- ggml-quants.c | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ggml-backend.c b/ggml-backend.c index f5bdcf078..dd090a583 100644 --- a/ggml-backend.c +++ b/ggml-backend.c @@ -1182,9 +1182,9 @@ static int ggml_backend_sched_backend_id_from_cur(ggml_backend_sched_t sched, st static char * fmt_size(size_t size) { static char buffer[128]; if (size >= 1024*1024) { - sprintf(buffer, "%zuM", size/1024/1024); + snprintf(buffer, sizeof(buffer), "%zuM", size/1024/1024); } else { - sprintf(buffer, "%zuK", size/1024); + snprintf(buffer, sizeof(buffer), "%zuK", size/1024); } return buffer; } diff --git a/ggml-quants.c b/ggml-quants.c index 9883b6f8c..00334c5fe 100644 --- a/ggml-quants.c +++ b/ggml-quants.c @@ -14,6 +14,12 @@ #include // for qsort #include // for GGML_ASSERT +#if defined(_MSC_VER) +// disable "possible loss of data" to avoid warnings for hundreds of casts +// we should just be careful :) +#pragma warning(disable: 4244 4267) +#endif + #define UNUSED GGML_UNUSED // some compilers don't provide _mm256_set_m128i, e.g. gcc 7