various: use id128_from_string_not_null()

No functional change. In config_parse_address_generation_type() we would set
the output parameter and then say it's ignored, so it _looked_ like an error in
the code, but the variable was always initialized to SD_ID128_NULL anyway, so
the code was actually fine.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2023-09-02 14:16:25 +03:00
parent 7c9de5d85d
commit aea3f594db
5 changed files with 19 additions and 46 deletions
+6 -11
View File
@@ -19,6 +19,7 @@
#include "fileio.h"
#include "fs-util.h"
#include "hostname-util.h"
#include "id128-util.h"
#include "in-addr-util.h"
#include "log.h"
#include "macro.h"
@@ -944,25 +945,19 @@ int config_parse_id128(
void *data,
void *userdata) {
sd_id128_t t, *result = data;
sd_id128_t *result = data;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
r = sd_id128_from_string(rvalue, &t);
if (r < 0) {
r = id128_from_string_nonzero(rvalue, result);
if (r == -ENXIO)
log_syntax(unit, LOG_WARNING, filename, line, r, "128-bit ID/UUID is all 0, ignoring: %s", rvalue);
else if (r < 0)
log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse 128-bit ID/UUID, ignoring: %s", rvalue);
return 0;
}
if (sd_id128_is_null(t)) {
log_syntax(unit, LOG_WARNING, filename, line, 0, "128-bit ID/UUID is all 0, ignoring: %s", rvalue);
return 0;
}
*result = t;
return 0;
}