diff options
author | David Young <dyoung@hdfgroup.org> | 2019-12-20 17:41:06 (GMT) |
---|---|---|
committer | David Young <dyoung@hdfgroup.org> | 2019-12-20 17:41:06 (GMT) |
commit | 7d6dc4d0d43a6fd2576d4954b2caaa8c5582a18f (patch) | |
tree | 430374c13f9c24b6999ab7f8dcdd4314ca763224 /doc | |
parent | 934e8d7e83606e9ffe26a7d87b3aa27d44cd3848 (diff) | |
download | hdf5-7d6dc4d0d43a6fd2576d4954b2caaa8c5582a18f.zip hdf5-7d6dc4d0d43a6fd2576d4954b2caaa8c5582a18f.tar.gz hdf5-7d6dc4d0d43a6fd2576d4954b2caaa8c5582a18f.tar.bz2 |
Try to fix a numbered list.
Diffstat (limited to 'doc')
-rw-r--r-- | doc/linux-coding-style.md | 128 |
1 files changed, 63 insertions, 65 deletions
diff --git a/doc/linux-coding-style.md b/doc/linux-coding-style.md index 85b7335..91e1f63 100644 --- a/doc/linux-coding-style.md +++ b/doc/linux-coding-style.md @@ -65,71 +65,69 @@ Anyway, here goes: 1) Indentation -Tabs are 8 characters, and thus indentations are also 8 characters. -There are heretic movements that try to make indentations 4 (or even 2!) -characters deep, and that is akin to trying to define the value of PI to -be 3. - -Rationale: The whole idea behind indentation is to clearly define where -a block of control starts and ends. Especially when you've been looking -at your screen for 20 straight hours, you'll find it a lot easier to see -how the indentation works if you have large indentations. - -Now, some people will claim that having 8-character indentations makes -the code move too far to the right, and makes it hard to read on a -80-character terminal screen. The answer to that is that if you need -more than 3 levels of indentation, you're screwed anyway, and should fix -your program. - -In short, 8-char indents make things easier to read, and have the added -benefit of warning you when you're nesting your functions too deep. Heed -that warning. - -The preferred way to ease multiple indentation levels in a switch -statement is to align the `switch`{.docutils .literal} and its -subordinate `case`{.docutils .literal} labels in the same column instead -of `double-indenting`{.docutils .literal} the `case`{.docutils .literal} -labels. E.g.: - -``` - switch (suffix) { - case 'G': - case 'g': - mem <<= 30; - break; - case 'M': - case 'm': - mem <<= 20; - break; - case 'K': - case 'k': - mem <<= 10; - /* fall through */ - default: - break; - } -``` - -Don't put multiple statements on a single line unless you have something -to hide: - -``` - if (condition) do_this; - do_something_everytime; -``` - -Don't put multiple assignments on a single line either. Kernel coding -style is super simple. Avoid tricky expressions. - -Outside of comments, documentation and except in Kconfig, spaces are -never used for indentation, and the above example is deliberately -broken. - -Get a decent editor and don't leave whitespace at the end of lines. -::: - -::: {#breaking-long-lines-and-strings .section} -2) Breaking long lines and strings[ΒΆ](#breaking-long-lines-and-strings "Permalink to this headline"){.headerlink} + Tabs are 8 characters, and thus indentations are also 8 characters. + There are heretic movements that try to make indentations 4 (or even 2!) + characters deep, and that is akin to trying to define the value of PI to + be 3. + + Rationale: The whole idea behind indentation is to clearly define where + a block of control starts and ends. Especially when you've been looking + at your screen for 20 straight hours, you'll find it a lot easier to see + how the indentation works if you have large indentations. + + Now, some people will claim that having 8-character indentations makes + the code move too far to the right, and makes it hard to read on a + 80-character terminal screen. The answer to that is that if you need + more than 3 levels of indentation, you're screwed anyway, and should fix + your program. + + In short, 8-char indents make things easier to read, and have the added + benefit of warning you when you're nesting your functions too deep. Heed + that warning. + + The preferred way to ease multiple indentation levels in a switch + statement is to align the `switch`{.docutils .literal} and its + subordinate `case`{.docutils .literal} labels in the same column instead + of `double-indenting`{.docutils .literal} the `case`{.docutils .literal} + labels. E.g.: + + ``` + switch (suffix) { + case 'G': + case 'g': + mem <<= 30; + break; + case 'M': + case 'm': + mem <<= 20; + break; + case 'K': + case 'k': + mem <<= 10; + /* fall through */ + default: + break; + } + ``` + + Don't put multiple statements on a single line unless you have something + to hide: + + ``` + if (condition) do_this; + do_something_everytime; + ``` + + Don't put multiple assignments on a single line either. Kernel coding + style is super simple. Avoid tricky expressions. + + Outside of comments, documentation and except in Kconfig, spaces are + never used for indentation, and the above example is deliberately + broken. + + Get a decent editor and don't leave whitespace at the end of lines. + +2) <a name="breaking-long-lines-and-strings">Breaking long lines and strings</a> Coding style is all about readability and maintainability using commonly available tools. |