aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorForrest Fleming <ffleming@gmail.com>2016-02-22 14:28:19 -0800
committerForrest Fleming <ffleming@gmail.com>2016-02-23 08:27:27 -0800
commit7feef42e8a5324b3a01e6ce3442b795d5f680b04 (patch)
treea24fd184bd0f5580976ed0eb89f95fe493614e4d
parent37d60042515f1dd37571f0df3af3936d1b0a9615 (diff)
downloadrneovim-7feef42e8a5324b3a01e6ce3442b795d5f680b04.tar.gz
rneovim-7feef42e8a5324b3a01e6ce3442b795d5f680b04.tar.bz2
rneovim-7feef42e8a5324b3a01e6ce3442b795d5f680b04.zip
coverity/71530: Prefer STRLCPY to STRCPY in option.c
Addresses Coverity CID 71530 Prefer sizeof(NameBuff) Add braces for Travis lint Break long line Properly align parameters in multi-line function call
-rw-r--r--src/nvim/option.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/nvim/option.c b/src/nvim/option.c
index 0f6874e941..af7b272467 100644
--- a/src/nvim/option.c
+++ b/src/nvim/option.c
@@ -5947,13 +5947,17 @@ option_value2string (
if (opp->flags & P_NUM) {
long wc = 0;
- if (wc_use_keyname(varp, &wc))
- STRCPY(NameBuff, get_special_key_name((int)wc, 0));
- else if (wc != 0)
- STRCPY(NameBuff, transchar((int)wc));
- else
- sprintf((char *)NameBuff, "%" PRId64, (int64_t)*(long *)varp);
- } else { /* P_STRING */
+ if (wc_use_keyname(varp, &wc)) {
+ STRLCPY(NameBuff, get_special_key_name((int)wc, 0), sizeof(NameBuff));
+ } else if (wc != 0) {
+ STRLCPY(NameBuff, transchar((int)wc), sizeof(NameBuff));
+ } else {
+ snprintf((char *)NameBuff,
+ sizeof(NameBuff),
+ "%" PRId64,
+ (int64_t)*(long *)varp);
+ }
+ } else { // P_STRING
varp = *(char_u **)(varp);
if (varp == NULL) /* just in case */
NameBuff[0] = NUL;