Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lxc
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
lxc
Commits
b629739c
Unverified
Commit
b629739c
authored
Mar 02, 2018
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CODING_STYLE: arrays of structs
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
c67cb619
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
108 additions
and
0 deletions
+108
-0
CODING_STYLE.md
CODING_STYLE.md
+108
-0
No files found.
CODING_STYLE.md
View file @
b629739c
...
@@ -24,6 +24,7 @@
...
@@ -24,6 +24,7 @@
following options:
following options:
```sh
```sh
cat << EOF > "${HOME}"/.clang-format
cat << EOF > "${HOME}"/.clang-format
AlignEscapedNewlines: Left
BreakBeforeBraces: Attach
BreakBeforeBraces: Attach
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakBeforeMultilineStrings: false
BreakBeforeBinaryOperators: None
BreakBeforeBinaryOperators: None
...
@@ -554,3 +555,110 @@ rules to use them:
...
@@ -554,3 +555,110 @@ rules to use them:
-
When
`fork()`
ing off a child process use
`_exit()`
to terminate it instead of
-
When
`fork()`
ing off a child process use
`_exit()`
to terminate it instead of
`exit()`
. The
`exit()`
function is not thread-safe and thus not suited for
`exit()`
. The
`exit()`
function is not thread-safe and thus not suited for
the shared library which must ensure that it is thread-safe.
the shared library which must ensure that it is thread-safe.
#### Keep Arrays of `struct`s Aligned Horizontally When Initializing
-
Arrays of
`struct`
s are:
```
struct foo_struct {
int n;
int m;
int p;
};
struct foo_struct new_instance[] = {
{ 1, 2, 3 },
{ 4, 5, 6 },
{ 7, 8, 9 },
};
```
-
Leave a single space after the opening
`{`
and before closing
`}`
of the
largest member of the last column.
-
Always leave a single space between the largest member of the current column
and the member in the next column.
-
A good example is
```
struct signame {
int num;
const char *name;
};
static const struct signame signames[] = {
{ SIGHUP, "HUP" },
{ SIGINT, "INT" },
{ SIGQUIT, "QUIT" },
{ SIGILL, "ILL" },
{ SIGABRT, "ABRT" },
{ SIGFPE, "FPE" },
{ SIGKILL, "KILL" },
{ SIGSEGV, "SEGV" },
{ SIGPIPE, "PIPE" },
{ SIGALRM, "ALRM" },
{ SIGTERM, "TERM" },
{ SIGUSR1, "USR1" },
{ SIGUSR2, "USR2" },
{ SIGCHLD, "CHLD" },
{ SIGCONT, "CONT" },
{ SIGSTOP, "STOP" },
{ SIGTSTP, "TSTP" },
{ SIGTTIN, "TTIN" },
{ SIGTTOU, "TTOU" },
#ifdef SIGTRAP
{ SIGTRAP, "TRAP" },
#endif
#ifdef SIGIOT
{ SIGIOT, "IOT" },
#endif
#ifdef SIGEMT
{ SIGEMT, "EMT" },
#endif
#ifdef SIGBUS
{ SIGBUS, "BUS" },
#endif
#ifdef SIGSTKFLT
{ SIGSTKFLT, "STKFLT" },
#endif
#ifdef SIGCLD
{ SIGCLD, "CLD" },
#endif
#ifdef SIGURG
{ SIGURG, "URG" },
#endif
#ifdef SIGXCPU
{ SIGXCPU, "XCPU" },
#endif
#ifdef SIGXFSZ
{ SIGXFSZ, "XFSZ" },
#endif
#ifdef SIGVTALRM
{ SIGVTALRM, "VTALRM" },
#endif
#ifdef SIGPROF
{ SIGPROF, "PROF" },
#endif
#ifdef SIGWINCH
{ SIGWINCH, "WINCH" },
#endif
#ifdef SIGIO
{ SIGIO, "IO" },
#endif
#ifdef SIGPOLL
{ SIGPOLL, "POLL" },
#endif
#ifdef SIGINFO
{ SIGINFO, "INFO" },
#endif
#ifdef SIGLOST
{ SIGLOST, "LOST" },
#endif
#ifdef SIGPWR
{ SIGPWR, "PWR" },
#endif
#ifdef SIGUNUSED
{ SIGUNUSED, "UNUSED" },
#endif
#ifdef SIGSYS
{ SIGSYS, "SYS" },
#endif
};
```
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment