From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Phil Sutter <phil@nwl.cc>
Cc: netfilter-devel@vger.kernel.org
Subject: Re: [nft PATCH v4 0/3] Implement --echo option
Date: Mon, 14 Aug 2017 11:26:51 +0200 [thread overview]
Message-ID: <20170814092651.GA7437@salvia> (raw)
In-Reply-To: <20170809111643.18906-1-phil@nwl.cc>
On Wed, Aug 09, 2017 at 01:16:40PM +0200, Phil Sutter wrote:
> Long description of what it is and how it works in patch 3. Patch 1 is a
> dependency to patch 2, Patch 3 adds a simple test suite which was
> helpful during development.
Applied, but please follow up asap to address a couple of issues:
mnl.c: In function ‘nft_mnl_talk_cb’:
mnl.c:82:5: warning: ‘rc’ may be used uninitialized in this function
[-Wmaybe-uninitialized]
if (rc)
^
struct nft_mnl_talk_cb_data {
int (*cb)(const struct nlmsghdr *nlh, void *data);
void *data;
};
static int nft_mnl_talk_cb(const struct nlmsghdr *nlh, void *data)
{
struct nft_mnl_talk_cb_data *cbdata = data;
int rc;
if (cbdata->cb)
rc = cbdata->cb(nlh, cbdata->data);
if (rc)
return rc;
return netlink_echo_callback(nlh, cbdata->data);
}
This code above doesn't look fine...
Apart from this, this struct nft_mnl_talk_cb_data looks... a bit
convoluted ;)
static int
nft_mnl_talk(struct mnl_socket *nf_sock, const void *data, unsigned int len,
int (*cb)(const struct nlmsghdr *nlh, void *data), void *cb_data)
{
uint32_t portid = mnl_socket_get_portid(nf_sock);
struct nft_mnl_talk_cb_data tcb_data = {
.cb = cb,
.data = cb_data,
};
#ifdef DEBUG
if (debug_level & DEBUG_MNL)
mnl_nlmsg_fprintf(stdout, data, len, sizeof(struct nfgenmsg));
#endif
if (mnl_socket_sendto(nf_sock, data, len) < 0)
return -1;
return nft_mnl_recv(nf_sock, seq, portid, &nft_mnl_talk_cb, &tcb_data);
}
Why don't you simply pass the callback that you need to nft_mnl_recv()
instead of adding this extra unnecesary abstraction...
Please, follow up with a patchset to address this.
Thanks!
next prev parent reply other threads:[~2017-08-14 9:27 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-09 11:16 [nft PATCH v4 0/3] Implement --echo option Phil Sutter
2017-08-09 11:16 ` [nft PATCH v4 1/3] netlink: Pass nlmsg flags from rule.c Phil Sutter
2017-08-09 11:16 ` [nft PATCH v4 2/3] Implement --echo option Phil Sutter
2017-08-14 10:50 ` Pablo Neira Ayuso
2017-08-09 11:16 ` [nft PATCH v4 3/3] tests: Add a simple test suite for " Phil Sutter
2017-08-14 9:26 ` Pablo Neira Ayuso [this message]
2017-08-14 11:36 ` [nft PATCH v4 0/3] Implement " Phil Sutter
2017-08-14 11:43 ` Pablo Neira Ayuso
2017-08-14 11:54 ` Phil Sutter
2017-08-14 12:02 ` Pablo Neira Ayuso
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=20170814092651.GA7437@salvia \
--to=pablo@netfilter.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=phil@nwl.cc \
/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).