build: enable MSVC level 3 warnings (#21934)

MSVC has 4 different warning levels: 1 (severe), 2 (significant), 3
(production quality) and 4 (informational). Enabling level 3 warnings
mostly revealed conversion problems, similar to GCC/clang -Wconversion
flag.
This commit is contained in:
dundargoc
2023-02-11 10:25:24 +01:00
committed by GitHub
parent c8c930ea78
commit 7224c889e0
32 changed files with 192 additions and 173 deletions

View File

@@ -531,15 +531,13 @@ static void uc_list(char *name, size_t name_len)
if (a & (EX_RANGE | EX_COUNT)) {
if (a & EX_COUNT) {
// -count=N
snprintf(IObuff + len, IOSIZE, "%" PRId64 "c",
(int64_t)cmd->uc_def);
snprintf(IObuff + len, IOSIZE, "%" PRId64 "c", cmd->uc_def);
len += (int)strlen(IObuff + len);
} else if (a & EX_DFLALL) {
IObuff[len++] = '%';
} else if (cmd->uc_def >= 0) {
// -range=N
snprintf(IObuff + len, IOSIZE, "%" PRId64 "",
(int64_t)cmd->uc_def);
snprintf(IObuff + len, IOSIZE, "%" PRId64 "", cmd->uc_def);
len += (int)strlen(IObuff + len);
} else {
IObuff[len++] = '.';
@@ -862,9 +860,9 @@ char *uc_validate_name(char *name)
/// This function takes ownership of compl_arg, compl_luaref, and luaref.
///
/// @return OK if the command is created, FAIL otherwise.
int uc_add_command(char *name, size_t name_len, const char *rep, uint32_t argt, long def, int flags,
int compl, char *compl_arg, LuaRef compl_luaref, LuaRef preview_luaref,
cmd_addr_T addr_type, LuaRef luaref, bool force)
int uc_add_command(char *name, size_t name_len, const char *rep, uint32_t argt, int64_t def,
int flags, int compl, char *compl_arg, LuaRef compl_luaref,
LuaRef preview_luaref, cmd_addr_T addr_type, LuaRef luaref, bool force)
FUNC_ATTR_NONNULL_ARG(1, 3)
{
ucmd_T *cmd = NULL;
@@ -1540,13 +1538,13 @@ static size_t uc_check_code(char *code, size_t len, char *buf, ucmd_T *cmd, exar
case ct_RANGE:
case ct_COUNT: {
char num_buf[20];
long num = (type == ct_LINE1) ? eap->line1 :
(type == ct_LINE2) ? eap->line2 :
(type == ct_RANGE) ? eap->addr_count :
(eap->addr_count > 0) ? eap->line2 : cmd->uc_def;
int64_t num = (type == ct_LINE1) ? eap->line1 :
(type == ct_LINE2) ? eap->line2 :
(type == ct_RANGE) ? eap->addr_count :
(eap->addr_count > 0) ? eap->line2 : cmd->uc_def;
size_t num_len;
snprintf(num_buf, sizeof(num_buf), "%" PRId64, (int64_t)num);
snprintf(num_buf, sizeof(num_buf), "%" PRId64, num);
num_len = strlen(num_buf);
result = num_len;
@@ -1783,7 +1781,7 @@ Dictionary commands_array(buf_T *buf)
Object obj = NIL;
if (cmd->uc_argt & EX_COUNT) {
if (cmd->uc_def >= 0) {
snprintf(str, sizeof(str), "%" PRId64, (int64_t)cmd->uc_def);
snprintf(str, sizeof(str), "%" PRId64, cmd->uc_def);
obj = STRING_OBJ(cstr_to_string(str)); // -count=N
} else {
obj = STRING_OBJ(cstr_to_string("0")); // -count
@@ -1796,7 +1794,7 @@ Dictionary commands_array(buf_T *buf)
if (cmd->uc_argt & EX_DFLALL) {
obj = STRING_OBJ(cstr_to_string("%")); // -range=%
} else if (cmd->uc_def >= 0) {
snprintf(str, sizeof(str), "%" PRId64, (int64_t)cmd->uc_def);
snprintf(str, sizeof(str), "%" PRId64, cmd->uc_def);
obj = STRING_OBJ(cstr_to_string(str)); // -range=N
} else {
obj = STRING_OBJ(cstr_to_string(".")); // -range