From: Thomas Haller <thaller@redhat.com>
To: Florian Westphal <fw@strlen.de>
Cc: Pablo Neira Ayuso <pablo@netfilter.org>,
NetFilter <netfilter-devel@vger.kernel.org>
Subject: Re: [PATCH nft 1/2] utils: add memory_allocation_check() helper
Date: Wed, 15 Nov 2023 10:06:05 +0100 [thread overview]
Message-ID: <22515546d5f842be275345ca6b8fd4b37e57ee16.camel@redhat.com> (raw)
In-Reply-To: <20231115085248.GD14621@breakpoint.cc>
On Wed, 2023-11-15 at 09:52 +0100, Florian Westphal wrote:
> Thomas Haller <thaller@redhat.com> wrote:
> > static inline void *__memory_allocation_check(const char *file,
> > unsigned line, const void *ptr) {
> > if (!ptr)
> > __memory_allocation_error(file, line);
> > return (void*) ptr;
> > }
> >
> > #define memory_allocation_check(cmd) \
> > ((typeof(cmd) __memory_allocation_check(__FILE__, __LINE__,
> > (cmd))
> >
> > Doesn't seem to make a difference either way.
>
> We seem to be moving in circles.
>
> I suspect your agenda is to avoid repeating the existing
>
> x = alloc()
> if (!x)
> barf()
>
> pattern when adding userhandle support?
exactly.
>
> If so I think its best to just add a specific ubuf alloc wrapper that
> can't fail (i.e. like the 'xmalloc' wrappers).
I don't understand.
_nftnl_udata_buf_alloc() *is* that specific wrapper.
Maybe the name is bad... and such wrappers should have a "nft_x_"
prefix (nft_x_nftnl_udata_buf_alloc()).
>
> Like Pablo said, I don't see any added value in providing FILE/LINE
> errors on stderr here. It could be as simple as exit().
>
I don't understand.
The two patches don't change anything about that. There is no change in
behavior -- aside introducing a convenience wrapper for the repeated
ENOMEM check.
If you want to change memory_allocation_error() to not use FILE/LINE or
call exit(), then that is a separate discussion (I'd like to avoid).
Thomas
prev parent reply other threads:[~2023-11-15 9:06 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-08 18:24 [PATCH nft 1/2] utils: add memory_allocation_check() helper Thomas Haller
2023-11-08 18:24 ` [PATCH nft 2/2] netlink: add and use _nftnl_udata_buf_alloc() helper Thomas Haller
2023-11-09 15:14 ` Pablo Neira Ayuso
2023-11-09 15:19 ` Thomas Haller
2023-11-09 15:32 ` Pablo Neira Ayuso
2023-11-09 16:48 ` Thomas Haller
2023-11-09 19:12 ` Pablo Neira Ayuso
2023-11-09 15:24 ` [PATCH nft 1/2] utils: add memory_allocation_check() helper Pablo Neira Ayuso
2023-11-09 17:02 ` Thomas Haller
2023-11-15 8:52 ` Florian Westphal
2023-11-15 9:06 ` Thomas Haller [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=22515546d5f842be275345ca6b8fd4b37e57ee16.camel@redhat.com \
--to=thaller@redhat.com \
--cc=fw@strlen.de \
--cc=netfilter-devel@vger.kernel.org \
--cc=pablo@netfilter.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).