diff options
-rw-r--r-- | src/basic/fileio.c | 6 | ||||
-rw-r--r-- | src/basic/hostname-util.c | 4 | ||||
-rw-r--r-- | src/core/main.c | 4 | ||||
-rw-r--r-- | src/libsystemd-network/sd-dhcp-client.c | 2 | ||||
-rw-r--r-- | src/libsystemd-network/sd-dhcp-lease.c | 2 | ||||
-rw-r--r-- | src/stdio-bridge/stdio-bridge.c | 3 | ||||
-rw-r--r-- | src/test/test-clock.c | 19 | ||||
-rw-r--r-- | src/timedate/timedated.c | 4 | ||||
-rw-r--r-- | units/systemd-nspawn@.service.in | 4 |
9 files changed, 25 insertions, 23 deletions
diff --git a/src/basic/fileio.c b/src/basic/fileio.c index 2c454e8ea2..69590941e5 100644 --- a/src/basic/fileio.c +++ b/src/basic/fileio.c @@ -588,7 +588,7 @@ static int parse_env_file_push( va_list aq, *ap = userdata; if (!utf8_is_valid(key)) { - _cleanup_free_ char *p; + _cleanup_free_ char *p = NULL; p = utf8_escape_invalid(key); log_error("%s:%u: invalid UTF-8 in key '%s', ignoring.", strna(filename), line, p); @@ -596,7 +596,7 @@ static int parse_env_file_push( } if (value && !utf8_is_valid(value)) { - _cleanup_free_ char *p; + _cleanup_free_ char *p = NULL; p = utf8_escape_invalid(value); log_error("%s:%u: invalid UTF-8 value for key %s: '%s', ignoring.", strna(filename), line, key, p); @@ -1069,7 +1069,7 @@ int fflush_and_check(FILE *f) { /* This is much like like mkostemp() but is subject to umask(). */ int mkostemp_safe(char *pattern, int flags) { - _cleanup_umask_ mode_t u; + _cleanup_umask_ mode_t u = 0; int fd; assert(pattern); diff --git a/src/basic/hostname-util.c b/src/basic/hostname-util.c index 3cd2f2c872..5a7ee87a20 100644 --- a/src/basic/hostname-util.c +++ b/src/basic/hostname-util.c @@ -150,6 +150,8 @@ char* hostname_cleanup(char *s) { assert(s); + strshorten(s, HOST_NAME_MAX); + for (p = s, d = s, dot = true; *p; p++) { if (*p == '.') { if (dot) @@ -169,8 +171,6 @@ char* hostname_cleanup(char *s) { else *d = 0; - strshorten(s, HOST_NAME_MAX); - return s; } diff --git a/src/core/main.c b/src/core/main.c index 2c315930ed..02c0488208 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -1435,9 +1435,7 @@ int main(int argc, char *argv[]) { /* clear the kernel timestamp, * because we are in a container */ - kernel_timestamp.monotonic = 0ULL; - kernel_timestamp.realtime = 0ULL; - + kernel_timestamp = DUAL_TIMESTAMP_NULL; } else { /* Running as user instance */ arg_running_as = MANAGER_USER; diff --git a/src/libsystemd-network/sd-dhcp-client.c b/src/libsystemd-network/sd-dhcp-client.c index d484c37a73..1188b31500 100644 --- a/src/libsystemd-network/sd-dhcp-client.c +++ b/src/libsystemd-network/sd-dhcp-client.c @@ -408,7 +408,7 @@ static void client_stop(sd_dhcp_client *client, int error) { static int client_message_init(sd_dhcp_client *client, DHCPPacket **ret, uint8_t type, size_t *_optlen, size_t *_optoffset) { - _cleanup_free_ DHCPPacket *packet; + _cleanup_free_ DHCPPacket *packet = NULL; size_t optlen, optoffset, size; be16_t max_size; usec_t time_now; diff --git a/src/libsystemd-network/sd-dhcp-lease.c b/src/libsystemd-network/sd-dhcp-lease.c index 7a119fd488..ef50ed17a1 100644 --- a/src/libsystemd-network/sd-dhcp-lease.c +++ b/src/libsystemd-network/sd-dhcp-lease.c @@ -825,7 +825,7 @@ int dhcp_lease_save(sd_dhcp_lease *lease, const char *lease_file) { r = sd_dhcp_lease_get_client_id(lease, &client_id, &client_id_len); if (r >= 0) { - _cleanup_free_ char *client_id_hex; + _cleanup_free_ char *client_id_hex = NULL; client_id_hex = hexmem(client_id, client_id_len); if (!client_id_hex) { diff --git a/src/stdio-bridge/stdio-bridge.c b/src/stdio-bridge/stdio-bridge.c index 85b99ce161..ce8efce3d5 100644 --- a/src/stdio-bridge/stdio-bridge.c +++ b/src/stdio-bridge/stdio-bridge.c @@ -234,12 +234,14 @@ int main(int argc, char *argv[]) { fd = sd_bus_get_fd(a); if (fd < 0) { + r = fd; log_error_errno(r, "Failed to get fd: %m"); goto finish; } events_a = sd_bus_get_events(a); if (events_a < 0) { + r = events_a; log_error_errno(r, "Failed to get events mask: %m"); goto finish; } @@ -252,6 +254,7 @@ int main(int argc, char *argv[]) { events_b = sd_bus_get_events(b); if (events_b < 0) { + r = events_b; log_error_errno(r, "Failed to get events mask: %m"); goto finish; } diff --git a/src/test/test-clock.c b/src/test/test-clock.c index 92c4f79b98..84f775e5bc 100644 --- a/src/test/test-clock.c +++ b/src/test/test-clock.c @@ -20,17 +20,18 @@ #include <unistd.h> #include <fcntl.h> -#include "macro.h" +#include "clock-util.h" +#include "fd-util.h" #include "fileio.h" #include "log.h" -#include "clock-util.h" +#include "macro.h" static void test_clock_is_localtime(void) { char adjtime[] = "/tmp/test-adjtime.XXXXXX"; - int fd; - FILE* f; + int fd = -1; + _cleanup_fclose_ FILE* f = NULL; - const struct scenario { + static const struct scenario { const char* contents; int expected_result; } scenarios[] = { @@ -55,10 +56,10 @@ static void test_clock_is_localtime(void) { assert_se(clock_is_localtime("/nonexisting/adjtime") == 0); fd = mkostemp_safe(adjtime, O_WRONLY|O_CLOEXEC); - assert(fd > 0); + assert_se(fd >= 0); log_info("adjtime test file: %s", adjtime); f = fdopen(fd, "w"); - assert(f); + assert_se(f); for (size_t i = 0; i < ELEMENTSOF(scenarios); ++i) { log_info("scenario #%zu:, expected result %i", i, scenarios[i].expected_result); @@ -81,10 +82,10 @@ static void test_clock_is_localtime_system(void) { log_info("/etc/adjtime exists, clock_is_localtime() == %i", r); /* if /etc/adjtime exists we expect some answer, no error or * crash */ - assert(r == 0 || r == 1); + assert_se(r == 0 || r == 1); } else /* default is UTC if there is no /etc/adjtime */ - assert(r == 0); + assert_se(r == 0); } int main(int argc, char *argv[]) { diff --git a/src/timedate/timedated.c b/src/timedate/timedated.c index 9406d28abe..0febc36af8 100644 --- a/src/timedate/timedated.c +++ b/src/timedate/timedated.c @@ -131,10 +131,10 @@ static int context_write_data_local_rtc(Context *c) { size_t a, b; p = strchrnul(s, '\n'); - if (*p == '\0') { + if (*p == '\0') /* only one line, no \n terminator */ prepend = "\n0\n"; - } else if (p[1] == '\0') { + else if (p[1] == '\0') { /* only one line, with \n terminator */ ++p; prepend = "0\n"; diff --git a/units/systemd-nspawn@.service.in b/units/systemd-nspawn@.service.in index eb10343ac6..1927c4d485 100644 --- a/units/systemd-nspawn@.service.in +++ b/units/systemd-nspawn@.service.in @@ -6,14 +6,14 @@ # (at your option) any later version. [Unit] -Description=Container %I +Description=Container %i Documentation=man:systemd-nspawn(1) PartOf=machines.target Before=machines.target After=network.target [Service] -ExecStart=@bindir@/systemd-nspawn --quiet --keep-unit --boot --link-journal=try-guest --network-veth --settings=override --machine=%I +ExecStart=@bindir@/systemd-nspawn --quiet --keep-unit --boot --link-journal=try-guest --network-veth --settings=override --machine=%i KillMode=mixed Type=notify RestartForceExitStatus=133 |