Re: [PATCH v2 0/2] Fixed type in sizeof in calloc

2020-09-12 Thread Willy Tarreau
On Sat, Sep 12, 2020 at 08:26:41PM +0200, Tim Duesterhus wrote:
> Willy,
> 
> Am 12.09.20 um 18:52 schrieb Willy Tarreau:
> > Thanks for doing this, I really appreciate it as I too hate having
> > a named type in calloc, as it doesn't survive code changes over time.
> > 
> > I'd rather have one patch to fix the known bug and the rest as a
> > cleanup patch however, so that we can backport the fix wherever
> > needed without risking to break something subtle by accident. Just
> > let me know if that's OK for you, otherwise I'll take care of slicing
> > your patch next week.
> > 
> 
> Okay. I've split it into 2 patches.

Great, now applied, thank you!

> Checking out the blame for the BUG was fun. Apparently it's the
> second time I fixed this exact issue.

I'm not surprised. This type of practice is common and sometimes even
needed (e.g. when you put the output into a void*), so some people tend
to be more used to it than to the other.

> I'm already seeing Ilya suggesting that we add Coccinelle to the CI pipeline
> in response to this :-)

That could be an idea, indeed. I seldom run coccinelle on the code when
I spot an ugly bug that's easy to search at other places, but I don't
think about doing it often. We need to be reasonable so that we don't
have yet-another series of low importance reports to deal with that
require code changes just to silence a low-threshold detector. That's
always the difficult part.

Cheers,
Willy



[PATCH v2 0/2] Fixed type in sizeof in calloc

2020-09-12 Thread Tim Duesterhus
Willy,

Am 12.09.20 um 18:52 schrieb Willy Tarreau:
> Thanks for doing this, I really appreciate it as I too hate having
> a named type in calloc, as it doesn't survive code changes over time.
> 
> I'd rather have one patch to fix the known bug and the rest as a
> cleanup patch however, so that we can backport the fix wherever
> needed without risking to break something subtle by accident. Just
> let me know if that's OK for you, otherwise I'll take care of slicing
> your patch next week.
> 

Okay. I've split it into 2 patches. Checking out the blame for the BUG was
fun. Apparently it's the second time I fixed this exact issue.

I'm already seeing Ilya suggesting that we add Coccinelle to the CI pipeline
in response to this :-)

Best regards

Tim Düsterhus (2):
  BUG/MINOR: Fix type passed of sizeof() for calloc()
  CLEANUP: Do not use a fixed type for 'sizeof' in 'calloc'

 src/51d.c | 2 +-
 src/arg.c | 2 +-
 src/cfgparse-listen.c | 2 +-
 src/cfgparse.c| 2 +-
 src/check.c   | 4 ++--
 src/extcheck.c| 4 ++--
 src/fd.c  | 4 ++--
 src/haproxy.c | 5 +++--
 src/hlua.c| 3 ++-
 src/lb_chash.c| 3 ++-
 src/lb_map.c  | 2 +-
 src/ssl_sock.c| 2 +-
 src/tools.c   | 2 +-
 src/uri_auth.c| 2 +-
 14 files changed, 21 insertions(+), 18 deletions(-)

-- 
2.28.0