Blame SOURCES/cryptsetup-2.0.5-remove-useless-division-followed-by-multiplication-b.patch

8af939
From d2f0773eb8482f754d9a7599d26697efcdd25cd6 Mon Sep 17 00:00:00 2001
8af939
From: Ondrej Kozina <okozina@redhat.com>
8af939
Date: Thu, 9 Aug 2018 10:34:17 +0200
8af939
Subject: [PATCH] Remove useless division followed by multiplication by same
8af939
 base.
8af939
8af939
---
8af939
 lib/luks2/luks2_json_format.c | 10 +++++-----
8af939
 lib/setup.c                   |  2 +-
8af939
 2 files changed, 6 insertions(+), 6 deletions(-)
8af939
8af939
diff --git a/lib/luks2/luks2_json_format.c b/lib/luks2/luks2_json_format.c
8af939
index a0b72ab..4b50f89 100644
8af939
--- a/lib/luks2/luks2_json_format.c
8af939
+++ b/lib/luks2/luks2_json_format.c
8af939
@@ -122,9 +122,9 @@ int LUKS2_generate_hdr(
8af939
 	const char *cipherMode,
8af939
 	const char *integrity,
8af939
 	const char *uuid,
8af939
-	unsigned int sector_size,
8af939
-	unsigned int alignPayload,
8af939
-	unsigned int alignOffset,
8af939
+	unsigned int sector_size,  /* in bytes */
8af939
+	unsigned int alignPayload, /* in bytes */
8af939
+	unsigned int alignOffset,  /* in bytes */
8af939
 	int detached_metadata_device)
8af939
 {
8af939
 	struct json_object *jobj_segment, *jobj_integrity, *jobj_keyslots, *jobj_segments, *jobj_config;
8af939
@@ -182,11 +182,11 @@ int LUKS2_generate_hdr(
8af939
 	jobj_segment = json_object_new_object();
8af939
 	json_object_object_add(jobj_segment, "type", json_object_new_string("crypt"));
8af939
 	if (detached_metadata_device)
8af939
-		offset = (uint64_t)alignPayload * sector_size;
8af939
+		offset = (uint64_t)alignPayload;
8af939
 	else {
8af939
 		//FIXME
8af939
 		//offset = size_round_up(areas[7].offset + areas[7].length, alignPayload * SECTOR_SIZE);
8af939
-		offset = size_round_up(LUKS2_HDR_DEFAULT_LEN, (size_t)alignPayload * sector_size);
8af939
+		offset = size_round_up(LUKS2_HDR_DEFAULT_LEN, (size_t)alignPayload);
8af939
 		offset += alignOffset;
8af939
 	}
8af939
 
8af939
diff --git a/lib/setup.c b/lib/setup.c
8af939
index 1a78d2e..61bf3da 100644
8af939
--- a/lib/setup.c
8af939
+++ b/lib/setup.c
8af939
@@ -1601,7 +1601,7 @@ static int _crypt_format_luks2(struct crypt_device *cd,
8af939
 			       cipher, cipher_mode,
8af939
 			       integrity, uuid,
8af939
 			       sector_size,
8af939
-			       required_alignment / sector_size,
8af939
+			       required_alignment,
8af939
 			       alignment_offset,
8af939
 			       cd->metadata_device ? 1 : 0);
8af939
 	if (r < 0)
8af939
-- 
8af939
1.8.3.1
8af939