Monday, March 22, 2010

Happy Ada Lovelace Day

When I was in studying Computer Science in college there was one classmate, let's call him Dave, who was really mean to me. He was just rude and it was uncalled for.

Dave was one of those people who study all night and all day. It turned out that he was pissed with me for getting better grades than him on a test.

It was a silly thing.

The thing is, I was a really poor student my final year. I missed a lot of classes. I only purchased one text book. My professors were all like, "I'm sorry Dan but I'm afraid I had to give you a B." and I was like, "You're giving me a B? From your expression, I was afraid you were going to say you had run over my dog." In fact, I did poorly on the test that Dave was so annoyed about.

It one of the women in the class who got the best score.

But I let Dave carry on thinking it was me. Whenever he was rude to me, I'd always just stay mellow and tell him, "Well that may be true, but you suck at taking tests."

Some dudes tried to take credit for Ada Lovelace's work too.

Sunday, March 21, 2010

Posted 60 range checking bugs to LKML

I posted a list of 60 range checking bugs to lkml. It's mostly not very interested bugs, but still. I think that's the first time anyone has done that, so it's a milestone of sorts.

I'm in Tanzania now, next to Lake Tanganyika.

Saturday, January 9, 2010

smatch_scripts/show_unreachable.sh

Smatch prints out stuff like this:
net/rds/send.c +395 rds_send_acked_before(13) info: ignoring unreachable code.

The show_unreachable.sh script lets you browse through all of those pretty quickly.

It prints output like this:


=========================================================
drivers/mca/mca-device.c +69
{
struct mca_bus *mca_bus = to_mca_bus(mca_dev->dev.parent);

return mca_bus->f.mca_read_pos(mca_dev, reg);

---------------------------------------------------------
return mca_dev->pos[reg];
}
EXPORT_SYMBOL(mca_device_read_pos);


You can scroll through an entire kernel worth of unreachable code in about 15 minutes.

released smatch 1.54

I am in Nairobi now. It costs less than $0.50 per hour to use internet here.

Nairobi has at one fibre connection to the outside world. It got connected last September. There are several others connecting soon. I used to follow the status closely but I have been mostly offline these past two years.

I released smatch 1.54. The announcement is here.

In some ways, I wish I had fixed it up a bit more before releasing. In other ways, release early and often.

I think the array overflow bugs from smatch 1.54 are interesting. The thing is that after a while all the interesting bugs get fixed and you are left with a discouraging pile of false positives. You have to have regular releases, with new checks because otherwise people think it's just false positives all the time.

[updated: I accidentally said it cost $1 to surf the net in Nairobi but I meant $.50 ]

Sunday, January 3, 2010

View patches from email

I have recently switched to using mutt to read email. When you are reading lkml you need a decent mail client and the only one I know of is mutt. It took a while to get used to the controls and to customize it but now I like it.

When someone emails a patch I like to view the context of the change, hence this view_full.sh script. The script assumes that your kernel source is in ~/progs/kernel/devel/. In mutt hit the '|' key and type ~/path/to/view_full.sh

After you exit vim it does patch -p1 -R to clean up.

#!/bin/bash -e

PATCH=$(mktemp)
tee $PATCH > /dev/null

files=$(grep ^+++ $PATCH | cut -f 1 | cut -b 5-)
cd ~/progs/kernel/devel/

if ! cat $PATCH | patch -p1 ; then
cat $PATCH | patch -R -p1
exit 1 # won't actually reach here because it's invoked with bash -e
# and the patch -R will fail.
fi

for file in $files ; do
line=$(grep -A1 "$file" $PATCH | tail -n 1 | cut -b 5- | cut -d ',' -f 1)
file=${file#*/}
vim $file +${line}
done
cat $PATCH | patch -p1 -R

rm $PATCH

One thing that is a bit annoying is that if you are in vim and type:
:! kchecker %
The line endings are messed up. The fix is to type:
:! kchecker % | less

Frist Post!!1!

I am in Lilongwe.

I start the bus ride to my brother's place in Kampala this evening. It takes 40+ hours to reach Dar Es Sala am. Then another day to Nairobi and then a third day to Kampala.

Once I did the trip in three days and three nights. There are no toilettes on the bus.

In Lilongwe, internet cafes charge $2 USD per hour. Last year most were charging $4 USD. Hopefully the price has gone down in Kampala as well.

Xuan Ji emailed me with an idea for improving smatch last night.


char buf[10];

if (x < sizeof(buf))
frob();
buf[x] = '\0';


The test for x implies that it's possible for x to be 10. Up to now smatch wasn't taking advantage of that. The old code just said that 'x' could be anything up to a bazillion. I made a new function get_fuzzy_max(x) that returns 10.

One problem is that if you say:

if (x == 10) {...

it assumes get_fuzzy_max() returns 11.