* [PATCH] Remove useless assertions from reiserfs
@ 2003-08-11 16:48 davej
2003-08-11 17:45 ` Jeff Garzik
0 siblings, 1 reply; 7+ messages in thread
From: davej @ 2003-08-11 16:48 UTC (permalink / raw)
To: torvalds; +Cc: linux-kernel
diff -urpN --exclude-from=/home/davej/.exclude bk-linus/fs/reiserfs/hashes.c linux-2.5/fs/reiserfs/hashes.c
--- bk-linus/fs/reiserfs/hashes.c 2003-04-10 06:01:29.000000000 +0100
+++ linux-2.5/fs/reiserfs/hashes.c 2003-07-13 06:04:57.000000000 +0100
@@ -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++)
{
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH] Remove useless assertions from reiserfs
2003-08-11 16:48 [PATCH] Remove useless assertions from reiserfs davej
@ 2003-08-11 17:45 ` Jeff Garzik
2003-08-11 17:52 ` Dave Jones
2003-08-11 18:00 ` Valdis.Kletnieks
0 siblings, 2 replies; 7+ messages in thread
From: Jeff Garzik @ 2003-08-11 17:45 UTC (permalink / raw)
To: davej; +Cc: torvalds, linux-kernel
Why are these useless?
davej@redhat.com wrote:
> diff -urpN --exclude-from=/home/davej/.exclude bk-linus/fs/reiserfs/hashes.c linux-2.5/fs/reiserfs/hashes.c
> --- bk-linus/fs/reiserfs/hashes.c 2003-04-10 06:01:29.000000000 +0100
> +++ linux-2.5/fs/reiserfs/hashes.c 2003-07-13 06:04:57.000000000 +0100
> @@ -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
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH] Remove useless assertions from reiserfs
2003-08-11 17:45 ` Jeff Garzik
@ 2003-08-11 17:52 ` Dave Jones
2003-08-11 17:56 ` Jeff Garzik
2003-08-11 18:00 ` Valdis.Kletnieks
1 sibling, 1 reply; 7+ messages in thread
From: Dave Jones @ 2003-08-11 17:52 UTC (permalink / raw)
To: Jeff Garzik; +Cc: torvalds, linux-kernel
On Mon, Aug 11, 2003 at 01:45:30PM -0400, Jeff Garzik wrote:
> Why are these useless?
read the code not the diff.
> >@@ -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
--
Dave Jones http://www.codemonkey.org.uk
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH] Remove useless assertions from reiserfs
2003-08-11 17:52 ` Dave Jones
@ 2003-08-11 17:56 ` Jeff Garzik
0 siblings, 0 replies; 7+ messages in thread
From: Jeff Garzik @ 2003-08-11 17:56 UTC (permalink / raw)
To: Dave Jones; +Cc: torvalds, linux-kernel
Dave Jones wrote:
> On Mon, Aug 11, 2003 at 01:45:30PM -0400, Jeff Garzik wrote:
> > Why are these useless?
>
> read the code not the diff.
>
> > >@@ -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
ok, agreed
Jeff
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Remove useless assertions from reiserfs
2003-08-11 17:45 ` Jeff Garzik
2003-08-11 17:52 ` Dave Jones
@ 2003-08-11 18:00 ` Valdis.Kletnieks
1 sibling, 0 replies; 7+ messages in thread
From: Valdis.Kletnieks @ 2003-08-11 18:00 UTC (permalink / raw)
To: Jeff Garzik; +Cc: davej, torvalds, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 543 bytes --]
On Mon, 11 Aug 2003 13:45:30 EDT, Jeff Garzik said:
> Why are these useless?
> > 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.
[-- Attachment #2: Type: application/pgp-signature, Size: 226 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Remove useless assertions from reiserfs
@ 2003-08-11 18:33 Petr Vandrovec
2003-08-11 18:46 ` Dave Jones
0 siblings, 1 reply; 7+ messages in thread
From: Petr Vandrovec @ 2003-08-11 18:33 UTC (permalink / raw)
To: Valdis.Kletnieks; +Cc: davej, torvalds, linux-kernel, jgarzik
On 11 Aug 03 at 14:00, Valdis.Kletnieks@vt.edu wrote:
> On Mon, 11 Aug 2003 13:45:30 EDT, Jeff Garzik said:
> > Why are these useless?
>
> > > 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.
I always thought that assertions are just for that - if you can hit them
without some unexpected event/bug, you have a SERIOUS problem.
Petr Vandrovec
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH] Remove useless assertions from reiserfs
2003-08-11 18:33 Petr Vandrovec
@ 2003-08-11 18:46 ` Dave Jones
0 siblings, 0 replies; 7+ messages in thread
From: Dave Jones @ 2003-08-11 18:46 UTC (permalink / raw)
To: Petr Vandrovec; +Cc: Valdis.Kletnieks, torvalds, linux-kernel, jgarzik
On Mon, Aug 11, 2003 at 08:33:13PM +0200, Petr Vandrovec wrote:
> I always thought that assertions are just for that - if you can hit them
> without some unexpected event/bug, you have a SERIOUS problem.
Not for when you explicitly code things above so it really cannot
happen. An assertion is more for the case "I really hope someone
doesn't pass me x in state y" type assertions than "I really hope
the compiler did the right thing with the previous loop"
Dave
--
Dave Jones http://www.codemonkey.org.uk
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2003-08-11 18:48 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-08-11 16:48 [PATCH] Remove useless assertions from reiserfs davej
2003-08-11 17:45 ` Jeff Garzik
2003-08-11 17:52 ` Dave Jones
2003-08-11 17:56 ` Jeff Garzik
2003-08-11 18:00 ` Valdis.Kletnieks
-- strict thread matches above, loose matches on Subject: below --
2003-08-11 18:33 Petr Vandrovec
2003-08-11 18:46 ` Dave Jones
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox