-/* SPDX-License-Identifier: LGPL-2.1+ */
-/***
- This file is part of systemd.
-
- Copyright 2014 Zbigniew Jędrzejewski-Szmek
-***/
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <curl/curl.h>
#include <stdbool.h>
r = snprintf(buf + pos, size - pos,
"__CURSOR=%s\n", u->current_cursor);
- if (pos + r > size)
+ assert(r >= 0);
+ if ((size_t) r > size - pos)
/* not enough space */
return pos;
r = snprintf(buf + pos, size - pos,
"__REALTIME_TIMESTAMP="USEC_FMT"\n", realtime);
- if (r + pos > size)
+ assert(r >= 0);
+ if ((size_t) r > size - pos)
/* not enough space */
return pos;
r = snprintf(buf + pos, size - pos,
"__MONOTONIC_TIMESTAMP="USEC_FMT"\n", monotonic);
- if (r + pos > size)
+ assert(r >= 0);
+ if ((size_t) r > size - pos)
/* not enough space */
return pos;
_fallthrough_;
case ENTRY_BOOT_ID: {
sd_id128_t boot_id;
- char sid[33];
+ char sid[SD_ID128_STRING_MAX];
r = sd_journal_get_monotonic_usec(u->journal, NULL, &boot_id);
if (r < 0)
r = snprintf(buf + pos, size - pos,
"_BOOT_ID=%s\n", sd_id128_to_string(boot_id, sid));
- if (r + pos > size)
+ assert(r >= 0);
+ if ((size_t) r > size - pos)
/* not enough space */
return pos;
size_t len;
c = memchr(u->field_data, '=', u->field_length);
- if (!c || c == u->field_data) {
- log_error("Invalid field.");
- return -EINVAL;
- }
+ if (!c || c == u->field_data)
+ return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
+ "Invalid field.");
len = c - (const char*)u->field_data;
return pos;
default:
- assert_not_reached("WTF?");
+ assert_not_reached();
}
}
- assert_not_reached("WTF?");
+ assert_not_reached();
}
-static inline void check_update_watchdog(Uploader *u) {
+static void check_update_watchdog(Uploader *u) {
usec_t after;
usec_t elapsed_time;
return log_error_errno(r, "Failed to register input event: %m");
log_debug("Listening for journal events on fd:%d, timeout %d",
- fd, u->timeout == (uint64_t) -1 ? -1 : (int) u->timeout);
+ fd, u->timeout == UINT64_MAX ? -1 : (int) u->timeout);
} else
log_debug("Not listening for journal events.");
cursor);
}
- return process_journal_input(u, 1 + !!after_cursor);
+ return process_journal_input(u, !!after_cursor);
}