From: Nishanth Aravamudan <nacc@us.ibm.com>
To: "Daniel Marjamäki" <daniel.marjamaki@gmail.com>
Cc: netdev@vger.kernel.org, kernel-janitors@lists.osdl.org,
linux-kernel@vger.kernel.org
Subject: Re: [KJ] [PATCH] net/core/flow.c: compare data with memcmp
Date: Sun, 31 Dec 2006 19:49:39 +0000 [thread overview]
Message-ID: <20061231194939.GA14048@us.ibm.com> (raw)
In-Reply-To: <80ec54e90612310837y786fd764oc18bf37c8f0b2b8c@mail.gmail.com>
On 31.12.2006 [17:37:05 +0100], Daniel Marjam?ki wrote:
> From: Daniel Marjamäki
> This has been tested by me.
> Signed-off-by: Daniel Marjamäki <daniel.marjamaki@gmail.com>
> --- linux-2.6.20-rc2/net/core/flow.c 2006-12-27 09:59:56.000000000 +0100
> +++ linux/net/core/flow.c 2006-12-31 18:26:06.000000000 +0100
> @@ -144,29 +144,16 @@ typedef u32 flow_compare_t;
>
> extern void flowi_is_missized(void);
>
> -/* I hear what you're saying, use memcmp. But memcmp cannot make
> - * important assumptions that we can here, such as alignment and
> - * constant size.
> - */
> static int flow_key_compare(struct flowi *key1, struct flowi *key2)
> {
> - flow_compare_t *k1, *k1_lim, *k2;
> - const int n_elem = sizeof(struct flowi) / sizeof(flow_compare_t);
> -
> if (sizeof(struct flowi) % sizeof(flow_compare_t))
> flowi_is_missized();
>
> - k1 = (flow_compare_t *) key1;
> - k1_lim = k1 + n_elem;
> -
> - k2 = (flow_compare_t *) key2;
> -
> - do {
> - if (*k1++ != *k2++)
> - return 1;
> - } while (k1 < k1_lim);
> + /* Number of elements to compare */
> + const int n_elem = sizeof(struct flowi) / sizeof(flow_compare_t);
>
> - return 0;
> + /* Compare all elements in key1 and key2. */
> + return memcmp(key1, key2, n_elem * sizeof(flow_compare_t));
> }
Small nit, I don't think either of your comments make the code any
clearer than the code on its own, so drop them both.
Thanks,
Nish
--
Nishanth Aravamudan <nacc@us.ibm.com>
IBM Linux Technology Center
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors
WARNING: multiple messages have this Message-ID (diff)
From: Nishanth Aravamudan <nacc@us.ibm.com>
To: "Daniel Marjamäki" <daniel.marjamaki@gmail.com>
Cc: netdev@vger.kernel.org, kernel-janitors@lists.osdl.org,
linux-kernel@vger.kernel.org
Subject: Re: [KJ] [PATCH] net/core/flow.c: compare data with memcmp
Date: Sun, 31 Dec 2006 11:49:39 -0800 [thread overview]
Message-ID: <20061231194939.GA14048@us.ibm.com> (raw)
In-Reply-To: <80ec54e90612310837y786fd764oc18bf37c8f0b2b8c@mail.gmail.com>
On 31.12.2006 [17:37:05 +0100], Daniel Marjam?ki wrote:
> From: Daniel Marjamäki
> This has been tested by me.
> Signed-off-by: Daniel Marjamäki <daniel.marjamaki@gmail.com>
> --- linux-2.6.20-rc2/net/core/flow.c 2006-12-27 09:59:56.000000000 +0100
> +++ linux/net/core/flow.c 2006-12-31 18:26:06.000000000 +0100
> @@ -144,29 +144,16 @@ typedef u32 flow_compare_t;
>
> extern void flowi_is_missized(void);
>
> -/* I hear what you're saying, use memcmp. But memcmp cannot make
> - * important assumptions that we can here, such as alignment and
> - * constant size.
> - */
> static int flow_key_compare(struct flowi *key1, struct flowi *key2)
> {
> - flow_compare_t *k1, *k1_lim, *k2;
> - const int n_elem = sizeof(struct flowi) / sizeof(flow_compare_t);
> -
> if (sizeof(struct flowi) % sizeof(flow_compare_t))
> flowi_is_missized();
>
> - k1 = (flow_compare_t *) key1;
> - k1_lim = k1 + n_elem;
> -
> - k2 = (flow_compare_t *) key2;
> -
> - do {
> - if (*k1++ != *k2++)
> - return 1;
> - } while (k1 < k1_lim);
> + /* Number of elements to compare */
> + const int n_elem = sizeof(struct flowi) / sizeof(flow_compare_t);
>
> - return 0;
> + /* Compare all elements in key1 and key2. */
> + return memcmp(key1, key2, n_elem * sizeof(flow_compare_t));
> }
Small nit, I don't think either of your comments make the code any
clearer than the code on its own, so drop them both.
Thanks,
Nish
--
Nishanth Aravamudan <nacc@us.ibm.com>
IBM Linux Technology Center
next prev parent reply other threads:[~2006-12-31 19:49 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-12-31 16:37 [KJ] [PATCH] net/core/flow.c: compare data with memcmp Daniel Marjamäki
2006-12-31 16:37 ` Daniel Marjamäki
2006-12-31 19:49 ` Nishanth Aravamudan [this message]
2006-12-31 19:49 ` [KJ] " Nishanth Aravamudan
2006-12-31 20:37 ` David Miller
2006-12-31 20:37 ` David Miller
2007-01-01 7:47 ` [KJ] " Daniel Marjamäki
2007-01-01 7:47 ` Daniel Marjamäki
2007-01-01 8:49 ` [KJ] " David Miller
2007-01-01 8:49 ` David Miller
2007-01-01 9:16 ` [KJ] " Daniel Marjamäki
2007-01-01 9:16 ` Daniel Marjamäki
2007-01-02 23:36 ` [KJ] " David Miller
2007-01-02 23:36 ` David Miller
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=20061231194939.GA14048@us.ibm.com \
--to=nacc@us.ibm.com \
--cc=daniel.marjamaki@gmail.com \
--cc=kernel-janitors@lists.osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.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 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.