]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commitdiff
build: fix and ignore msvc warnings (ggml/805)
authorBorislav Stanimirov <redacted>
Thu, 25 Apr 2024 14:24:07 +0000 (17:24 +0300)
committerGeorgi Gerganov <redacted>
Sat, 11 May 2024 12:38:34 +0000 (15:38 +0300)
ggml-backend.c
ggml-quants.c

index f5bdcf07838aa45b224a900e1d6b4daf62ffb1c4..dd090a583f685c6f5508b1df654f9b933ae7af68 100644 (file)
@@ -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;
 }
index 9883b6f8cabbb10a1cf99c4fb697f56b15d09280..00334c5feb3f32d6a4a2069f9a83e04610a5296f 100644 (file)
 #include <stdlib.h> // for qsort
 #include <stdio.h>  // 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