]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
homework: reduce scope of iterator variables
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 11 Feb 2021 10:59:22 +0000 (11:59 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 11 Feb 2021 10:59:22 +0000 (11:59 +0100)
src/home/homework-luks.c

index b0b2d8029fb3517c5f61d51dde6eb76496a1ca1f..a2d7c78005859cfe03321a765aadb9cf5e4ee00f 100644 (file)
@@ -518,7 +518,7 @@ static int luks_validate(
         blkid_loff_t offset = 0, size = 0;
         blkid_partlist pl;
         bool found = false;
-        int r, i, n;
+        int r, n;
 
         assert(fd >= 0);
         assert(label);
@@ -570,7 +570,7 @@ static int luks_validate(
         if (n < 0)
                 return errno > 0 ? -errno : -EIO;
 
-        for (i = 0; i < n; i++) {
+        for (int i = 0; i < n; i++) {
                 blkid_partition pp;
                 sd_id128_t id;
                 const char *sid;
@@ -681,12 +681,12 @@ static int luks_validate_home_record(
                 PasswordCache *cache,
                 UserRecord **ret_luks_home_record) {
 
-        int r, token;
+        int r;
 
         assert(cd);
         assert(h);
 
-        for (token = 0;; token++) {
+        for (int token = 0;; token++) {
                 _cleanup_(json_variant_unrefp) JsonVariant *v = NULL, *rr = NULL;
                 _cleanup_(EVP_CIPHER_CTX_freep) EVP_CIPHER_CTX *context = NULL;
                 _cleanup_(user_record_unrefp) UserRecord *lhr = NULL;
@@ -2423,7 +2423,7 @@ static int prepare_resize_partition(
         _cleanup_(fdisk_unref_contextp) struct fdisk_context *c = NULL;
         _cleanup_(fdisk_unref_tablep) struct fdisk_table *t = NULL;
         _cleanup_free_ char *path = NULL, *disk_uuid_as_string = NULL;
-        size_t n_partitions, i;
+        size_t n_partitions;
         sd_id128_t disk_uuid;
         bool found = false;
         int r;
@@ -2473,7 +2473,7 @@ static int prepare_resize_partition(
                 return log_error_errno(r, "Failed to acquire partition table: %m");
 
         n_partitions = fdisk_table_get_nents(t);
-        for (i = 0; i < n_partitions; i++)  {
+        for (size_t i = 0; i < n_partitions; i++)  {
                 struct fdisk_partition *p;
 
                 p = fdisk_table_get_partition(t, i);
@@ -2898,7 +2898,7 @@ int home_passwd_luks(
                 PasswordCache *cache,      /* the passwords acquired via PKCS#11/FIDO2 security tokens */
                 char **effective_passwords /* new passwords */) {
 
-        size_t volume_key_size, i, max_key_slots, n_effective;
+        size_t volume_key_size, max_key_slots, n_effective;
         _cleanup_(erase_and_freep) void *volume_key = NULL;
         struct crypt_pbkdf_type good_pbkdf, minimal_pbkdf;
         const char *type;
@@ -2943,7 +2943,7 @@ int home_passwd_luks(
         build_good_pbkdf(&good_pbkdf, h);
         build_minimal_pbkdf(&minimal_pbkdf, h);
 
-        for (i = 0; i < max_key_slots; i++) {
+        for (size_t i = 0; i < max_key_slots; i++) {
                 r = crypt_keyslot_destroy(setup->crypt_device, i);
                 if (r < 0 && !IN_SET(r, -ENOENT, -EINVAL)) /* Returns EINVAL or ENOENT if there's no key in this slot already */
                         return log_error_errno(r, "Failed to destroy LUKS password: %m");