Let me help with a sales pitch for pool_foreach2(): in this form one can set 
gdb breakpoints in the loop body. All by itself, that's a good enough reason to 
switch...

Thanks for this one!

Dave


-----Original Message-----
From: vpp-dev@lists.fd.io <vpp-dev@lists.fd.io> On Behalf Of Damjan Marion via 
lists.fd.io
Sent: Sunday, December 13, 2020 7:16 AM
To: vpp-dev <vpp-dev@lists.fd.io>
Subject: [vpp-dev] move to clang-format


Hi,

I was playing a bit with clang-format as replacement to gnu indent which we use 
today[1].

While it is impossible to render exact same result like gnu indent, good thing 
is that clang-format can be used only on lines which are changed in the diff so 
no major reformat is needed. My patch deos exactly that.

Another good thing is that clang-format can learn about custom foreach macros 
se we can significantly reduce amount of INDENT-OFF/INDENT-ON sections in the 
code. It also properly formats registration macros like VLIB_REGISTER_NODE() 
which again means less INDENT-OFF/INDENT-ON.

What it cannot deal with is macros which include body of function as argument. 
Three most popular ones are pool_foreach, pool_foreach_index and 
clib_bitmap_foreach. To address this I created patch[2] which adds simpler 
variant of the macros. Instead of writing 

pool_foreach (e, pool ({
  /* some code */
}));

New macro looks like:

pool_foreach2 (e, pool)
  /* some code */

Here we have option to either maintain both macros, or do one-shot replacement.

As we plan to move to ubuntu 20.04 post 21.01 release, and that comes with lot 
of gnu indent pain, it might be also good time to move to clang-format. It is 
obvious that gnu indent is on the sunset of it’s existence and no new 
development happening for years.

Thoughts?

— 
Damjan

[1] https://gerrit.fd.io/r/c/vpp/+/30395
[2] https://gerrit.fd.io/r/c/vpp/+/30393


-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#18321): https://lists.fd.io/g/vpp-dev/message/18321
Mute This Topic: https://lists.fd.io/mt/78925374/21656
Group Owner: vpp-dev+ow...@lists.fd.io
Unsubscribe: https://lists.fd.io/g/vpp-dev/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to