Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 31 Oct 2019 15:07:18 +0000
From:      bugzilla-noreply@freebsd.org
To:        bugs@FreeBSD.org
Subject:   [Bug 207854] usr/src/sys/contrib/ncsw/Peripherals/QM/qm_portal_fqr.c:1437: bad shift ?
Message-ID:  <bug-207854-227-xOM5tKdhSk@https.bugs.freebsd.org/bugzilla/>
In-Reply-To: <bug-207854-227@https.bugs.freebsd.org/bugzilla/>
References:  <bug-207854-227@https.bugs.freebsd.org/bugzilla/>

next in thread | previous in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D207854

Gleb Popov <arrowd@FreeBSD.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |arrowd@FreeBSD.org

--- Comment #1 from Gleb Popov <arrowd@FreeBSD.org> ---
Not sure how UL would help here, since unsigned long is also 32-bits. The
proper fix is to use tmpN modulo 32 as shift operand. Verified this on
standalone example:

#include <stdio.h>
#include <sys/types.h>

int main(int argc, char* argv[])
{
    uint32_t tmpN;
    int tmp;
    for (tmpN=3D7 ; tmpN<64; tmpN++ )
    {
        //tmp =3D (1<<(tmpN%32));
        tmp =3D (1UL<<(tmpN%32));
        printf("%d\n", tmp);
    }
    return 0;
}


Patch for the problem:

Index: sys/contrib/ncsw/Peripherals/QM/qm_portal_fqr.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- sys/contrib/ncsw/Peripherals/QM/qm_portal_fqr.c     (revision 353638)
+++ sys/contrib/ncsw/Peripherals/QM/qm_portal_fqr.c     (working copy)
@@ -1468,7 +1468,7 @@
     for (tmpA=3D(uint32_t)(64*pres) ; tmpA<128*pres; tmpA +=3D pres )
         for (tmpN=3D7 ; tmpN<64; tmpN++ )
         {
-            tmp =3D ABS((int)(slope - tmpA/(1<<tmpN)));
+            tmp =3D ABS((int)(slope - tmpA/(1UL<<(tmpN%32))));
             if (tmp < gap)
             {
                sa =3D tmpA;

--=20
You are receiving this mail because:
You are the assignee for the bug.=



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-207854-227-xOM5tKdhSk>