[usr/src/sys/contrib/ncsw/Peripherals/QM/qm_portal_fqr.c:1437]: (error) Shifting 32-bit value by 63 bits is undefined behaviour Source code is for (tmpN=7 ; tmpN<64; tmpN++ ) { tmp = ABS((int)(slope - tmpA/(1<<tmpN))); Maybe better code for (tmpN=7 ; tmpN<64; tmpN++ ) { tmp = ABS((int)(slope - tmpA / (1UL << tmpN)));
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=7 ; tmpN<64; tmpN++ ) { //tmp = (1<<(tmpN%32)); tmp = (1UL<<(tmpN%32)); printf("%d\n", tmp); } return 0; } Patch for the problem: Index: sys/contrib/ncsw/Peripherals/QM/qm_portal_fqr.c =================================================================== --- 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=(uint32_t)(64*pres) ; tmpA<128*pres; tmpA += pres ) for (tmpN=7 ; tmpN<64; tmpN++ ) { - tmp = ABS((int)(slope - tmpA/(1<<tmpN))); + tmp = ABS((int)(slope - tmpA/(1UL<<(tmpN%32)))); if (tmp < gap) { sa = tmpA;
Bump.
I am not sure who the bump is for. If it is for me, I gave up working on freebsd a year or two back and so you are on your own with this one. 1 is a 32 bit value, 1UL can be a 64 bit value on some architectures.
(In reply to David Binderman from comment #5) > If it is for me, I gave up working on freebsd a year or two back and so you are on your own with this one. For freebsd-bugs@, so some committer would pick this up and commit. You can remove yourself from CC list, I think.
(In reply to Gleb Popov from comment #6) > You can remove yourself from CC list, I think. No, he can't, as he is the originator, and not actually on the Cc: list.
(In reply to Mark Linimon from comment #7) Then let's commit this trivial patch and bother reporter no more.
A commit references this bug: Author: arrowd Date: Sat Dec 21 11:38:48 UTC 2019 New revision: 355980 URL: https://svnweb.freebsd.org/changeset/base/355980 Log: Don't shift 32-bit value by more than 32 bits. PR: 207854 Approved by: emaste Changes: head/sys/contrib/ncsw/Peripherals/QM/qm_portal_fqr.c