summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2019-04-12 16:40:34 +0200
committerLennart Poettering <lennart@poettering.net>2019-04-12 16:40:34 +0200
commit996f119d9740d245aea5932de08a7c91a14faf88 (patch)
tree200aa188e8ec72a3690bb05cc69506e0fe0b1ba8 /docs
parentb065e1f176267245dfb18ee8bc2bd675d382f519 (diff)
downloadsystemd-996f119d9740d245aea5932de08a7c91a14faf88.tar.gz
CODING_STYLE: split out section about command line parsing
Diffstat (limited to 'docs')
-rw-r--r--docs/CODING_STYLE.md25
1 files changed, 13 insertions, 12 deletions
diff --git a/docs/CODING_STYLE.md b/docs/CODING_STYLE.md
index 20f9e10e7a..2809213af5 100644
--- a/docs/CODING_STYLE.md
+++ b/docs/CODING_STYLE.md
@@ -161,11 +161,6 @@ title: Coding Style
`is_main_thread()` to detect whether the calling thread is the main
thread.
-- Command line option parsing:
- - Do not print full `help()` on error, be specific about the error.
- - Do not print messages to stdout on error.
- - Do not POSIX_ME_HARDER unless necessary, i.e. avoid `+` in option string.
-
- Do not write functions that clobber call-by-reference variables on
failure. Use temporary variables for these cases and change the
passed in variables only on success.
@@ -261,13 +256,6 @@ title: Coding Style
global variables, for example data parsed from command lines, see
below.
-- If you parse a command line, and want to store the parsed parameters
- in global variables, please consider prefixing their names with
- `arg_`. We have been following this naming rule in most of our
- tools, and we should continue to do so, as it makes it easy to
- identify command line parameter variables, and makes it clear why it
- is OK that they are global variables.
-
- When exposing public C APIs, be careful what function parameters you make
`const`. For example, a parameter taking a context object should probably not
be `const`, even if you are writing an otherwise read-only accessor function
@@ -469,6 +457,19 @@ title: Coding Style
effect on the regular file. If in doubt consider turning off `O_NONBLOCK`
again after opening.
+## Command Line
+
+- If you parse a command line, and want to store the parsed parameters in
+ global variables, please consider prefixing their names with `arg_`. We have
+ been following this naming rule in most of our tools, and we should continue
+ to do so, as it makes it easy to identify command line parameter variables,
+ and makes it clear why it is OK that they are global variables.
+
+- Command line option parsing:
+ - Do not print full `help()` on error, be specific about the error.
+ - Do not print messages to stdout on error.
+ - Do not POSIX_ME_HARDER unless necessary, i.e. avoid `+` in option string.
+
## Referencing Concepts
- When referring to a configuration file option in the documentation and such,