Page MenuHomeFreeBSD

ctld: Consistently use item count as the first argument to calloc
ClosedPublic

Authored by jhb on Jul 17 2024, 7:16 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Dec 2, 2:07 AM
Unknown Object (File)
Sat, Nov 30, 10:27 PM
Unknown Object (File)
Nov 6 2024, 6:50 AM
Unknown Object (File)
Nov 6 2024, 6:49 AM
Unknown Object (File)
Nov 6 2024, 6:35 AM
Unknown Object (File)
Oct 21 2024, 3:14 PM
Unknown Object (File)
Oct 2 2024, 11:57 AM
Unknown Object (File)
Sep 29 2024, 7:39 AM
Subscribers
None

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

jhb requested review of this revision.Jul 17 2024, 7:16 PM
jhb created this revision.

Some of these can be argued either way (is it one buffer of length ir_buflen, or is it a buffer of ir_buflen byte objects) but it's fine to do this just to placate GCC.

This revision is now accepted and ready to land.Jul 17 2024, 7:45 PM

Yes, in general I avoided changing the ones that were an array of bytes (e.g. for strings or opaque buffers) as you can argue it either way (a single opaque buffer, or an array of bytes). In this case GCC only warned about the first one, but here I believe it is obvious that rather than being an opaque buffer, the second one is really allocating a struct isns_hdr object, so the size really should be the second argument there as well.

Also, given the number of changes to be fixed, and that in many cases it made individual files or programs more consistent (e.g. all but a small number of calls were already correct), I think I'd prefer to just leave the calloc warning enabled going forward rather than muting it.