From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 795F645D5D; Thu, 21 Nov 2024 00:12:31 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3453543252; Thu, 21 Nov 2024 00:12:31 +0100 (CET) Received: from inbox.dpdk.org (inbox.dpdk.org [95.142.172.178]) by mails.dpdk.org (Postfix) with ESMTP id D850F40296 for ; Thu, 21 Nov 2024 00:12:29 +0100 (CET) Received: by inbox.dpdk.org (Postfix, from userid 33) id CF50E45D5E; Thu, 21 Nov 2024 00:12:29 +0100 (CET) From: bugzilla@dpdk.org To: dev@dpdk.org Subject: [DPDK/other Bug 1587] lpm: undefined right shift Date: Wed, 20 Nov 2024 23:12:29 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: DPDK X-Bugzilla-Component: other X-Bugzilla-Version: unspecified X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: stephen@networkplumber.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: Normal X-Bugzilla-Assigned-To: dev@dpdk.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: multipart/alternative; boundary=17321443490.0B7b1f8.815806 Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://bugs.dpdk.org/ Auto-Submitted: auto-generated X-Auto-Response-Suppress: All MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org --17321443490.0B7b1f8.815806 Date: Thu, 21 Nov 2024 00:12:29 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://bugs.dpdk.org/ Auto-Submitted: auto-generated X-Auto-Response-Suppress: All https://bugs.dpdk.org/show_bug.cgi?id=3D1587 Bug ID: 1587 Summary: lpm: undefined right shift Product: DPDK Version: unspecified Hardware: All OS: All Status: UNCONFIRMED Severity: normal Priority: Normal Component: other Assignee: dev@dpdk.org Reporter: stephen@networkplumber.org Target Milestone: --- Both rte_lpm.c and rte_lpm6.c are using >> operator on a negative integer. According to the C standard the result of that is implementation defined (ie not portable). Reported by PVS studio as warning: https://pvs-studio.com/en/docs/warnings/v610/ static uint32_t __rte_pure depth_to_mask(uint8_t depth) { VERIFY_DEPTH(depth); /* To calculate a mask start with a 1 on the left hand side and rig= ht * shift while populating the left hand side with 1's */ return (int)0x80000000 >> (depth - 1); } and static uint8_t __rte_pure depth_to_mask_1b(uint8_t depth) { /* To calculate a mask start with a 1 on the left hand side and rig= ht * shift while populating the left hand side with 1's */ return (signed char)0x80 >> (depth - 1); } --=20 You are receiving this mail because: You are the assignee for the bug.= --17321443490.0B7b1f8.815806 Date: Thu, 21 Nov 2024 00:12:29 +0100 MIME-Version: 1.0 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://bugs.dpdk.org/ Auto-Submitted: auto-generated X-Auto-Response-Suppress: All
Bug ID 1587
Summary lpm: undefined right shift
Product DPDK
Version unspecified
Hardware All
OS All
Status UNCONFIRMED
Severity normal
Priority Normal
Component other
Assignee dev@dpdk.org
Reporter stephen@networkplumber.org
Target Milestone ---

Both rte_lpm.c and rte_lpm6.c are =
using >> operator on a negative integer.
According to the C standard the result of that is implementation defined (ie
not portable).

Reported by PVS studio as warning:
https://pvs-studi=
o.com/en/docs/warnings/v610/

static uint32_t __rte_pure
depth_to_mask(uint8_t depth)
{
        VERIFY_DEPTH(depth);

        /* To calculate a mask start with a 1 on the left hand side and rig=
ht
         * shift while populating the left hand side with 1's
         */
        return (int)0x80000000 >> (depth - 1);
}

and

static uint8_t __rte_pure
depth_to_mask_1b(uint8_t depth)
{
        /* To calculate a mask start with a 1 on the left hand side and rig=
ht
         * shift while populating the left hand side with 1's
         */
        return (signed char)0x80 >> (depth - 1);
}
          


You are receiving this mail because:
  • You are the assignee for the bug.
=20=20=20=20=20=20=20=20=20=20
= --17321443490.0B7b1f8.815806--