Subject: Re: [PATCH v9 9/9] cocci: allow padding with `strbuf_addf()`

From: Teng Long <[email-masked]>
Date: Mon, 10 Jan 2022 16:22:54 +0800

I am not sure whether I have sent the email repeatedly, because it is
not shown on mailist. If so, sorry to bother you.

Johannes Schindelin writes:

> Doing this in 9/9 is too late, by this time you already introduced the
> code site that requires this workaround.

Yes, you are correct.
Will fixed if the patch is still remained to next one. 

> At the same time, I wonder why you want to defend spinning up the
> full-blown `printf()` machinery just to pad text that you can easily pad
> yourself. It sounds like a lot of trouble to me to introduce this patch
> and then use an uncommon method to pad a fixed string at runtime. Too much
> trouble for my liking.

I may not have explained it clearly in the cover. Sorry for that, I'm going
to explain some more here, please correct me if there is something wrong or
the method is not recommended or is not best practice in community.

Firstly, the patch needs to be introduced I think and it has nothing to do
with using "      -" or "%7s" here, because the fix recommandation is not
accurate in terms of the "static-analysis" report if someone just uses the
"addf" api:

-               strbuf_addf(line, "%7s", "-");
+               strbuf_addstr(line, "-");

They have different execution results and bring confusion to people. 

Then secondly, about the using "strbuf_addf(line, "%7s" , "-");" or
"strbuf_addstr(line, "      -");". I think you prefer the later and I prefer
the former, right? (I'm not a native English speaker, so I just want to make
sure I understand whole your meannings).

If I understand everything correctly so far, it's good :)

As I metioned in a previous reply [1], I think there is no performance
issue here..

Why I prefer more of the former that is because, for the single line,
it's more readable I think. Maybe it's not going to modify very often,
but If someone want to know what this is, might have to do a count. So
I don't think this is any more readable than "%7s".

Here's what I think and looking forward to your reply.

Thanks.

[1] https://public-inbox.org/git/[email-masked]/