Fix unbelievably broken code in put_vformat()

Linus Torvalds torvalds at linux-foundation.org
Sat Mar 8 15:54:50 PST 2014


This code has worked for us for a long time, and we use it extensively
("put_format()" is built around it).

That doesn't mean it wasn't completely buggered, though.

But the broken case only happened when the result of the printout was
larger than (or equal to) the on-stack buffer of 128 bytes that we
used for temporary storage, and all our normal uses are to print out
things like dates and depths using this, and perhaps one-liner error
messages etc, so 128 bytes was basically "infinite".

Until I did some debug messages and printed out trip/dive notes with
it, at which point everything blew up, and I thought I had something
seriously wrong in my git object parsing code.

But no, the git object parsing code was fine, it was just my
put_vformat() code that was utter crap, clearly written by some
hopped-up woodland creature - me.

Christ, sometimes I wonder what bad drugs I'm on when writing code.
And other times I wonder if I should perhaps be taking more, to forget
the shame.

                  Linus
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Fix-totally-broken-put_vformat-implementation.patch
Type: text/x-patch
Size: 2271 bytes
Desc: not available
URL: <http://lists.hohndel.org/pipermail/subsurface/attachments/20140308/9dbbb83d/attachment.bin>


More information about the subsurface mailing list