chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
util: replace close_nointr_nofail() by a more useful safe_close()
[elogind.git]
/
src
/
journal
/
journalctl.c
diff --git
a/src/journal/journalctl.c
b/src/journal/journalctl.c
index 482795bd38a43be085e2e2c109434bafbd88bf00..019629047b02a5bc445adec70f3909d86881311a 100644
(file)
--- a/
src/journal/journalctl.c
+++ b/
src/journal/journalctl.c
@@
-658,6
+658,11
@@
static int parse_argv(int argc, char *argv[]) {
return -EINVAL;
}
return -EINVAL;
}
+ if (arg_action != ACTION_SHOW && optind < argc) {
+ log_error("Extraneous arguments starting with '%s'", argv[optind]);
+ return -EINVAL;
+ }
+
return 1;
}
return 1;
}
@@
-727,7
+732,7
@@
static int add_matches(sd_journal *j, char **args) {
t = strappend("_COMM=", comm);
/* Append _EXE only if the interpreter is not a link.
t = strappend("_COMM=", comm);
/* Append _EXE only if the interpreter is not a link.
- Otherwise it might be outdated often. */
+ Otherwise
,
it might be outdated often. */
if (lstat(interpreter, &st) == 0 &&
!S_ISLNK(st.st_mode)) {
t2 = strappend("_EXE=", interpreter);
if (lstat(interpreter, &st) == 0 &&
!S_ISLNK(st.st_mode)) {
t2 = strappend("_EXE=", interpreter);
@@
-1285,7
+1290,7
@@
static int setup_keys(void) {
n = now(CLOCK_REALTIME);
n /= arg_interval;
n = now(CLOCK_REALTIME);
n /= arg_interval;
-
close_nointr_nofail
(fd);
+
safe_close
(fd);
fd = mkostemp_safe(k, O_WRONLY|O_CLOEXEC);
if (fd < 0) {
log_error("Failed to open %s: %m", k);
fd = mkostemp_safe(k, O_WRONLY|O_CLOEXEC);
if (fd < 0) {
log_error("Failed to open %s: %m", k);
@@
-1384,8
+1389,7
@@
static int setup_keys(void) {
r = 0;
finish:
r = 0;
finish:
- if (fd >= 0)
- close_nointr_nofail(fd);
+ safe_close(fd);
if (k) {
unlink(k);
if (k) {
unlink(k);
@@
-1651,7
+1655,7
@@
int main(int argc, char *argv[]) {
}
if (arg_action == ACTION_DISK_USAGE) {
}
if (arg_action == ACTION_DISK_USAGE) {
- uint64_t bytes;
+ uint64_t bytes
= 0
;
char sbytes[FORMAT_BYTES_MAX];
r = sd_journal_get_usage(j, &bytes);
char sbytes[FORMAT_BYTES_MAX];
r = sd_journal_get_usage(j, &bytes);