refactor: follow style guide

- reduce variable scope
- prefer initialization over declaration and assignment
This commit is contained in:
dundargoc
2023-11-13 23:40:37 +01:00
committed by dundargoc
parent 1798a4b5e9
commit ac1113ded5
52 changed files with 713 additions and 1269 deletions

View File

@@ -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);