Damjan Marion <[email protected]> writes:

On 19 May 2019, at 18:43, Christian Hopps <[email protected]> wrote:

Hi vpp-devs,

Having gotten bit by a checkstyle failure on my first submission, I decided to port the 
"go-like" functionality of auto-formatting the file (using indent since that's 
what vpp uses) on file save in Emacs.. Here's the lisp

https://gist.github.com/choppsv1/c45a857ced56d4f9713eb7a555cfba2d

in case anyone would find it useful too. Personally, I like clang-format better 
(as it appears to have deterministic results), but that's not what the project 
chose. :)

That was not the case some time ago when I was comparing outputs of 
clang-format 4.0 and 5.0. They were producing quite different outputs for GNU 
mode.
Maybe it is more stable today, but at that time it was quite bad...

Maybe it's better now, not sure. The case I ran into with indent was in 
ikev2.c, and clang format didn't have an issue with it (or the other files I've 
touched so far which admittedly is not that many).

#+begin_src c
                          hash_set (
                              km->per_thread_data[thread_index].sa_by_rspi,
                              sa0->rspi,
                              sa0 - km->per_thread_data[thread_index].sas);
#+end_src

The diff shows the results between first and second run of indent (the 
emacs-lisp I posted does 2 runs to make sure there are no diffs and doesn't 
perform the indent if so, but does display the diff).

#+begin_src diff
--- /tmp/vppfmt1sr7Cv3  2019-05-19 16:10:39.413561001 -0400
+++ /tmp/vppfmt248sTEv  2019-05-19 16:10:39.413561001 -0400
@@ -2168,8 +2168,9 @@
                          pool_get (km->per_thread_data[thread_index].sas,
                                    sa0);
                          clib_memcpy_fast (sa0, &sa, sizeof (*sa0));
-                         hash_set (km->per_thread_data[thread_index].
-                                   sa_by_rspi, sa0->rspi,
+                         hash_set (km->
+                                   per_thread_data[thread_index].sa_by_rspi,
+                                   sa0->rspi,
                                    sa0 -
                                    km->per_thread_data[thread_index].sas);
                        }
#+end_src


Thanks,
Chris.



FWIW, it only does the re-format on save if the file contains the magic string:

"fd.io coding-style-patch-verification: ON"

Attachment: signature.asc
Description: PGP signature

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.

View/Reply Online (#13092): https://lists.fd.io/g/vpp-dev/message/13092
Mute This Topic: https://lists.fd.io/mt/31675798/21656
Group Owner: [email protected]
Unsubscribe: https://lists.fd.io/g/vpp-dev/unsub  [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to