From d7e4449adbd483512580a2a9e823190b61f2aa53 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 15 Apr 2018 19:33:50 +0300 Subject: ex_docmd: Fix PVS/V547: due to short-circuiting name_len is never > 4 --- src/nvim/ex_docmd.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/nvim/ex_docmd.c') diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 4b37abab9e..f39c996902 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -5181,11 +5181,13 @@ static void ex_command(exarg_T *eap) p = skipwhite(end); } - /* Get the name (if any) and skip to the following argument */ + // Get the name (if any) and skip to the following argument. name = p; - if (ASCII_ISALPHA(*p)) - while (ASCII_ISALNUM(*p)) - ++p; + if (ASCII_ISALPHA(*p)) { + while (ASCII_ISALNUM(*p)) { + p++; + } + } if (!ends_excmd(*p) && !ascii_iswhite(*p)) { EMSG(_("E182: Invalid command name")); return; @@ -5203,8 +5205,7 @@ static void ex_command(exarg_T *eap) EMSG(_("E183: User defined commands must start with an uppercase letter")); return; } else if ((name_len == 1 && *name == 'X') - || (name_len <= 4 - && STRNCMP(name, "Next", name_len > 4 ? 4 : name_len) == 0)) { + || (name_len <= 4 && STRNCMP(name, "Next", name_len) == 0)) { EMSG(_("E841: Reserved name, cannot be used for user defined command")); return; } else -- cgit From cad616c94ecf94a2abd959e3c09886c00c5afb3f Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 15 Apr 2018 19:36:03 +0300 Subject: ex_docmd: Fix PVS/V547: condition was already checked in surr. if() --- src/nvim/ex_docmd.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'src/nvim/ex_docmd.c') diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index f39c996902..33e2805538 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -5669,22 +5669,21 @@ static void do_ucmd(exarg_T *eap) if (start != NULL) end = vim_strchr(start + 1, '>'); if (buf != NULL) { - for (ksp = p; *ksp != NUL && *ksp != K_SPECIAL; ++ksp) - ; + for (ksp = p; *ksp != NUL && *ksp != K_SPECIAL; ksp++) { + } if (*ksp == K_SPECIAL && (start == NULL || ksp < start || end == NULL) - && ((ksp[1] == KS_SPECIAL && ksp[2] == KE_FILLER) - )) { - /* K_SPECIAL has been put in the buffer as K_SPECIAL - * KS_SPECIAL KE_FILLER, like for mappings, but - * do_cmdline() doesn't handle that, so convert it back. - * Also change K_SPECIAL KS_EXTRA KE_CSI into CSI. */ + && (ksp[1] == KS_SPECIAL && ksp[2] == KE_FILLER)) { + // K_SPECIAL has been put in the buffer as K_SPECIAL + // KS_SPECIAL KE_FILLER, like for mappings, but + // do_cmdline() doesn't handle that, so convert it back. + // Also change K_SPECIAL KS_EXTRA KE_CSI into CSI. len = ksp - p; if (len > 0) { memmove(q, p, len); q += len; } - *q++ = ksp[1] == KS_SPECIAL ? K_SPECIAL : CSI; + *q++ = K_SPECIAL; p = ksp + 3; continue; } -- cgit