Page MenuHomeFreeBSD

Update .clang-format with style(9) header-sorting
ClosedPublic

Authored by cem on Jun 24 2020, 4:51 PM.
Tags
None
Referenced Files
F80103126: D25428.diff
Wed, Mar 27, 10:57 PM
Unknown Object (File)
Feb 15 2024, 5:48 AM
Unknown Object (File)
Jan 19 2024, 2:26 AM
Unknown Object (File)
Jan 15 2024, 7:02 AM
Unknown Object (File)
Dec 29 2023, 2:28 AM
Unknown Object (File)
Dec 28 2023, 2:22 AM
Unknown Object (File)
Dec 22 2023, 11:56 PM
Unknown Object (File)
Dec 22 2023, 11:56 PM
Subscribers

Details

Summary

Thanks to work done in the NetBSD clang-format project.

Test Plan

Example 1:

--- a/sys/kern/uipc_mbuf.c
+++ b/sys/kern/uipc_mbuf.c
@@ -34,105 +34,89 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");

-#include "opt_param.h"
-#include "opt_mbuf_stress_test.h"
 #include "opt_mbuf_profiling.h"
+#include "opt_mbuf_stress_test.h"
+#include "opt_param.h"

 #include <sys/param.h>
-#include <sys/systm.h>
+#include <sys/domain.h>
 #include <sys/kernel.h>
 #include <sys/limits.h>
 #include <sys/lock.h>
 #include <sys/malloc.h>
 #include <sys/mbuf.h>
-#include <sys/sysctl.h>
-#include <sys/domain.h>
 #include <sys/protosw.h>
+#include <sys/sdt.h>
+#include <sys/sysctl.h>
+#include <sys/systm.h>
 #include <sys/uio.h>
 #include <sys/vmmeter.h>
-#include <sys/sdt.h>
+
 #include <vm/vm.h>
-#include <vm/vm_pageout.h>
 #include <vm/vm_page.h>
+#include <vm/vm_pageout.h>

Example 2:

--- a/sys/x86/x86/mp_x86.c
+++ b/sys/x86/x86/mp_x86.c
@@ -39,12 +39,12 @@ __FBSDID("$FreeBSD$");
 #include "opt_stack.h"

 #include <sys/param.h>
-#include <sys/systm.h>
 #include <sys/bus.h>
-#include <sys/cons.h>  /* cngetc() */
+#include <sys/cons.h> /* cngetc() */
 #include <sys/cpuset.h>
 #include <sys/csan.h>
-#ifdef GPROF
+#include <sys/systm.h>
+#ifdef GPROF
 #include <sys/gmon.h>
 #endif
 #include <sys/kdb.h>
@@ -61,32 +61,33 @@ __FBSDID("$FreeBSD$");
 #include <sys/sysctl.h>

 #include <vm/vm.h>
-#include <vm/vm_param.h>
 #include <vm/pmap.h>
-#include <vm/vm_kern.h>
 #include <vm/vm_extern.h>
+#include <vm/vm_kern.h>
 #include <vm/vm_map.h>
+#include <vm/vm_param.h>

-#include <x86/apicreg.h>
 #include <machine/clock.h>
 #include <machine/cpu.h>
 #include <machine/cputypes.h>
-#include <x86/mca.h>
 #include <machine/md_var.h>
 #include <machine/pcb.h>
 #include <machine/psl.h>
 #include <machine/smp.h>
 #include <machine/specialreg.h>
 #include <machine/stack.h>
+
+#include <x86/apicreg.h>
+#include <x86/mca.h>
 #include <x86/ucode.h>

Any objections to the reordering, or suggestions for other test cases?

Diff Detail

Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 31927
Build 29478: arc lint + arc unit

Event Timeline

cem requested review of this revision.Jun 24 2020, 4:51 PM
cem created this revision.
cem added a reviewer: emaste.

I'm not sure off hand of other representative test cases - most likely we can just find them from user feedback as folks start using this.

vm/vm.h must come before vm/pmap.h (and likely all other vm/ headers).

(This is definitely not a complete style(9) .clang-format; the working goal is "less wrong than it was before.")

This seems reasonable to me. Thanks for doing it.

.clang-format
105

I think it should be just `^<(fs|nfs|nfsclient|nfsserver|ufs)/'.

This revision is now accepted and ready to land.Jun 24 2020, 5:19 PM
cem marked an inline comment as done.

Drop miscfs/msdosfs and add nfs{client,server} to top-level include-ordering rule.

This revision now requires review to proceed.Jun 24 2020, 5:36 PM
This revision is now accepted and ready to land.Jun 24 2020, 5:59 PM
This revision was automatically updated to reflect the committed changes.

This is very nice to have codified, although I personally think our header ordering requirements are atrocious. ;-)