mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 04:25:18 +00:00
Add a rule for indenting labels
Indent top-level labels by one space. Add the rule to HACKING and enforce it by syntax-check.
This commit is contained in:
parent
5d8793eebb
commit
9af14dadf6
31
HACKING
31
HACKING
@ -232,22 +232,9 @@ but we do prefer that contributed code be formatted similarly. In short, use
|
|||||||
spaces-not-TABs for indentation, use 4 spaces for each indentation level, and
|
spaces-not-TABs for indentation, use 4 spaces for each indentation level, and
|
||||||
other than that, follow the K&R style.
|
other than that, follow the K&R style.
|
||||||
|
|
||||||
If you use Emacs, add the following to one of one of your start-up files
|
If you use Emacs, the project includes a file .dir-locals.el that sets up the
|
||||||
(e.g., ~/.emacs), to help ensure that you get indentation right:
|
preferred indentation. If you use vim, append the following to your ~/.vimrc
|
||||||
|
file:
|
||||||
;;; When editing C sources in libvirt, use this style.
|
|
||||||
(defun libvirt-c-mode ()
|
|
||||||
"C mode with adjusted defaults for use with libvirt."
|
|
||||||
(interactive)
|
|
||||||
(c-set-style "K&R")
|
|
||||||
(setq indent-tabs-mode nil) ; indent using spaces, not TABs
|
|
||||||
(setq c-indent-level 4)
|
|
||||||
(setq c-basic-offset 4))
|
|
||||||
(add-hook 'c-mode-hook
|
|
||||||
'(lambda () (if (string-match "/libvirt" (buffer-file-name))
|
|
||||||
(libvirt-c-mode))))
|
|
||||||
|
|
||||||
If you use vim, append the following to your ~/.vimrc file:
|
|
||||||
|
|
||||||
set nocompatible
|
set nocompatible
|
||||||
filetype on
|
filetype on
|
||||||
@ -257,7 +244,7 @@ If you use vim, append the following to your ~/.vimrc file:
|
|||||||
set tabstop=8
|
set tabstop=8
|
||||||
set shiftwidth=4
|
set shiftwidth=4
|
||||||
set expandtab
|
set expandtab
|
||||||
set cinoptions=(0,:0,l1,t0
|
set cinoptions=(0,:0,l1,t0,L3
|
||||||
filetype plugin indent on
|
filetype plugin indent on
|
||||||
au FileType make setlocal noexpandtab
|
au FileType make setlocal noexpandtab
|
||||||
au BufRead,BufNewFile *.am setlocal noexpandtab
|
au BufRead,BufNewFile *.am setlocal noexpandtab
|
||||||
@ -928,6 +915,16 @@ When using goto, please use one of these standard labels if it makes sense:
|
|||||||
no_memory: A path only taken upon return with an OOM error code
|
no_memory: A path only taken upon return with an OOM error code
|
||||||
retry: If needing to jump upwards (e.g., retry on EINTR)
|
retry: If needing to jump upwards (e.g., retry on EINTR)
|
||||||
|
|
||||||
|
Top-level labels should be indented by one space (putting them on the
|
||||||
|
beginning of the line confuses function context detection in git):
|
||||||
|
|
||||||
|
int foo()
|
||||||
|
{
|
||||||
|
/* ... do stuff ... */
|
||||||
|
cleanup:
|
||||||
|
/* ... do other stuff ... */
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Libvirt committer guidelines
|
Libvirt committer guidelines
|
||||||
============================
|
============================
|
||||||
|
6
cfg.mk
6
cfg.mk
@ -898,6 +898,12 @@ sc_prohibit_virConnectOpen_in_virsh:
|
|||||||
halt='Use vshConnect() in virsh instead of virConnectOpen*' \
|
halt='Use vshConnect() in virsh instead of virConnectOpen*' \
|
||||||
$(_sc_search_regexp)
|
$(_sc_search_regexp)
|
||||||
|
|
||||||
|
sc_require_space_before_label:
|
||||||
|
@prohibit='^( ?)?[_a-zA-Z0-9]+:$$' \
|
||||||
|
in_vc_files='\.[ch]$$' \
|
||||||
|
halt="Top-level labels should be indented by one space" \
|
||||||
|
$(_sc_search_regexp)
|
||||||
|
|
||||||
sc_curly_braces_style:
|
sc_curly_braces_style:
|
||||||
@files=$$($(VC_LIST_EXCEPT) | grep '\.[ch]$$'); \
|
@files=$$($(VC_LIST_EXCEPT) | grep '\.[ch]$$'); \
|
||||||
$(GREP) -nHP \
|
$(GREP) -nHP \
|
||||||
|
@ -273,26 +273,11 @@
|
|||||||
In short, use spaces-not-TABs for indentation, use 4 spaces for each
|
In short, use spaces-not-TABs for indentation, use 4 spaces for each
|
||||||
indentation level, and other than that, follow the K&R style.
|
indentation level, and other than that, follow the K&R style.
|
||||||
</p>
|
</p>
|
||||||
<p>
|
|
||||||
If you use Emacs, add the following to one of one of your start-up files
|
|
||||||
(e.g., ~/.emacs), to help ensure that you get indentation right:
|
|
||||||
</p>
|
|
||||||
<pre>
|
|
||||||
;;; When editing C sources in libvirt, use this style.
|
|
||||||
(defun libvirt-c-mode ()
|
|
||||||
"C mode with adjusted defaults for use with libvirt."
|
|
||||||
(interactive)
|
|
||||||
(c-set-style "K&R")
|
|
||||||
(setq indent-tabs-mode nil) ; indent using spaces, not TABs
|
|
||||||
(setq c-indent-level 4)
|
|
||||||
(setq c-basic-offset 4))
|
|
||||||
(add-hook 'c-mode-hook
|
|
||||||
'(lambda () (if (string-match "/libvirt" (buffer-file-name))
|
|
||||||
(libvirt-c-mode))))
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
If you use vim, append the following to your ~/.vimrc file:
|
If you use Emacs, the project includes a file .dir-locals.el
|
||||||
|
that sets up the preferred indentation. If you use vim,
|
||||||
|
append the following to your ~/.vimrc file:
|
||||||
</p>
|
</p>
|
||||||
<pre>
|
<pre>
|
||||||
set nocompatible
|
set nocompatible
|
||||||
@ -303,7 +288,7 @@
|
|||||||
set tabstop=8
|
set tabstop=8
|
||||||
set shiftwidth=4
|
set shiftwidth=4
|
||||||
set expandtab
|
set expandtab
|
||||||
set cinoptions=(0,:0,l1,t0
|
set cinoptions=(0,:0,l1,t0,L3
|
||||||
filetype plugin indent on
|
filetype plugin indent on
|
||||||
au FileType make setlocal noexpandtab
|
au FileType make setlocal noexpandtab
|
||||||
au BufRead,BufNewFile *.am setlocal noexpandtab
|
au BufRead,BufNewFile *.am setlocal noexpandtab
|
||||||
@ -1139,6 +1124,20 @@
|
|||||||
retry: If needing to jump upwards (e.g., retry on EINTR)
|
retry: If needing to jump upwards (e.g., retry on EINTR)
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Top-level labels should be indented by one space (putting them on
|
||||||
|
the beginning of the line confuses function context detection in git):
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<pre>
|
||||||
|
int foo()
|
||||||
|
{
|
||||||
|
/* ... do stuff ... */
|
||||||
|
cleanup:
|
||||||
|
/* ... do other stuff ... */
|
||||||
|
}
|
||||||
|
</pre>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h2><a name="committers">Libvirt committer guidelines</a></h2>
|
<h2><a name="committers">Libvirt committer guidelines</a></h2>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user