]> git.proxmox.com Git - mirror_lxc.git/commitdiff
CODING_STLYE: Simplify explanation for use of 'extern'
authorTobin C. Harding <me@tobin.cc>
Thu, 16 Aug 2018 23:38:48 +0000 (09:38 +1000)
committerTobin C. Harding <me@tobin.cc>
Fri, 17 Aug 2018 04:37:13 +0000 (14:37 +1000)
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 <me@tobin.cc>
CODING_STYLE.md

index c81015173aba2c1a1ce543d318123bc6df439a0d..7e1cbf3262680b3b25a302faff7139d5b8694fe7 100644 (file)
@@ -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