aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/testing.c
diff options
context:
space:
mode:
authordundargoc <gocdundar@gmail.com>2023-11-13 23:40:37 +0100
committerdundargoc <33953936+dundargoc@users.noreply.github.com>2023-11-19 15:08:35 +0100
commitac1113ded5f8f09dd99a9894d7a7e795626fb728 (patch)
tree9cf615d03efafe2c44e539cb45f1b3df171b3e85 /src/nvim/testing.c
parent1798a4b5e9f0ae56cd800095f79423fea5cae8ca (diff)
downloadrneovim-ac1113ded5f8f09dd99a9894d7a7e795626fb728.tar.gz
rneovim-ac1113ded5f8f09dd99a9894d7a7e795626fb728.tar.bz2
rneovim-ac1113ded5f8f09dd99a9894d7a7e795626fb728.zip
refactor: follow style guide
- reduce variable scope - prefer initialization over declaration and assignment
Diffstat (limited to 'src/nvim/testing.c')
-rw-r--r--src/nvim/testing.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/nvim/testing.c b/src/nvim/testing.c
index f5609a3fb2..d5bb5171fa 100644
--- a/src/nvim/testing.c
+++ b/src/nvim/testing.c
@@ -153,7 +153,6 @@ static void ga_concat_shorten_esc(garray_T *gap, const char *str)
static void fill_assert_error(garray_T *gap, typval_T *opt_msg_tv, const char *exp_str,
typval_T *exp_tv_arg, typval_T *got_tv_arg, assert_type_T atype)
{
- char *tofree;
typval_T *exp_tv = exp_tv_arg;
typval_T *got_tv = got_tv_arg;
bool did_copy = false;
@@ -163,7 +162,7 @@ static void fill_assert_error(garray_T *gap, typval_T *opt_msg_tv, const char *e
&& !(opt_msg_tv->v_type == VAR_STRING
&& (opt_msg_tv->vval.v_string == NULL
|| *opt_msg_tv->vval.v_string == NUL))) {
- tofree = encode_tv2echo(opt_msg_tv, NULL);
+ char *tofree = encode_tv2echo(opt_msg_tv, NULL);
ga_concat(gap, tofree);
xfree(tofree);
ga_concat(gap, ": ");
@@ -224,7 +223,7 @@ static void fill_assert_error(garray_T *gap, typval_T *opt_msg_tv, const char *e
}
}
- tofree = encode_tv2string(exp_tv, NULL);
+ char *tofree = encode_tv2string(exp_tv, NULL);
ga_concat_shorten_esc(gap, tofree);
xfree(tofree);
} else {
@@ -245,7 +244,7 @@ static void fill_assert_error(garray_T *gap, typval_T *opt_msg_tv, const char *e
} else {
ga_concat(gap, " but got ");
}
- tofree = encode_tv2string(got_tv, NULL);
+ char *tofree = encode_tv2string(got_tv, NULL);
ga_concat_shorten_esc(gap, tofree);
xfree(tofree);