From 39a1e1fa19914f6ae7d595c5fb8fd7eb636dcbdc Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Fri, 17 Aug 2018 09:38:48 +1000 Subject: [PATCH] CODING_STLYE: Simplify explanation for use of 'extern' Current explanation of rules around usage of 'extern' are overly verbose. It is not necessary to state that functions should be declared in header files, the compiler already enforces this. These rules are simple, they are better described with simple statements. An example is not necessary for such simple rules and serves only to make the document longer. Use two simple statements describing the rules that govern function declaration and the usage of the 'extern' keyword. Signed-off-by: Tobin C. Harding --- CODING_STYLE.md | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/CODING_STYLE.md b/CODING_STYLE.md index c81015173..7e1cbf326 100644 --- a/CODING_STYLE.md +++ b/CODING_STYLE.md @@ -127,26 +127,8 @@ https://www.kernel.org/doc/html/latest/process/coding-style.html #### All Exported Functions Must Be Declared `extern` In A Header File -- Functions which are used in different files in the library should be declared - in a suitable `*.c` file and exposed in a suitable `*.h` file. When defining - the function in the `*.c` file the function signature should not be preceded - by the `extern` keyword. When declaring the function signature in the `*.h` - file it must be preceded by the `extern` keyword. For example: - ```C - /* Valid function definition in a *.c file */ - ssize_t lxc_write_nointr(int fd, const void* buf, size_t count) - { - ssize_t ret; - again: - ret = write(fd, buf, count); - if (ret < 0 && errno == EINTR) - goto again; - return ret; - } - - /* Valid function declaration in a *.h file */ - extern ssize_t lxc_write_nointr(int fd, const void* buf, size_t count); - ``` +- Functions declared in header files (`*.h`) should use the `extern` keyword. +- Functions declared in source files (`*.c`) should not use the `extern` keyword. #### All Names Must Be In lower_case -- 2.47.2