mirror of
https://github.com/systemd/systemd.git
synced 2024-10-31 16:21:26 +03:00
shared/user-record: inline iterator variable declarations
This commit is contained in:
parent
ab4ab13c74
commit
6f8f8688e1
@ -608,7 +608,6 @@ static int json_dispatch_access_mode(const char *name, JsonVariant *variant, Jso
|
||||
static int json_dispatch_environment(const char *name, JsonVariant *variant, JsonDispatchFlags flags, void *userdata) {
|
||||
_cleanup_strv_free_ char **n = NULL;
|
||||
char ***l = userdata;
|
||||
size_t i;
|
||||
int r;
|
||||
|
||||
if (json_variant_is_null(variant)) {
|
||||
@ -619,7 +618,7 @@ static int json_dispatch_environment(const char *name, JsonVariant *variant, Jso
|
||||
if (!json_variant_is_array(variant))
|
||||
return json_log(variant, flags, SYNTHETIC_ERRNO(EINVAL), "JSON field '%s' is not an array.", strna(name));
|
||||
|
||||
for (i = 0; i < json_variant_elements(variant); i++) {
|
||||
for (size_t i = 0; i < json_variant_elements(variant); i++) {
|
||||
JsonVariant *e;
|
||||
const char *a;
|
||||
|
||||
@ -1463,7 +1462,7 @@ int user_group_record_mangle(
|
||||
JsonDispatchFlags json_flags = USER_RECORD_LOAD_FLAGS_TO_JSON_DISPATCH_FLAGS(load_flags);
|
||||
_cleanup_(json_variant_unrefp) JsonVariant *w = NULL;
|
||||
JsonVariant *array[ELEMENTSOF(mask_field) * 2];
|
||||
size_t n_retain = 0, i;
|
||||
size_t n_retain = 0;
|
||||
UserRecordMask m = 0;
|
||||
int r;
|
||||
|
||||
@ -1488,7 +1487,7 @@ int user_group_record_mangle(
|
||||
return json_log(v, json_flags, SYNTHETIC_ERRNO(EINVAL), "Stripping everything from record, refusing.");
|
||||
|
||||
/* Check if we have the special sections and if they match our flags set */
|
||||
for (i = 0; i < ELEMENTSOF(mask_field); i++) {
|
||||
for (size_t i = 0; i < ELEMENTSOF(mask_field); i++) {
|
||||
JsonVariant *e, *k;
|
||||
|
||||
if (FLAGS_SET(USER_RECORD_STRIP_MASK(load_flags), mask_field[i].mask)) {
|
||||
@ -1527,16 +1526,15 @@ int user_group_record_mangle(
|
||||
r = json_variant_new_object(&w, array, n_retain);
|
||||
if (r < 0)
|
||||
return json_log(v, json_flags, r, "Failed to allocate new object: %m");
|
||||
} else {
|
||||
} else
|
||||
/* And now check if there's anything else in the record */
|
||||
for (i = 0; i < json_variant_elements(v); i += 2) {
|
||||
for (size_t i = 0; i < json_variant_elements(v); i += 2) {
|
||||
const char *f;
|
||||
bool special = false;
|
||||
size_t j;
|
||||
|
||||
assert_se(f = json_variant_string(json_variant_by_index(v, i)));
|
||||
|
||||
for (j = 0; j < ELEMENTSOF(mask_field); j++)
|
||||
for (size_t j = 0; j < ELEMENTSOF(mask_field); j++)
|
||||
if (streq(f, mask_field[j].name)) { /* already covered in the loop above */
|
||||
special = true;
|
||||
continue;
|
||||
@ -1550,7 +1548,6 @@ int user_group_record_mangle(
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (FLAGS_SET(load_flags, USER_RECORD_REQUIRE_REGULAR) && !FLAGS_SET(m, USER_RECORD_REGULAR))
|
||||
return json_log(v, json_flags, SYNTHETIC_ERRNO(EBADMSG), "Record lacks basic identity fields, which are required.");
|
||||
|
Loading…
Reference in New Issue
Block a user