On Monday 01 September 2008 23:56, Conrad Meyer wrote:
Your negative for loop is stylish. Let's try crunching down the loop
body a little:
int isinorder(BTREE, struct ileaf *leaf)
{
u16 *dict = (void *)leaf + btree->sb->blocksize;
for (int i = 0, offset = 0, limit; i > -leaf->count; i--, offset = limit)
if ((limit = dict[i]) < offset)
return 0;
return 1;
}
Wow, it compresses nicely :-)
It is still your nice clear and correct algorithm, just poked a little.
You can integrate it with the existing (lame) check like this:
int ileaf_check(BTREE, struct ileaf *leaf)
{
char *why;
why = "not an inode table leaf";
if (leaf->magic != 0x90de)
goto eek;
why = "dict out of order";
if (!isinorder(btree, leaf))
goto eek;
return 0;
eek:
printf("%s!\n", why);
return -1;
}
_______________________________________________
Tux3 mailing list
Tux3@tux3.org
http://tux3.org/cgi-bin/mailman/listinfo/tux3
| Jens Axboe | Re: [BUG] New Kernel Bugs |
| KAMEZAWA Hiroyuki | Re: 2.6.24-rc3-mm1 |
| Ingo Molnar | Re: [Announce] [patch] Modular Scheduler Core and Completely Fair Scheduler [CFS] |
| Greg Kroah-Hartman | [PATCH 001/196] Chinese: Add the known_regression URI to the HOWTO |
git: | |
| Jarek Poplawski | [PATCH] pkt_sched: Destroy gen estimators under rtnl_lock(). |
| Gerrit Renker | [PATCH 27/37] dccp: Integration of dynamic feature activation - part 2 (server side) |
| Jarek Poplawski | Re: Data corruption issue with splice() on 2.6.27.10 |
| Patrick McHardy | Re: [GIT]: Networking |
