[systemd-commits] 3 commits - src/core src/cryptsetup src/login src/shared
Zbigniew JÄdrzejewski-Szmek
zbyszek at kemper.freedesktop.org
Fri Apr 19 07:11:41 PDT 2013
src/core/killall.c | 9 ++-------
src/cryptsetup/cryptsetup-generator.c | 4 ++--
src/login/logind-dbus.c | 2 +-
src/shared/util.c | 9 ---------
src/shared/util.h | 10 ++++++++++
5 files changed, 15 insertions(+), 19 deletions(-)
New commits:
commit 7f6437976d31fa772ccef9abedd152d6f5372303
Author: Lukas Nykryn <lnykryn at redhat.com>
Date: Fri Apr 19 13:58:58 2013 +0200
logind-dbus: initialize result variable
diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c
index 4176902..05cc1fd 100644
--- a/src/login/logind-dbus.c
+++ b/src/login/logind-dbus.c
@@ -1137,7 +1137,7 @@ static int bus_manager_can_shutdown_or_sleep(
DBusMessage **_reply) {
bool multiple_sessions, challenge, blocked, b;
- const char *result;
+ const char *result = NULL;
_cleanup_dbus_message_unref_ DBusMessage *reply = NULL;
int r;
unsigned long ul;
commit 5a8e21785907df7466fef5e1cb54ce3bf99e5362
Author: Lukas Nykryn <lnykryn at redhat.com>
Date: Fri Apr 19 13:58:57 2013 +0200
crypt-setup-generator: correctly check return of strdup
diff --git a/src/cryptsetup/cryptsetup-generator.c b/src/cryptsetup/cryptsetup-generator.c
index ac0ed58..b31329d 100644
--- a/src/cryptsetup/cryptsetup-generator.c
+++ b/src/cryptsetup/cryptsetup-generator.c
@@ -302,7 +302,7 @@ static int parse_proc_cmdline(char ***arg_proc_cmdline_disks, char **arg_proc_cm
} else if (startswith(word, "luks.key=")) {
*arg_proc_cmdline_keyfile = strdup(word + 9);
- if (! arg_proc_cmdline_keyfile)
+ if (!*arg_proc_cmdline_keyfile)
return log_oom();
} else if (startswith(word, "rd.luks.key=")) {
@@ -311,7 +311,7 @@ static int parse_proc_cmdline(char ***arg_proc_cmdline_disks, char **arg_proc_cm
if (*arg_proc_cmdline_keyfile)
free(*arg_proc_cmdline_keyfile);
*arg_proc_cmdline_keyfile = strdup(word + 12);
- if (!arg_proc_cmdline_keyfile)
+ if (!*arg_proc_cmdline_keyfile)
return log_oom();
}
commit 31885cd5e38ec9807a6a7ab32660cf8c2fcf48f7
Author: Zbigniew JÄdrzejewski-Szmek <zbyszek at in.waw.pl>
Date: Wed Apr 17 17:19:38 2013 -0400
core/killall: use procfs_file_alloca
diff --git a/src/core/killall.c b/src/core/killall.c
index e078012..a0f5745 100644
--- a/src/core/killall.c
+++ b/src/core/killall.c
@@ -32,8 +32,7 @@
#define TIMEOUT_USEC (10 * USEC_PER_SEC)
static bool ignore_proc(pid_t pid) {
- char buf[PATH_MAX];
- FILE *f;
+ _cleanup_fclose_ FILE *f = NULL;
char c;
size_t count;
uid_t uid;
@@ -51,15 +50,11 @@ static bool ignore_proc(pid_t pid) {
if (uid != 0)
return false;
- snprintf(buf, sizeof(buf), "/proc/%lu/cmdline", (unsigned long) pid);
- char_array_0(buf);
-
- f = fopen(buf, "re");
+ f = fopen(procfs_file_alloca(pid, "cmdline"), "re");
if (!f)
return true; /* not really, but has the desired effect */
count = fread(&c, 1, 1, f);
- fclose(f);
/* Kernel threads have an empty cmdline */
if (count <= 0)
diff --git a/src/shared/util.c b/src/shared/util.c
index 1fc6c5a..a6ec79a 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -80,15 +80,6 @@ char **saved_argv = NULL;
static volatile unsigned cached_columns = 0;
static volatile unsigned cached_lines = 0;
-#define procfs_file_alloca(pid, field) \
- ({ \
- pid_t _pid_ = (pid); \
- char *_r_; \
- _r_ = alloca(sizeof("/proc/") -1 + DECIMAL_STR_MAX(pid_t) + 1 + sizeof(field)); \
- sprintf(_r_, "/proc/%lu/" field, (unsigned long) _pid_); \
- _r_; \
- })
-
size_t page_size(void) {
static __thread size_t pgsz = 0;
long r;
diff --git a/src/shared/util.h b/src/shared/util.h
index cfb5493..6575f56 100644
--- a/src/shared/util.h
+++ b/src/shared/util.h
@@ -21,6 +21,7 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
+#include <alloca.h>
#include <inttypes.h>
#include <time.h>
#include <sys/time.h>
@@ -696,3 +697,12 @@ int unlink_noerrno(const char *path);
strcpy(stpcpy(_c_, _a_), _b_); \
_c_; \
})
+
+#define procfs_file_alloca(pid, field) \
+ ({ \
+ pid_t _pid_ = (pid); \
+ char *_r_; \
+ _r_ = alloca(sizeof("/proc/") -1 + DECIMAL_STR_MAX(pid_t) + 1 + sizeof(field)); \
+ sprintf(_r_, "/proc/%lu/" field, (unsigned long) _pid_); \
+ _r_; \
+ })
More information about the systemd-commits
mailing list