Fix Spectre warnings for MSVC
This commit is contained in:
parent
8d8fcf9dc5
commit
ce656a6275
@ -1,6 +1,7 @@
|
|||||||
#include "cpath.h"
|
#include "cpath.h"
|
||||||
#include "aliases.h"
|
#include "aliases.h"
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
#include <stdbool.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
@ -47,7 +48,10 @@ void dirup(char *dst, u64 levels, const char *path) {
|
|||||||
|
|
||||||
char tmp[256];
|
char tmp[256];
|
||||||
sprintf(tmp, "%c", PATH_SEP);
|
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;
|
copy_count = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user