Older blog entries for movement (starting at number 269)

It's not just atol(), Nicholas

Nicholas Nethercote warns us against atol(). Sadly, he recommends using strtol() instead. This interface is almost as bad. If atol() is impossible to get right, strtol() has to be classified under the obvious use is wrong.

As a perfect example of how horrible strtol() is, let's look at his example code:


int i1 = strtol(s, &endptr, 0); if (*endptr != ',') goto bad;
int i2 = strtol(endptr+1, &endptr, 0); if (*endptr != ',') goto bad;
int i3 = strtol(endptr+1, &endptr, 0); if (*endptr != '\0') goto bad;
...
bad: /* error case */

Can you spot the bug? What about an input like ",2,3" ? Nicholas does mention that this code is broken for underflow or overflow (you must wrap every singe call like this: "errno = 0; strtol(...); if (errno...)") but either missed this or considered it irrelevant. It's just too hard to get right.

Just use the *scanf() family (yes, that's hard to use too). Be suspicious of any code using either strtol() or atol().

Syndicated 2009-03-14 12:03:00 (Updated 2009-03-14 12:16:29) from John Levon

Comics I Don't Understand

Comics I Don't Understand. One for Seinfeld fans. What I don't understand is how someone can have a Wordpress design that has no "Previous" button. Blech.

Syndicated 2009-03-10 02:15:00 (Updated 2009-03-10 02:47:34) from John Levon

Heston Blumethal's Feasts

I've just watched last week's episode of this series, Heston Blumenthal's Victorian Feast. The guy is the epitome of the mad scientist (his dessert was strawberry, elderflower and absinthe dildo jelly with earl grey ice cream).

I had one of his inventions a while back: strawberry, olive and leather vanilla sundae. It was pretty nice, though the rather more staid chocolate wine popsicle was much nicer.

You should watch Tuesday's...

Syndicated 2009-03-09 22:47:00 (Updated 2009-03-09 22:55:44) from John Levon

Tomcat on Centos 5.2: just don't

If you were thinking of trying to use CentOS 5.2's tomcat packages: don't. You just get a silent 400 Bad request error on the holding page for no reason. Download it from upstream, and use that directly. It's very poorly documented, sadly, so to get started:

  1. Install the Sun JRE and set $JAVA_HOME appropriately - gcj is ... lacking
  2. Grab the Tomcat 'core' tarball and unpack it in place
  3. edit conf/tomcat-users.xml to add a user that has the 'manager' role
  4. start Tomcat with ./bin/startup.sh
  5. Go to http://yourhost:8080/ and log in to "status" with the manager user you added
  6. This will list any of the apps you installed (by dumping their .war file in webapps/)
I also set up a virtual host with Apache (for OpenGrok) like this:

<VirtualHost *.80>
ServerName grok.example.org
ProxyPreserveHost On
ProxyPass / http://example.org:8080/
ProxyPassReverse / http://example.org:8080/
</VirtualHost>

Syndicated 2009-03-07 19:10:00 (Updated 2009-03-07 19:16:51) from John Levon

Gas no gas abadie pizza please

Well this makes no sense:

Me: "Hi, your letter said I needed to arrange a visit with you to check the gas safety of my flat."
Them: "That's right, what's your details?"
*gives them*
Me: "There's no gas supply in the building, but apparently you have to come see that in person yourselves."
Them: "Yes, that's true. .... OK, we'll send you a letter with the appointment details."
Me: "Uh, I can't just do any time, it needs to be arranged."
Them: "That's OK - if you can't make the appointment on the letter, then you can ring us up after you receive it and tell us."
Me: "..."

Syndicated 2009-02-27 00:49:00 (Updated 2009-02-27 00:52:36) from John Levon

Holocaust deniers

Somewhat unpleasantly, I'm a vague acquaintance of a couple of holocaust deniers (in the sense that I've been in the same place as them once or twice). Really weird people:

  1. They always bring it up at parties. Seriously, what? If I were a terrorism expert, I'd tend to keep off the subject at parties, since people might see it as a little sensitive. Even if I was just a huge fan of He-Man or something I'd probably only mention it if we were talking about 1980s kids' TV. Why do they always start talking about it?
  2. It's never a slight correction. It's always some ridiculous figure they claim, like "zero" or "thousands". Surely if the figures are really dubious, they're not going to be 6 million off? It's equivalent to claiming that nobody lives in Libya.
  3. They appear to believe in either the most expertly executed hoax of all time, and their only apparent response to this is to moan about it to people they don't know. How does that make any sense?

Syndicated 2009-02-25 17:21:00 (Updated 2009-02-25 17:35:05) from John Levon

Javascript off

cdfrey: the fact that you've disabled JavaScript in your browser automatically qualifies you as irrelevant for anyone designing a modern user interface - sorry.

Syndicated 2009-02-21 18:20:00 (Updated 2009-02-21 18:22:10) from John Levon

Dear Everyone

If you have a blog, and you ask questions in blog entries, have some way to leave comments, won't you?

Syndicated 2009-02-21 00:14:00 (Updated 2009-02-21 00:15:48) from John Levon

Things I discovered yesterday

  1. Installing Firefox in an OpenVZ container can make you lose /dev/null
  2. OpenSolaris sleep(1) needs the network to be up
  3. People are injecting foreskins into their face
  4. Dubai is really screwed

Syndicated 2009-02-18 18:43:00 (Updated 2009-02-18 20:08:44) from John Levon

260 older entries...

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!