Re: [PATCHES] reading uninitialized buffer

2004-02-02 Thread Neil Conway
Andrew Dunstan [EMAIL PROTECTED] writes: OK, then *This* patch does it the way I think is clearest. Most of it is just reindenting. Okay, I applied this patch, and made a few additional cleanups along the way (the whole function and a couple other things don't need to be declared in hba.h, for

Re: [PATCHES] reading uninitialized buffer

2004-02-02 Thread Andrew Dunstan
Neil Conway wrote: Andrew Dunstan [EMAIL PROTECTED] writes: OK, then *This* patch does it the way I think is clearest. Most of it is just reindenting. Okay, I applied this patch, and made a few additional cleanups along the way (the whole function and a couple other things don't need to

Re: [PATCHES] reading uninitialized buffer

2004-02-01 Thread Andrew Dunstan
This time it is my fault, rather than freebsd's ;-) I think I can do something slightly cleaner than this, though, by hoisting the buf termination above the test. We could also replace the strncmp calls with strcmp calls if the buffer has its nul. I will post something soon. cheers andrew

Re: [PATCHES] reading uninitialized buffer

2004-02-01 Thread Andrew Dunstan
... and here it is. As for the test being outside the if statement, it is true that that might waste a few cycles, but it hardly matters. Personally, I would prefer to replace the if statement with this: if (c == EOF || c == '\n') { *buf = '\0'; return; } and then it

Re: [PATCHES] reading uninitialized buffer

2004-02-01 Thread Dennis Bjorklund
On Sun, 1 Feb 2004, Andrew Dunstan wrote: As for the test being outside the if statement, it is true that that might waste a few cycles, but it hardly matters. The cycles are not important. My fix wasn't the most optimized either if one should count cycles. It was terminating the string twice

Re: [PATCHES] reading uninitialized buffer

2004-02-01 Thread Tom Lane
Andrew Dunstan [EMAIL PROTECTED] writes: ... and then it wouldn't be an issue at all, but I know some people don't like early function returns - is there a general postgres style rule about it? Hardly; we do that a lot. Write it however it seems clearest. regards,

Re: [PATCHES] reading uninitialized buffer

2004-02-01 Thread Andrew Dunstan
OK, then *This* patch does it the way I think is clearest. Most of it is just reindenting. cheers andrew Dennis Bjorklund wrote: On Sun, 1 Feb 2004, Andrew Dunstan wrote: As for the test being outside the if statement, it is true that that might waste a few cycles, but it hardly matters.

Re: [PATCHES] reading uninitialized buffer

2004-02-01 Thread Neil Conway
Andrew Dunstan [EMAIL PROTECTED] writes: OK, then *This* patch does it the way I think is clearest. Most of it is just reindenting. Unless anyone objects, I'll review and apply this patch within 24 hours. Thanks for the patch, Dennis and Andrew. -Neil ---(end of