diff mbox series

[v4,08/22] fsck.c: move definition of msg_id into append_msg_id()

Message ID 20210316161738.30254-9-avarab@gmail.com (mailing list archive)
State New, archived
Headers show
Series fsck: API improvements | expand

Commit Message

Ævar Arnfjörð Bjarmason March 16, 2021, 4:17 p.m. UTC
Refactor code added in 71ab8fa840f (fsck: report the ID of the
error/warning, 2015-06-22) to resolve the msg_id to a string in the
function that wants it, instead of doing it in report().

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 fsck.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Junio C Hamano March 17, 2021, 6:45 p.m. UTC | #1
Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:

> Refactor code added in 71ab8fa840f (fsck: report the ID of the
> error/warning, 2015-06-22) to resolve the msg_id to a string in the
> function that wants it, instead of doing it in report().

This reintroduces the same confusion 07/22 tried to get rid of,
unless msg_id variable is renamed to msg_id_str in this step,
instead of being left to the next step, no?


> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
> ---
>  fsck.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/fsck.c b/fsck.c
> index 0a9ac9ca07..b977493f57 100644
> --- a/fsck.c
> +++ b/fsck.c
> @@ -264,8 +264,9 @@ void fsck_set_msg_types(struct fsck_options *options, const char *values)
>  	free(to_free);
>  }
>  
> -static void append_msg_id(struct strbuf *sb, const char *msg_id)
> +static void append_msg_id(struct strbuf *sb, enum fsck_msg_id id)
>  {
> +	const char *msg_id = msg_id_info[id].id_string;
>  	for (;;) {
>  		char c = *(msg_id)++;
>  
> @@ -308,7 +309,7 @@ static int report(struct fsck_options *options,
>  	else if (msg_type == FSCK_INFO)
>  		msg_type = FSCK_WARN;
>  
> -	append_msg_id(&sb, msg_id_info[id].id_string);
> +	append_msg_id(&sb, id);
>  
>  	va_start(ap, fmt);
>  	strbuf_vaddf(&sb, fmt, ap);
diff mbox series

Patch

diff --git a/fsck.c b/fsck.c
index 0a9ac9ca07..b977493f57 100644
--- a/fsck.c
+++ b/fsck.c
@@ -264,8 +264,9 @@  void fsck_set_msg_types(struct fsck_options *options, const char *values)
 	free(to_free);
 }
 
-static void append_msg_id(struct strbuf *sb, const char *msg_id)
+static void append_msg_id(struct strbuf *sb, enum fsck_msg_id id)
 {
+	const char *msg_id = msg_id_info[id].id_string;
 	for (;;) {
 		char c = *(msg_id)++;
 
@@ -308,7 +309,7 @@  static int report(struct fsck_options *options,
 	else if (msg_type == FSCK_INFO)
 		msg_type = FSCK_WARN;
 
-	append_msg_id(&sb, msg_id_info[id].id_string);
+	append_msg_id(&sb, id);
 
 	va_start(ap, fmt);
 	strbuf_vaddf(&sb, fmt, ap);