Re: [PATCH nft v2 0/4] [RESENT] remove xfree() and add free_const()+nft_gmp_free()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 2023-11-09 at 20:15 +0100, Pablo Neira Ayuso wrote:
> On Thu, Nov 09, 2023 at 06:14:56PM +0100, Thomas Haller wrote:
> > On Thu, 2023-11-09 at 17:05 +0100, Pablo Neira Ayuso wrote:
> [...]
> > > I might end up myself using
> > > free_const() everywhere not to figure out if it is const or not,
> > > because I don't really care.
> > 
> > That seems not a good practice. Const-correctness may help you to
> > catch
> > bugs via unwanted modifications. If constness is unnecessarily cast
> > away, it's looses such hints from the compiler.
> 
> Why should I care if the pointer is const or not if what I need to
> free it?

There might be a mistake/bug, and the thing should not actually be
freed.

We need every help from the compiler we can get (compiler warnings,
strong typing/const-correctness, static assertions).

Normally, the compiler would help and complain against free() of a
const pointer. With xfree()/free_const() used eagerly, it does not
help.


Thomas





[Index of Archives]     [Netfitler Users]     [Berkeley Packet Filter]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux