From ce656a6275fcbaca5db3d6ba5cc57a5270baad69 Mon Sep 17 00:00:00 2001 From: Abdelrahman Said Date: Sun, 6 Oct 2024 19:54:13 +0100 Subject: [PATCH] Fix Spectre warnings for MSVC --- src/core/cpath/cpath.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/core/cpath/cpath.c b/src/core/cpath/cpath.c index 35b3829..6629d1c 100644 --- a/src/core/cpath/cpath.c +++ b/src/core/cpath/cpath.c @@ -1,6 +1,7 @@ #include "cpath.h" #include "aliases.h" #include +#include #include #include @@ -47,7 +48,10 @@ void dirup(char *dst, u64 levels, const char *path) { char tmp[256]; sprintf(tmp, "%c", PATH_SEP); - if (sep_count < levels && strncmp(path, tmp, copy_count) != 0) { + // NOTE (Abdelrahman): Conditions stored in variables to silence MSVC warning C5045 + bool insufficient_levels = sep_count < levels; + bool path_to_copy_is_separator = strncmp(path, tmp, copy_count) != 0; + if (insufficient_levels && path_to_copy_is_separator) { copy_count = 0; }