* [PATCH nf-next 1/1] netfilter: nf_tables: Remove one useless condition check in nf_tables_newobj
@ 2017-01-06 1:49 fgao
2017-01-11 1:34 ` Feng Gao
0 siblings, 1 reply; 2+ messages in thread
From: fgao @ 2017-01-06 1:49 UTC (permalink / raw)
To: pablo, netfilter-devel; +Cc: gfree.wind, Gao Feng
From: Gao Feng <fgao@ikuai8.com>
The return value of nf_tables_obj_lookup is valid pointer or one error.
There are two cases in nf_tables_newobj totally.
case1: return value is -ENOENT, the obj is NULL, it is unnecessary to
perform the latter check "obj != NULL".
case2: IS_ERR(obj) is false, the obj is one valid pointer. It is also
unnecessary to perform that check.
In summary, we could move the block of condition check "obj != NULL" in
the else block to erase the original condition check.
Signed-off-by: Gao Feng <fgao@ikuai8.com>
---
net/netfilter/nf_tables_api.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
index a019a87..bc55086 100644
--- a/net/netfilter/nf_tables_api.c
+++ b/net/netfilter/nf_tables_api.c
@@ -4154,9 +4154,7 @@ static int nf_tables_newobj(struct net *net, struct sock *nlsk,
return err;
obj = NULL;
- }
-
- if (obj != NULL) {
+ } else {
if (nlh->nlmsg_flags & NLM_F_EXCL)
return -EEXIST;
--
1.9.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH nf-next 1/1] netfilter: nf_tables: Remove one useless condition check in nf_tables_newobj
2017-01-06 1:49 [PATCH nf-next 1/1] netfilter: nf_tables: Remove one useless condition check in nf_tables_newobj fgao
@ 2017-01-11 1:34 ` Feng Gao
0 siblings, 0 replies; 2+ messages in thread
From: Feng Gao @ 2017-01-11 1:34 UTC (permalink / raw)
To: Pablo Neira Ayuso, Netfilter Developer Mailing List; +Cc: Feng Gao, Gao Feng
On Fri, Jan 6, 2017 at 9:49 AM, <fgao@ikuai8.com> wrote:
> From: Gao Feng <fgao@ikuai8.com>
>
> The return value of nf_tables_obj_lookup is valid pointer or one error.
> There are two cases in nf_tables_newobj totally.
> case1: return value is -ENOENT, the obj is NULL, it is unnecessary to
> perform the latter check "obj != NULL".
> case2: IS_ERR(obj) is false, the obj is one valid pointer. It is also
> unnecessary to perform that check.
>
> In summary, we could move the block of condition check "obj != NULL" in
> the else block to erase the original condition check.
>
> Signed-off-by: Gao Feng <fgao@ikuai8.com>
> ---
> net/netfilter/nf_tables_api.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
> index a019a87..bc55086 100644
> --- a/net/netfilter/nf_tables_api.c
> +++ b/net/netfilter/nf_tables_api.c
> @@ -4154,9 +4154,7 @@ static int nf_tables_newobj(struct net *net, struct sock *nlsk,
> return err;
>
> obj = NULL;
> - }
> -
> - if (obj != NULL) {
> + } else {
> if (nlh->nlmsg_flags & NLM_F_EXCL)
> return -EEXIST;
>
> --
> 1.9.1
>
>
Hi all,
Please ignore this patch.
Because I find the nf_tables_newtable and nf_tables_newset have same
logic, so I update them too, and send another patch.
The link is https://patchwork.ozlabs.org/patch/713533/.
Regards
Feng
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-01-11 1:34 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-06 1:49 [PATCH nf-next 1/1] netfilter: nf_tables: Remove one useless condition check in nf_tables_newobj fgao
2017-01-11 1:34 ` Feng Gao
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.