X-Git-Url: http://git.ipfire.org/?p=thirdparty%2Fsystemd.git;a=blobdiff_plain;f=src%2Fjournal-remote%2Fjournal-upload.c;h=20e2a2f73bdde82037da4a59b5eeeb1f088e9cfb;hp=5d23639ee81b2eb2b3402fdd7e92f614eb7ffcd3;hb=6bedfcbb2970e06a4d3280c8fb62083d252ede73;hpb=72c0a2c255b172ebbb2a2b7dab7c9aec4c9582d9
diff --git a/src/journal-remote/journal-upload.c b/src/journal-remote/journal-upload.c
index 5d23639ee81..20e2a2f73bd 100644
--- a/src/journal-remote/journal-upload.c
+++ b/src/journal-remote/journal-upload.c
@@ -19,23 +19,26 @@
along with systemd; If not, see .
***/
-#include
#include
-#include
#include
#include
+#include
+#include
#include "sd-daemon.h"
-#include "log.h"
-#include "util.h"
-#include "build.h"
+
+#include "conf-parser.h"
+#include "fd-util.h"
#include "fileio.h"
+#include "formats-util.h"
+#include "journal-upload.h"
+#include "log.h"
#include "mkdir.h"
-#include "conf-parser.h"
+#include "parse-util.h"
#include "sigbus.h"
-#include "formats-util.h"
#include "signal-util.h"
-#include "journal-upload.h"
+#include "string-util.h"
+#include "util.h"
#define PRIV_KEY_FILE CERTIFICATE_ROOT "/private/journal-upload.pem"
#define CERT_FILE CERTIFICATE_ROOT "/certs/journal-upload.pem"
@@ -126,26 +129,31 @@ static int update_cursor_state(Uploader *u) {
r = fopen_temporary(u->state_file, &f, &temp_path);
if (r < 0)
- goto finish;
+ goto fail;
fprintf(f,
"# This is private data. Do not parse.\n"
"LAST_CURSOR=%s\n",
u->last_cursor);
- fflush(f);
+ r = fflush_and_check(f);
+ if (r < 0)
+ goto fail;
- if (ferror(f) || rename(temp_path, u->state_file) < 0) {
+ if (rename(temp_path, u->state_file) < 0) {
r = -errno;
- unlink(u->state_file);
- unlink(temp_path);
+ goto fail;
}
-finish:
- if (r < 0)
- log_error_errno(r, "Failed to save state %s: %m", u->state_file);
+ return 0;
- return r;
+fail:
+ if (temp_path)
+ (void) unlink(temp_path);
+
+ (void) unlink(u->state_file);
+
+ return log_error_errno(r, "Failed to save state %s: %m", u->state_file);
}
static int load_cursor_state(Uploader *u) {
@@ -614,9 +622,7 @@ static int parse_argv(int argc, char *argv[]) {
return 0 /* done */;
case ARG_VERSION:
- puts(PACKAGE_STRING);
- puts(SYSTEMD_FEATURES);
- return 0 /* done */;
+ return version();
case 'u':
if (arg_url) {
@@ -823,7 +829,7 @@ int main(int argc, char **argv) {
"READY=1\n"
"STATUS=Processing input...");
- while (true) {
+ for (;;) {
r = sd_event_get_state(u.events);
if (r < 0)
break;