* [PATCH] Optimise nfq_queue_cb
[not found] <md5:KJl5IfCAjtPWb+o93HAjWA==>
@ 2015-06-01 9:22 ` Paul Aitken
2015-06-01 11:03 ` Pablo Neira Ayuso
0 siblings, 1 reply; 7+ messages in thread
From: Paul Aitken @ 2015-06-01 9:22 UTC (permalink / raw)
To: netfilter-devel; +Cc: Pablo Neira Ayuso
ct and myct have both already been checked for non-NULL,
so there's no need to check either of them again later.
Signed-off-by: Paul Aitken <paitken@brocade.com>
---
src/cthelper.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/src/cthelper.c b/src/cthelper.c
index 15d5126..6537515 100644
--- a/src/cthelper.c
+++ b/src/cthelper.c
@@ -325,14 +325,12 @@ static int nfq_queue_cb(const struct nlmsghdr *nlh, void *data)
if (pkt_verdict_issue(helper, myct, queue_num, id, verdict, pktb) < 0)
goto err_pktb;
- if (ct != NULL)
- nfct_destroy(ct);
+ nfct_destroy(ct);
if (myct->exp != NULL)
nfexp_destroy(myct->exp);
- if (myct && myct->priv_data != NULL)
+ if (myct->priv_data != NULL)
free(myct->priv_data);
- if (myct != NULL)
- free(myct);
+ free(myct);
return MNL_CB_OK;
err_pktb:
--
1.9.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] Optimise nfq_queue_cb
2015-06-01 9:22 ` Paul Aitken
@ 2015-06-01 11:03 ` Pablo Neira Ayuso
2015-06-01 11:19 ` Paul Aitken
0 siblings, 1 reply; 7+ messages in thread
From: Pablo Neira Ayuso @ 2015-06-01 11:03 UTC (permalink / raw)
To: Paul Aitken; +Cc: netfilter-devel
On Mon, Jun 01, 2015 at 10:22:00AM +0100, Paul Aitken wrote:
> ct and myct have both already been checked for non-NULL,
> so there's no need to check either of them again later.
>
> Signed-off-by: Paul Aitken <paitken@brocade.com>
> ---
> src/cthelper.c | 8 +++-----
> 1 file changed, 3 insertions(+), 5 deletions(-)
>
> diff --git a/src/cthelper.c b/src/cthelper.c
> index 15d5126..6537515 100644
> --- a/src/cthelper.c
> +++ b/src/cthelper.c
> @@ -325,14 +325,12 @@ static int nfq_queue_cb(const struct nlmsghdr *nlh, void *data)
> if (pkt_verdict_issue(helper, myct, queue_num, id, verdict, pktb) < 0)
> goto err_pktb;
> - if (ct != NULL)
> - nfct_destroy(ct);
> + nfct_destroy(ct);
void nfct_destroy(struct nf_conntrack *ct)
{
assert(ct != NULL);
...
the library doesn't allow NULL pointers.
> if (myct->exp != NULL)
> nfexp_destroy(myct->exp);
> - if (myct && myct->priv_data != NULL)
> + if (myct->priv_data != NULL)
> free(myct->priv_data);
> - if (myct != NULL)
> - free(myct);
> + free(myct);
> return MNL_CB_OK;
> err_pktb:
> --
> 1.9.1
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Optimise nfq_queue_cb
2015-06-01 11:03 ` Pablo Neira Ayuso
@ 2015-06-01 11:19 ` Paul Aitken
2015-06-01 17:34 ` Pablo Neira Ayuso
0 siblings, 1 reply; 7+ messages in thread
From: Paul Aitken @ 2015-06-01 11:19 UTC (permalink / raw)
To: Pablo Neira Ayuso; +Cc: netfilter-devel
Pablo,
> On Mon, Jun 01, 2015 at 10:22:00AM +0100, Paul Aitken wrote:
>> ct and myct have both already been checked for non-NULL,
>> so there's no need to check either of them again later.
>>
>> Signed-off-by: Paul Aitken <paitken@brocade.com>
>> ---
>> src/cthelper.c | 8 +++-----
>> 1 file changed, 3 insertions(+), 5 deletions(-)
>>
>> diff --git a/src/cthelper.c b/src/cthelper.c
>> index 15d5126..6537515 100644
>> --- a/src/cthelper.c
>> +++ b/src/cthelper.c
>> @@ -325,14 +325,12 @@ static int nfq_queue_cb(const struct nlmsghdr *nlh, void *data)
>> if (pkt_verdict_issue(helper, myct, queue_num, id, verdict, pktb) < 0)
>> goto err_pktb;
>> - if (ct != NULL)
>> - nfct_destroy(ct);
>> + nfct_destroy(ct);
> void nfct_destroy(struct nf_conntrack *ct)
> {
> assert(ct != NULL);
> ...
>
> the library doesn't allow NULL pointers.
ct was already checked for non-NULL when it was assigned around line 297:
ct = nfct_new();
if (ct == NULL)
goto err;
- so ct cannot be NULL at line 325.
P.
>> if (myct->exp != NULL)
>> nfexp_destroy(myct->exp);
>> - if (myct && myct->priv_data != NULL)
>> + if (myct->priv_data != NULL)
>> free(myct->priv_data);
>> - if (myct != NULL)
>> - free(myct);
>> + free(myct);
>> return MNL_CB_OK;
>> err_pktb:
>> --
>> 1.9.1
>>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Optimise nfq_queue_cb
2015-06-01 11:19 ` Paul Aitken
@ 2015-06-01 17:34 ` Pablo Neira Ayuso
2015-06-04 9:13 ` Paul Aitken
0 siblings, 1 reply; 7+ messages in thread
From: Pablo Neira Ayuso @ 2015-06-01 17:34 UTC (permalink / raw)
To: Paul Aitken; +Cc: netfilter-devel
On Mon, Jun 01, 2015 at 12:19:20PM +0100, Paul Aitken wrote:
> Pablo,
>
> >On Mon, Jun 01, 2015 at 10:22:00AM +0100, Paul Aitken wrote:
> >>ct and myct have both already been checked for non-NULL,
> >>so there's no need to check either of them again later.
> >>
> >>Signed-off-by: Paul Aitken <paitken@brocade.com>
> >>---
> >> src/cthelper.c | 8 +++-----
> >> 1 file changed, 3 insertions(+), 5 deletions(-)
> >>
> >>diff --git a/src/cthelper.c b/src/cthelper.c
> >>index 15d5126..6537515 100644
> >>--- a/src/cthelper.c
> >>+++ b/src/cthelper.c
> >>@@ -325,14 +325,12 @@ static int nfq_queue_cb(const struct nlmsghdr *nlh, void *data)
> >> if (pkt_verdict_issue(helper, myct, queue_num, id, verdict, pktb) < 0)
> >> goto err_pktb;
> >>- if (ct != NULL)
> >>- nfct_destroy(ct);
> >>+ nfct_destroy(ct);
> >void nfct_destroy(struct nf_conntrack *ct)
> >{
> > assert(ct != NULL);
> > ...
> >
> >the library doesn't allow NULL pointers.
>
> ct was already checked for non-NULL when it was assigned around line 297:
>
> ct = nfct_new();
> if (ct == NULL)
> goto err;
>
> - so ct cannot be NULL at line 325.
Right, makes sense. However, your patch doesn't apply here for some
reason:
$ git am Optimise-nfq_queue_cb.patch
Applying: Optimise nfq_queue_cb
error: patch failed: src/cthelper.c:325
error: src/cthelper.c: patch does not apply
Patch failed at 0001 Optimise nfq_queue_cb
When you have resolved this problem run "git am --resolved".
If you would prefer to skip this patch, instead run "git am --skip".
To restore the original branch and stop patching run "git am --abort"
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Optimise nfq_queue_cb
2015-06-01 17:34 ` Pablo Neira Ayuso
@ 2015-06-04 9:13 ` Paul Aitken
0 siblings, 0 replies; 7+ messages in thread
From: Paul Aitken @ 2015-06-04 9:13 UTC (permalink / raw)
To: Pablo Neira Ayuso; +Cc: netfilter-devel
Pablo, somehow tabs had been converted to spaces.
Let me try again...
P.
On 01/06/15 18:34, Pablo Neira Ayuso wrote:
> On Mon, Jun 01, 2015 at 12:19:20PM +0100, Paul Aitken wrote:
>> Pablo,
>>
>>> On Mon, Jun 01, 2015 at 10:22:00AM +0100, Paul Aitken wrote:
>>>> ct and myct have both already been checked for non-NULL,
>>>> so there's no need to check either of them again later.
>>>>
>>>> Signed-off-by: Paul Aitken <paitken@brocade.com>
>>>> ---
>>>> src/cthelper.c | 8 +++-----
>>>> 1 file changed, 3 insertions(+), 5 deletions(-)
>>>>
>>>> diff --git a/src/cthelper.c b/src/cthelper.c
>>>> index 15d5126..6537515 100644
>>>> --- a/src/cthelper.c
>>>> +++ b/src/cthelper.c
>>>> @@ -325,14 +325,12 @@ static int nfq_queue_cb(const struct nlmsghdr *nlh, void *data)
>>>> if (pkt_verdict_issue(helper, myct, queue_num, id, verdict, pktb) < 0)
>>>> goto err_pktb;
>>>> - if (ct != NULL)
>>>> - nfct_destroy(ct);
>>>> + nfct_destroy(ct);
>>> void nfct_destroy(struct nf_conntrack *ct)
>>> {
>>> assert(ct != NULL);
>>> ...
>>>
>>> the library doesn't allow NULL pointers.
>> ct was already checked for non-NULL when it was assigned around line 297:
>>
>> ct = nfct_new();
>> if (ct == NULL)
>> goto err;
>>
>> - so ct cannot be NULL at line 325.
> Right, makes sense. However, your patch doesn't apply here for some
> reason:
>
> $ git am Optimise-nfq_queue_cb.patch
> Applying: Optimise nfq_queue_cb
> error: patch failed: src/cthelper.c:325
> error: src/cthelper.c: patch does not apply
> Patch failed at 0001 Optimise nfq_queue_cb
> When you have resolved this problem run "git am --resolved".
> If you would prefer to skip this patch, instead run "git am --skip".
> To restore the original branch and stop patching run "git am --abort"
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH] Optimise nfq_queue_cb
@ 2015-06-04 9:15 Paul Aitken
2015-06-12 13:08 ` Pablo Neira Ayuso
0 siblings, 1 reply; 7+ messages in thread
From: Paul Aitken @ 2015-06-04 9:15 UTC (permalink / raw)
To: netfilter-devel; +Cc: pablo, paitken
ct and myct have both already been checked for non-NULL,
so there's no need to check either of them again later.
Signed-off-by: Paul Aitken <paitken@brocade.com>
---
src/cthelper.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/src/cthelper.c b/src/cthelper.c
index 15d5126..6537515 100644
--- a/src/cthelper.c
+++ b/src/cthelper.c
@@ -325,14 +325,12 @@ static int nfq_queue_cb(const struct nlmsghdr *nlh, void *data)
if (pkt_verdict_issue(helper, myct, queue_num, id, verdict, pktb) < 0)
goto err_pktb;
- if (ct != NULL)
- nfct_destroy(ct);
+ nfct_destroy(ct);
if (myct->exp != NULL)
nfexp_destroy(myct->exp);
- if (myct && myct->priv_data != NULL)
+ if (myct->priv_data != NULL)
free(myct->priv_data);
- if (myct != NULL)
- free(myct);
+ free(myct);
return MNL_CB_OK;
err_pktb:
--
1.9.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] Optimise nfq_queue_cb
2015-06-04 9:15 [PATCH] Optimise nfq_queue_cb Paul Aitken
@ 2015-06-12 13:08 ` Pablo Neira Ayuso
0 siblings, 0 replies; 7+ messages in thread
From: Pablo Neira Ayuso @ 2015-06-12 13:08 UTC (permalink / raw)
To: Paul Aitken; +Cc: netfilter-devel
On Thu, Jun 04, 2015 at 10:15:00AM +0100, Paul Aitken wrote:
> ct and myct have both already been checked for non-NULL,
> so there's no need to check either of them again later.
Applied, thanks.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2015-06-12 13:03 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-04 9:15 [PATCH] Optimise nfq_queue_cb Paul Aitken
2015-06-12 13:08 ` Pablo Neira Ayuso
[not found] <md5:KJl5IfCAjtPWb+o93HAjWA==>
2015-06-01 9:22 ` Paul Aitken
2015-06-01 11:03 ` Pablo Neira Ayuso
2015-06-01 11:19 ` Paul Aitken
2015-06-01 17:34 ` Pablo Neira Ayuso
2015-06-04 9:13 ` Paul Aitken
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).