hostnamed: our base indentation is 8 spaces, not 9 spaces

No idea what was going on here...
This commit is contained in:
Lennart Poettering
2024-03-01 22:37:38 +01:00
parent 8157cc0e3e
commit f3525b78af
+33 -33
View File
@@ -286,71 +286,71 @@ static int get_hardware_serial(char **ret) {
}
static int get_firmware_version(char **ret) {
return get_hardware_firmware_data("bios_version", ret);
return get_hardware_firmware_data("bios_version", ret);
}
static int get_firmware_vendor(char **ret) {
return get_hardware_firmware_data("bios_vendor", ret);
return get_hardware_firmware_data("bios_vendor", ret);
}
static int get_firmware_date(usec_t *ret) {
_cleanup_free_ char *bios_date = NULL, *month = NULL, *day = NULL, *year = NULL;
int r;
_cleanup_free_ char *bios_date = NULL, *month = NULL, *day = NULL, *year = NULL;
int r;
assert(ret);
assert(ret);
r = get_hardware_firmware_data("bios_date", &bios_date);
if (r < 0)
r = get_hardware_firmware_data("bios_date", &bios_date);
if (r < 0)
return r;
if (r == 0) {
if (r == 0) {
*ret = USEC_INFINITY;
return 0;
}
}
const char *p = bios_date;
r = extract_many_words(&p, "/", EXTRACT_DONT_COALESCE_SEPARATORS, &month, &day, &year, NULL);
if (r < 0)
const char *p = bios_date;
r = extract_many_words(&p, "/", EXTRACT_DONT_COALESCE_SEPARATORS, &month, &day, &year, NULL);
if (r < 0)
return r;
if (r != 3) /* less than three args read? */
if (r != 3) /* less than three args read? */
return -EINVAL;
if (!isempty(p)) /* more left in the string? */
if (!isempty(p)) /* more left in the string? */
return -EINVAL;
unsigned m, d, y;
r = safe_atou_full(month, 10 | SAFE_ATO_REFUSE_PLUS_MINUS | SAFE_ATO_REFUSE_LEADING_WHITESPACE, &m);
if (r < 0)
unsigned m, d, y;
r = safe_atou_full(month, 10 | SAFE_ATO_REFUSE_PLUS_MINUS | SAFE_ATO_REFUSE_LEADING_WHITESPACE, &m);
if (r < 0)
return r;
if (m < 1 || m > 12)
if (m < 1 || m > 12)
return -EINVAL;
m -= 1;
m -= 1;
r = safe_atou_full(day, 10 | SAFE_ATO_REFUSE_PLUS_MINUS | SAFE_ATO_REFUSE_LEADING_WHITESPACE, &d);
if (r < 0)
r = safe_atou_full(day, 10 | SAFE_ATO_REFUSE_PLUS_MINUS | SAFE_ATO_REFUSE_LEADING_WHITESPACE, &d);
if (r < 0)
return r;
if (d < 1 || d > 31)
if (d < 1 || d > 31)
return -EINVAL;
r = safe_atou_full(year, 10 | SAFE_ATO_REFUSE_PLUS_MINUS | SAFE_ATO_REFUSE_LEADING_WHITESPACE, &y);
if (r < 0)
r = safe_atou_full(year, 10 | SAFE_ATO_REFUSE_PLUS_MINUS | SAFE_ATO_REFUSE_LEADING_WHITESPACE, &y);
if (r < 0)
return r;
if (y < 1970 || y > (unsigned) INT_MAX)
if (y < 1970 || y > (unsigned) INT_MAX)
return -EINVAL;
y -= 1900;
y -= 1900;
struct tm tm = {
struct tm tm = {
.tm_mday = d,
.tm_mon = m,
.tm_year = y,
};
time_t v = timegm(&tm);
if (v == (time_t) -1)
};
time_t v = timegm(&tm);
if (v == (time_t) -1)
return -errno;
if (tm.tm_mday != (int) d || tm.tm_mon != (int) m || tm.tm_year != (int) y)
if (tm.tm_mday != (int) d || tm.tm_mon != (int) m || tm.tm_year != (int) y)
return -EINVAL; /* date was not normalized? (e.g. "30th of feb") */
*ret = (usec_t) v * USEC_PER_SEC;
*ret = (usec_t) v * USEC_PER_SEC;
return 0;
return 0;
}
static const char* valid_chassis(const char *chassis) {