[PATCH v2 4/4] net/l2tpv3: Simplify LD/ST API uses

Philippe Mathieu-Daudé posted 4 patches 1 month, 3 weeks ago
[PATCH v2 4/4] net/l2tpv3: Simplify LD/ST API uses
Posted by Philippe Mathieu-Daudé 1 month, 3 weeks ago
Directly call ldn_be_p once instead of ldl_be_p / ldq_be_p.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 net/l2tpv3.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/net/l2tpv3.c b/net/l2tpv3.c
index b5547cb917..7a0d5dcfe9 100644
--- a/net/l2tpv3.c
+++ b/net/l2tpv3.c
@@ -318,11 +318,7 @@ static int l2tpv3_verify_header(NetL2TPV3State *s, uint8_t *buf)
     */
 
     if (s->cookie) {
-        if (s->cookie_is_64) {
-            cookie = ldq_be_p(buf + s->cookie_offset);
-        } else {
-            cookie = ldl_be_p(buf + s->cookie_offset) & 0xffffffffULL;
-        }
+        cookie = ldn_be_p(buf + s->cookie_offset, s->cookie_is_64 ? 8 : 4);
         if (cookie != s->rx_cookie) {
             if (!s->header_mismatch) {
                 error_report("unknown cookie id");
-- 
2.45.2


Re: [PATCH v2 4/4] net/l2tpv3: Simplify LD/ST API uses
Posted by Richard Henderson 1 month, 3 weeks ago
On 9/27/24 14:50, Philippe Mathieu-Daudé wrote:
> Directly call ldn_be_p once instead of ldl_be_p / ldq_be_p.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   net/l2tpv3.c | 6 +-----
>   1 file changed, 1 insertion(+), 5 deletions(-)
> 
> diff --git a/net/l2tpv3.c b/net/l2tpv3.c
> index b5547cb917..7a0d5dcfe9 100644
> --- a/net/l2tpv3.c
> +++ b/net/l2tpv3.c
> @@ -318,11 +318,7 @@ static int l2tpv3_verify_header(NetL2TPV3State *s, uint8_t *buf)
>       */
>   
>       if (s->cookie) {
> -        if (s->cookie_is_64) {
> -            cookie = ldq_be_p(buf + s->cookie_offset);
> -        } else {
> -            cookie = ldl_be_p(buf + s->cookie_offset) & 0xffffffffULL;
> -        }
> +        cookie = ldn_be_p(buf + s->cookie_offset, s->cookie_is_64 ? 8 : 4);
>           if (cookie != s->rx_cookie) {
>               if (!s->header_mismatch) {
>                   error_report("unknown cookie id");

Is this really an improvement?  I don't see it.


r~