[systemd-commits] 6 commits - Makefile.am src/bootchart src/journal
Zbigniew JÄdrzejewski-Szmek
zbyszek at kemper.freedesktop.org
Thu Jan 10 12:43:45 PST 2013
Makefile.am | 23 +++++-----
src/bootchart/bootchart.c | 26 +++++------
src/bootchart/log.c | 21 ++++-----
src/journal/journald-server.c | 96 +++++++++++-------------------------------
4 files changed, 61 insertions(+), 105 deletions(-)
New commits:
commit d354315ff7a4e128aea58583a3cbedbf86e69196
Author: Zbigniew JÄdrzejewski-Szmek <zbyszek at in.waw.pl>
Date: Thu Jan 10 15:43:20 2013 -0500
build-sys: do not install to / in 'make distcheck'
diff --git a/Makefile.am b/Makefile.am
index 11bb9b3..3318829 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -4105,11 +4105,14 @@ DISTCHECK_CONFIGURE_FLAGS = \
--with-rootprefix=$$dc_install_base \
--disable-split-usr
-
if HAVE_SYSV_COMPAT
DISTCHECK_CONFIGURE_FLAGS += \
--with-sysvinit-path=$$dc_install_base/$(sysvinitdir) \
--with-sysvrcnd-path=$$dc_install_base/$(sysvrcnddir)
+else
+DISTCHECK_CONFIGURE_FLAGS += \
+ --with-sysvinit-path= \
+ --with-sysvrcnd-path=
endif
if ENABLE_GTK_DOC
commit 52edb22835c264d3c5b15b74993c34b4ec979ef5
Author: Zbigniew JÄdrzejewski-Szmek <zbyszek at in.waw.pl>
Date: Thu Jan 10 15:42:31 2013 -0500
build-sys: fix 'make distcheck' w/o sysvinit compat
EXTRA_DIST must unconditionally contain all source files.
diff --git a/Makefile.am b/Makefile.am
index 2ba8d55..11bb9b3 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -377,24 +377,22 @@ EXTRA_DIST += \
introspect.awk \
man/custom-html.xsl
-if HAVE_KMOD
EXTRA_DIST += \
units/systemd-modules-load.service.in
-endif
if HAVE_SYSV_COMPAT
nodist_systemunit_DATA += \
units/rc-local.service \
units/halt-local.service
-EXTRA_DIST += \
- units/rc-local.service.in \
- units/halt-local.service.in
-
systemgenerator_PROGRAMS += \
systemd-rc-local-generator
endif
+EXTRA_DIST += \
+ units/rc-local.service.in \
+ units/halt-local.service.in
+
dist_doc_DATA = \
README \
NEWS \
@@ -3944,10 +3942,6 @@ docs/sysvinit/README: docs/sysvinit/README.in
docs/var-log/README: docs/var-log/README.in
$(SED_PROCESS)
-EXTRA_DIST += \
- docs/sysvinit/README.in \
- docs/var-log/README.in
-
CLEANFILES += \
docs/sysvinit/README \
docs/var-log/README
@@ -3955,6 +3949,10 @@ CLEANFILES += \
endif
EXTRA_DIST += \
+ docs/sysvinit/README.in \
+ docs/var-log/README.in
+
+EXTRA_DIST += \
shell-completion/systemd-zsh-completion.zsh
systemd-install-data-hook:
commit 2c408fbf64af68c0fa6e882a2a34e5e7bf342ff6
Author: Auke Kok <auke-jan.h.kok at intel.com>
Date: Thu Jan 10 11:34:59 2013 -0800
bootchart: fix a -Wshadow warning for "now"
diff --git a/src/bootchart/log.c b/src/bootchart/log.c
index e41689d..48002fa 100644
--- a/src/bootchart/log.c
+++ b/src/bootchart/log.c
@@ -39,11 +39,11 @@ DIR *proc;
double gettime_ns(void)
{
- struct timespec now;
+ struct timespec n;
- clock_gettime(CLOCK_MONOTONIC, &now);
+ clock_gettime(CLOCK_MONOTONIC, &n);
- return (now.tv_sec + (now.tv_nsec / 1000000000.0));
+ return (n.tv_sec + (n.tv_nsec / 1000000000.0));
}
commit a2e9b3380804c9eff565836b0e32b88389d4391c
Author: Auke Kok <auke-jan.h.kok at intel.com>
Date: Thu Jan 10 11:35:00 2013 -0800
bootchart: Convert malloc/memset to calloc
diff --git a/src/bootchart/bootchart.c b/src/bootchart/bootchart.c
index 7bcfd98..37d8fbe 100644
--- a/src/bootchart/bootchart.c
+++ b/src/bootchart/bootchart.c
@@ -232,12 +232,11 @@ int main(int argc, char *argv[])
}
/* start with empty ps LL */
- ps_first = malloc(sizeof(struct ps_struct));
+ ps_first = calloc(1, sizeof(struct ps_struct));
if (!ps_first) {
- perror("malloc(ps_struct)");
+ perror("calloc(ps_struct)");
exit(EXIT_FAILURE);
}
- memset(ps_first, 0, sizeof(struct ps_struct));
/* handle TERM/INT nicely */
memset(&sig, 0, sizeof(struct sigaction));
diff --git a/src/bootchart/log.c b/src/bootchart/log.c
index c697121..e41689d 100644
--- a/src/bootchart/log.c
+++ b/src/bootchart/log.c
@@ -225,21 +225,19 @@ schedstat_next:
char t[32];
struct ps_struct *parent;
- ps->next_ps = malloc(sizeof(struct ps_struct));
+ ps->next_ps = calloc(1, sizeof(struct ps_struct));
if (!ps->next_ps) {
- perror("malloc(ps_struct)");
+ perror("calloc(ps_struct)");
exit (EXIT_FAILURE);
}
- memset(ps->next_ps, 0, sizeof(struct ps_struct));
ps = ps->next_ps;
ps->pid = pid;
- ps->sample = malloc(sizeof(struct ps_sched_struct) * (len + 1));
+ ps->sample = calloc(len + 1, sizeof(struct ps_sched_struct));
if (!ps->sample) {
- perror("malloc(ps_struct)");
+ perror("calloc(ps_struct)");
exit (EXIT_FAILURE);
}
- memset(ps->sample, 0, sizeof(struct ps_sched_struct) * (len + 1));
pscount++;
commit 53f5329f7aa321d72847cd7f8f28da9a7db80331
Author: Auke Kok <auke-jan.h.kok at intel.com>
Date: Thu Jan 10 11:34:58 2013 -0800
bootchart: Convert !strcmp usage to streq
diff --git a/src/bootchart/bootchart.c b/src/bootchart/bootchart.c
index 3d77bab..7bcfd98 100644
--- a/src/bootchart/bootchart.c
+++ b/src/bootchart/bootchart.c
@@ -28,6 +28,7 @@
#include "bootchart.h"
+#include "util.h"
double graph_start;
double log_start;
@@ -109,25 +110,25 @@ int main(int argc, char *argv[])
// todo: filter leading/trailing whitespace
- if (!strcmp(key, "samples"))
+ if (streq(key, "samples"))
len = atoi(val);
- if (!strcmp(key, "freq"))
+ if (streq(key, "freq"))
hz = atof(val);
- if (!strcmp(key, "rel"))
+ if (streq(key, "rel"))
relative = atoi(val);
- if (!strcmp(key, "filter"))
+ if (streq(key, "filter"))
filter = atoi(val);
- if (!strcmp(key, "pss"))
+ if (streq(key, "pss"))
pss = atoi(val);
- if (!strcmp(key, "output"))
+ if (streq(key, "output"))
strncpy(output_path, val, PATH_MAX - 1);
- if (!strcmp(key, "init"))
+ if (streq(key, "init"))
strncpy(init_path, val, PATH_MAX - 1);
- if (!strcmp(key, "scale_x"))
+ if (streq(key, "scale_x"))
scale_x = atof(val);
- if (!strcmp(key, "scale_y"))
+ if (streq(key, "scale_y"))
scale_y = atof(val);
- if (!strcmp(key, "entropy"))
+ if (streq(key, "entropy"))
entropy = atoi(val);
}
fclose(f);
diff --git a/src/bootchart/log.c b/src/bootchart/log.c
index 78f0cab..c697121 100644
--- a/src/bootchart/log.c
+++ b/src/bootchart/log.c
@@ -26,6 +26,7 @@
#include "bootchart.h"
+#include "util.h"
/*
* Alloc a static 4k buffer for stdio - primarily used to increase
@@ -125,9 +126,9 @@ void log_sample(int sample)
while (m) {
if (sscanf(m, "%s %s", key, val) < 2)
goto vmstat_next;
- if (!strcmp(key, "pgpgin"))
+ if (streq(key, "pgpgin"))
blockstat[sample].bi = atoi(val);
- if (!strcmp(key, "pgpgout")) {
+ if (streq(key, "pgpgout")) {
blockstat[sample].bo = atoi(val);
break;
}
commit db91ea32aa223d1b087d99811226a9c59a1bb281
Author: Zbigniew JÄdrzejewski-Szmek <zbyszek at in.waw.pl>
Date: Wed Jan 9 19:14:32 2013 -0500
journald: use automatic cleanup
diff --git a/src/journal/journald-server.c b/src/journal/journald-server.c
index 43ffe75..60e5a91 100644
--- a/src/journal/journald-server.c
+++ b/src/journal/journald-server.c
@@ -91,13 +91,14 @@ DEFINE_STRING_TABLE_LOOKUP(split_mode, SplitMode);
DEFINE_CONFIG_PARSE_ENUM(config_parse_split_mode, split_mode, SplitMode, "Failed to parse split mode setting");
static uint64_t available_space(Server *s) {
- char ids[33], *p;
+ char ids[33];
+ char _cleanup_free_ *p = NULL;
const char *f;
sd_id128_t machine;
struct statvfs ss;
uint64_t sum = 0, avail = 0, ss_avail = 0;
int r;
- DIR *d;
+ DIR _cleanup_closedir_ *d = NULL;
usec_t ts;
JournalMetrics *m;
@@ -125,13 +126,11 @@ static uint64_t available_space(Server *s) {
return 0;
d = opendir(p);
- free(p);
-
if (!d)
return 0;
if (fstatvfs(dirfd(d), &ss) < 0)
- goto finish;
+ return 0;
for (;;) {
struct stat st;
@@ -170,9 +169,6 @@ static uint64_t available_space(Server *s) {
s->cached_available_space = avail;
s->cached_available_space_timestamp = ts;
-finish:
- closedir(d);
-
return avail;
}
@@ -396,7 +392,8 @@ void server_vacuum(Server *s) {
static char *shortened_cgroup_path(pid_t pid) {
int r;
- char *process_path, *init_path, *path;
+ char _cleanup_free_ *process_path = NULL, *init_path = NULL;
+ char *path;
assert(pid > 0);
@@ -405,10 +402,8 @@ static char *shortened_cgroup_path(pid_t pid) {
return NULL;
r = cg_get_by_pid(SYSTEMD_CGROUP_CONTROLLER, 1, &init_path);
- if (r < 0) {
- free(process_path);
+ if (r < 0)
return NULL;
- }
if (endswith(init_path, "/system"))
init_path[strlen(init_path) - 7] = 0;
@@ -416,23 +411,12 @@ static char *shortened_cgroup_path(pid_t pid) {
init_path[0] = 0;
if (startswith(process_path, init_path)) {
- char *p;
-
- p = strdup(process_path + strlen(init_path));
- if (!p) {
- free(process_path);
- free(init_path);
- return NULL;
- }
- path = p;
+ path = strdup(process_path + strlen(init_path));
} else {
path = process_path;
process_path = NULL;
}
- free(process_path);
- free(init_path);
-
return path;
}
@@ -519,7 +503,7 @@ static void dispatch_message_real(
const char *label, size_t label_len,
const char *unit_id) {
- char *pid = NULL, *uid = NULL, *gid = NULL,
+ char _cleanup_free_ *pid = NULL, *uid = NULL, *gid = NULL,
*source_time = NULL, *boot_id = NULL, *machine_id = NULL,
*comm = NULL, *cmdline = NULL, *hostname = NULL,
*audit_session = NULL, *audit_loginuid = NULL,
@@ -679,24 +663,6 @@ static void dispatch_message_real(
s->split_mode == SPLIT_NONE ? 0 :
(s->split_mode == SPLIT_UID ? realuid :
(realuid == 0 ? 0 : loginuid)), iovec, n);
-
- free(pid);
- free(uid);
- free(gid);
- free(comm);
- free(exe);
- free(cmdline);
- free(source_time);
- free(boot_id);
- free(machine_id);
- free(hostname);
- free(audit_session);
- free(audit_loginuid);
- free(cgroup);
- free(session);
- free(owner_uid);
- free(unit);
- free(selinux_context);
}
void server_driver_message(Server *s, sd_id128_t message_id, const char *format, ...) {
@@ -744,7 +710,8 @@ void server_dispatch_message(
int priority) {
int rl;
- char *path = NULL, *c;
+ char _cleanup_free_ *path = NULL;
+ char *c;
assert(s);
assert(iovec || n == 0);
@@ -778,18 +745,16 @@ void server_dispatch_message(
}
}
- rl = journal_rate_limit_test(s->rate_limit, path, priority & LOG_PRIMASK, available_space(s));
+ rl = journal_rate_limit_test(s->rate_limit, path,
+ priority & LOG_PRIMASK, available_space(s));
- if (rl == 0) {
- free(path);
+ if (rl == 0)
return;
- }
/* Write a suppression message if we suppressed something */
if (rl > 1)
- server_driver_message(s, SD_MESSAGE_JOURNAL_DROPPED, "Suppressed %u messages from %s", rl - 1, path);
-
- free(path);
+ server_driver_message(s, SD_MESSAGE_JOURNAL_DROPPED,
+ "Suppressed %u messages from %s", rl - 1, path);
finish:
dispatch_message_real(s, iovec, n, m, ucred, tv, label, label_len, unit_id);
@@ -1234,7 +1199,8 @@ static int open_signalfd(Server *s) {
}
static int server_parse_proc_cmdline(Server *s) {
- char *line, *w, *state;
+ char _cleanup_free_ *line = NULL;
+ char *w, *state;
int r;
size_t l;
@@ -1248,13 +1214,11 @@ static int server_parse_proc_cmdline(Server *s) {
}
FOREACH_WORD_QUOTED(w, l, line, state) {
- char *word;
+ char _cleanup_free_ *word;
word = strndup(w, l);
- if (!word) {
- r = -ENOMEM;
- goto finish;
- }
+ if (!word)
+ return -ENOMEM;
if (startswith(word, "systemd.journald.forward_to_syslog=")) {
r = parse_boolean(word + 35);
@@ -1276,25 +1240,18 @@ static int server_parse_proc_cmdline(Server *s) {
s->forward_to_console = r;
} else if (startswith(word, "systemd.journald"))
log_warning("Invalid systemd.journald parameter. Ignoring.");
-
- free(word);
}
- r = 0;
-
-finish:
- free(line);
- return r;
+ return 0;
}
static int server_parse_config_file(Server *s) {
- FILE *f;
- const char *fn;
+ static const char *fn = "/etc/systemd/journald.conf";
+ FILE _cleanup_fclose_ *f = NULL;
int r;
assert(s);
- fn = "/etc/systemd/journald.conf";
f = fopen(fn, "re");
if (!f) {
if (errno == ENOENT)
@@ -1304,12 +1261,11 @@ static int server_parse_config_file(Server *s) {
return -errno;
}
- r = config_parse(fn, f, "Journal\0", config_item_perf_lookup, (void*) journald_gperf_lookup, false, s);
+ r = config_parse(fn, f, "Journal\0", config_item_perf_lookup,
+ (void*) journald_gperf_lookup, false, s);
if (r < 0)
log_warning("Failed to parse configuration file: %s", strerror(-r));
- fclose(f);
-
return r;
}
More information about the systemd-commits
mailing list