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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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/CADMgQSRxko6nC0zfDiVVfL2ZkdQVbBq0s59Er+6Nmg9vz4uJKQ@xxxxxxxxxxxxxx/



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux