Message ID | cover.1727774935.git.ps@pks.im (mailing list archive) |
---|---|
Headers | show |
Series | reftable: handle allocation errors | expand |
Patrick Steinhardt <ps@pks.im> writes: > this is the fourth version of this patch series that converts the > reftable library to start handling allocation errors. This is done such > that the reftable library can truly behave like a library and let its > callers handle such conditions. > > Changes compared to v3: > > - Fix some additional sites where we use strdup(3P)/free(3P) by > accident. > > - Convert preexisting callsites of free(3P) to use reftable_free(). > > - Introduce a REFTABLE_FREE_AND_NULL() macro and use it. > > - Ban standard allocators in reftable code "banned.h"-style. With this patch, there is only one hit from $ git grep '[^_]free(' reftable/ and no hits from $ git grep '[^_]FREE_AND_NULL(' reftable/ which is just as expected. Nicely done. Shouldn't we add FREE_AND_NULL() to the banned list as well in the last step? Thanks.
Am 01.10.24 um 19:52 schrieb Junio C Hamano: > Shouldn't we add FREE_AND_NULL() to the banned list as well in the > last step? And perhaps the wrapper.h functions like xmalloc()? At least as long as git-compat-util.h is included by reftable/system.h. Can be done later, of course, no need to reroll just for that. René
René Scharfe <l.s.r@web.de> writes: > Am 01.10.24 um 19:52 schrieb Junio C Hamano: >> Shouldn't we add FREE_AND_NULL() to the banned list as well in the >> last step? > > And perhaps the wrapper.h functions like xmalloc()? At least as long as > git-compat-util.h is included by reftable/system.h. Can be done later, > of course, no need to reroll just for that. Yeah, and I agree FREE_AND_NULL() falls into the same bucket as xmalloc() and friends, so no need to reroll just for that, either. Thanks.
On Tue, Oct 01, 2024 at 12:25:02PM -0700, Junio C Hamano wrote: > René Scharfe <l.s.r@web.de> writes: > > > Am 01.10.24 um 19:52 schrieb Junio C Hamano: > >> Shouldn't we add FREE_AND_NULL() to the banned list as well in the > >> last step? > > > > And perhaps the wrapper.h functions like xmalloc()? At least as long as > > git-compat-util.h is included by reftable/system.h. Can be done later, > > of course, no need to reroll just for that. > > Yeah, and I agree FREE_AND_NULL() falls into the same bucket as xmalloc() > and friends, so no need to reroll just for that, either. `FREE_AND_NULL()` would already be detected because it expands to code that contains `free()`. Same for `REALLOC_ARRAY()` and the likes. I'm overall a bit more hesitant to also start banning all the Git specific wrappers, mostly because there are so many of them. My goal is to rather make them inaccessible in the "reftable/" code in the first place so that we don't have to play whack-a-mole. My plan here is to split out the POSIX-providing bits from "git-compat-util.h" into a new header "compat/posix.h" that we can include in "reftable/system.h". But it'll take a while to get there :) Thanks for your inputs! Patrick
Patrick Steinhardt <ps@pks.im> writes: > `FREE_AND_NULL()` would already be detected because it expands to code > that contains `free()`. Same for `REALLOC_ARRAY()` and the likes. Ah, that is very true.