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
F108431833: D46013.id.diff
Fri, Jan 24, 5:36 PM
Unknown Object (File)
Thu, Jan 9, 9:21 PM
Unknown Object (File)
Mon, Dec 30, 6:52 PM
Unknown Object (File)
Mon, Dec 30, 9:18 AM
Unknown Object (File)
Dec 2 2024, 2:07 AM
Unknown Object (File)
Nov 30 2024, 10:27 PM
Unknown Object (File)
Nov 6 2024, 6:50 AM
Unknown Object (File)
Nov 6 2024, 6:49 AM
Subscribers
None

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 58695
Build 55583: arc lint + arc unit

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.