Skip to contentSkip to conversation

Remove useless assertions from reiserfs

PATCH In review [email protected] 3 participants 5 messages Aug 11, 2003

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Remove useless assertions from reiserfs

fs/reiserfs/hashes.c +0 -13
diff -urpN --exclude-from=/home/davej/.exclude bk-linus/fs/reiserfs/hashes.c linux-2.5/fs/reiserfs/hashes.c
@@ -90,10 +90,6 @@ u32 keyed_hash(const signed char *msg, i
 
 	if (len >= 12)
 	{
-	    	//assert(len < 16);
-		if (len >= 16)
-		    BUG();
-
 		a = (u32)msg[ 0]      |
 		    (u32)msg[ 1] << 8 |
 		    (u32)msg[ 2] << 16|
@@ -116,9 +112,6 @@ u32 keyed_hash(const signed char *msg, i
 	}
 	else if (len >= 8)
 	{
-	    	//assert(len < 12);
-		if (len >= 12)
-		    BUG();
 		a = (u32)msg[ 0]      |
 		    (u32)msg[ 1] << 8 |
 		    (u32)msg[ 2] << 16|
@@ -137,9 +130,6 @@ u32 keyed_hash(const signed char *msg, i
 	}
 	else if (len >= 4)
 	{
-	    	//assert(len < 8);
-		if (len >= 8)
-		    BUG();
 		a = (u32)msg[ 0]      |
 		    (u32)msg[ 1] << 8 |
 		    (u32)msg[ 2] << 16|
@@ -154,9 +144,6 @@ u32 keyed_hash(const signed char *msg, i
 	}
 	else
 	{
-	    	//assert(len < 4);
-		if (len >= 4)
-		    BUG();
 		a = b = c = d = pad;
 		for(i = 0; i < len; i++)
 		{
#1 lore raw

Why are these useless?

Quoted 4 lines · [email protected] wrote:

diff -urpN --exclude-from=/home/davej/.exclude bk-linus/fs/reiserfs/hashes.c linux-2.5/fs/reiserfs/hashes.c

fs/reiserfs/hashes.c u32 keyed_hash(const signed char *msg, i · line 95

Quoted 10 lines
fs/reiserfs/hashes.c +0 -4
@@ -90,10 +90,6 @@ u32 keyed_hash(const signed char *msg, i
 
 	if (len >= 12)
 	{
-	    	//assert(len < 16);
-		if (len >= 16)
-		    BUG();
-
 		a = (u32)msg[ 0]      |
 		    (u32)msg[ 1] << 8 |
 		    (u32)msg[ 2] << 16|

Seems like a valid check to me...

Jeff

author
#2 lore raw
Quoted 1 line · Jeff Garzik

Why are these useless?

read the code not the diff.

Quoted 13 lines

fs/reiserfs/hashes.c u32 keyed_hash(const signed char *msg, i · line 95

Quoted 11 lines
fs/reiserfs/hashes.c +0 -4
@@ -90,10 +90,6 @@ u32 keyed_hash(const signed char *msg, i
 
 	if (len >= 12)
 	{
-	    	//assert(len < 16);
-		if (len >= 16)
-		    BUG();
-
 		a = (u32)msg[ 0]      |
 		    (u32)msg[ 1] << 8 |
 		    (u32)msg[ 2] << 16|

Seems like a valid check to me...

Above this loop is another loop which we don't exit until len < 16

Dave

Signature · 1 line
 Dave Jones     http://www.codemonkey.org.uk
#3 lore raw
Quoted 19 lines · Dave Jones
Quoted 1 line · Jeff Garzik

Why are these useless?

read the code not the diff.

Quoted 13 lines

fs/reiserfs/hashes.c u32 keyed_hash(const signed char *msg, i · line 95

Quoted 11 lines
fs/reiserfs/hashes.c +0 -4
@@ -90,10 +90,6 @@ u32 keyed_hash(const signed char *msg, i
 
 	if (len >= 12)
 	{
-	    	//assert(len < 16);
-		if (len >= 16)
-		    BUG();
-
 		a = (u32)msg[ 0]      |
 		    (u32)msg[ 1] << 8 |
 		    (u32)msg[ 2] << 16|

Seems like a valid check to me...

Quoted 1 line

Above this loop is another loop which we don't exit until len < 16

ok, agreed

Jeff

#4 lore raw
In reply to Jeff Garzik
Quoted 9 lines · Jeff Garzik

Why are these useless?

Review

Quoted 5 lines
(quoted diff) +0 -0
 	if (len >= 12)
 	{          
     //assert(len < 16);
              if (len >= 16)
                   BUG();

Seems like a valid check to me...

Just before that, there's code:

     while(len >= 16)
        {
	...
                len -= 16;
            }

So if that ever exits with a len >=16, we have a SERIOUS problem with either the compiler or the hardware - as such, that "if (..) BUG" is dead code. Similarly for the other checks.