diff mbox

ext4/hash.c: remove useless test and assignment in strtohash

Message ID 1501188807-4459-1-git-send-email-damien.guibouret@partition-saving.com
State Accepted, archived
Headers show

Commit Message

Damien Guibouret July 27, 2017, 8:53 p.m. UTC
On transformation of str to hash, computed value is initialised before
first byte modulo 4. But it is already initialised before entering loop
and after processing last byte modulo 4. So the corresponding test and
initialisation could be removed.

Signed-off-by: Damien Guibouret <damien.guibouret@partition-saving.com>
---
 fs/ext4/hash.c | 4 ----
 1 file changed, 4 deletions(-)

Comments

Theodore Ts'o Aug. 24, 2017, 7:13 p.m. UTC | #1
On Thu, Jul 27, 2017 at 10:53:27PM +0200, Damien Guibouret wrote:
> On transformation of str to hash, computed value is initialised before
> first byte modulo 4. But it is already initialised before entering loop
> and after processing last byte modulo 4. So the corresponding test and
> initialisation could be removed.
> 
> Signed-off-by: Damien Guibouret <damien.guibouret@partition-saving.com>

Thanks, applied.

					- Ted
diff mbox

Patch

diff --git a/fs/ext4/hash.c b/fs/ext4/hash.c
index 38b8a96..00c6dd2 100644
--- a/fs/ext4/hash.c
+++ b/fs/ext4/hash.c
@@ -148,8 +148,6 @@  static void str2hashbuf_signed(const char *msg, int len, __u32 *buf, int num)
 	if (len > num*4)
 		len = num * 4;
 	for (i = 0; i < len; i++) {
-		if ((i % 4) == 0)
-			val = pad;
 		val = ((int) scp[i]) + (val << 8);
 		if ((i % 4) == 3) {
 			*buf++ = val;
@@ -176,8 +174,6 @@  static void str2hashbuf_unsigned(const char *msg, int len, __u32 *buf, int num)
 	if (len > num*4)
 		len = num * 4;
 	for (i = 0; i < len; i++) {
-		if ((i % 4) == 0)
-			val = pad;
 		val = ((int) ucp[i]) + (val << 8);
 		if ((i % 4) == 3) {
 			*buf++ = val;