[systemd-commits] 2 commits - CODING_STYLE src/shared

Lennart Poettering lennart at kemper.freedesktop.org
Fri May 15 07:37:44 PDT 2015


 CODING_STYLE              |   12 +++++++++++-
 src/shared/socket-label.c |    3 ---
 2 files changed, 11 insertions(+), 4 deletions(-)

New commits:
commit a2c7f25aec23b6d74ff5cf169e38159754e6dfe8
Author: Davide Bettio <davide.bettio at ispirata.com>
Date:   Fri May 15 16:36:28 2015 +0200

    core: don't consider umask for SocketMode=
    
    https://bugs.freedesktop.org/show_bug.cgi?id=89248

diff --git a/src/shared/socket-label.c b/src/shared/socket-label.c
index dfb8a1a..cbe3ff2 100644
--- a/src/shared/socket-label.c
+++ b/src/shared/socket-label.c
@@ -109,9 +109,6 @@ int socket_address_listen(
                 /* Enforce the right access mode for the socket */
                 old_mask = umask(~ socket_mode);
 
-                /* Include the original umask in our mask */
-                umask(~socket_mode | old_mask);
-
                 r = mac_selinux_bind(fd, &a->sockaddr.sa, a->size);
 
                 if (r < 0 && errno == EADDRINUSE) {

commit 42706f47c918b035dee82f4bad15bf6499592d1c
Author: Lennart Poettering <lennart at poettering.net>
Date:   Fri May 15 15:47:37 2015 +0200

    CODING_STYLE: document alloca() DONTS

diff --git a/CODING_STYLE b/CODING_STYLE
index 70f45be..00986eb 100644
--- a/CODING_STYLE
+++ b/CODING_STYLE
@@ -121,7 +121,8 @@
   no speed benefit, and on calls like printf() "float"s get promoted
   to "double"s anyway, so there is no point.
 
-- Do not invoke functions when you allocate variables on the stack. Wrong:
+- Do not mix function invocations with variable definitions in one
+  line. Wrong:
 
   {
           int a = foobar();
@@ -259,3 +260,12 @@
 
   which will always work regardless if p is initialized or not, and
   guarantees that p is NULL afterwards, all in just one line.
+
+- Use alloca(), but never forget that it is not OK to invoke alloca()
+  within a loop or within function call parameters. alloca() memory is
+  released at the end of a function, and not at the end of a {}
+  block. Thus, if you invoke it in a loop, you keep increasing the
+  stack pointer without ever releasing memory again. (VLAs have better
+  behaviour in this case, so consider using them as an alternative.)
+  Regarding not using alloca() within function parameters, see the
+  BUGS section of the alloca(3) man page.



More information about the systemd-commits mailing list