byacc: fix UBSan signed shift range error

I've submitted this patch upstream, so apply this to contrib/ until a new
version containing this change has been released.

Reviewed By:	jkim
Differential Revision: https://reviews.freebsd.org/D26505
This commit is contained in:
Alex Richardson 2020-09-23 12:54:42 +00:00
parent 1e266857ad
commit d1e106f262
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=366075
2 changed files with 4 additions and 4 deletions

View File

@ -87,7 +87,7 @@ set_first_derives(void)
k = 0;
}
if (cword & (unsigned)(1 << k))
if (cword & (1u << k))
{
rp = derives[j];
while ((rule = *rp++) >= 0)
@ -151,7 +151,7 @@ closure(Value_t *nucleus, int n)
{
for (i = 0; i < BITS_PER_WORD; ++i)
{
if (word & (unsigned)(1 << i))
if (word & (1u << i))
{
itemno = rrhs[ruleno + i];
while (csp < csend && *csp < itemno)

View File

@ -28,7 +28,7 @@ transitive_closure(unsigned *R, int n)
while (rowj < relend)
{
if (*ccol & (unsigned)(1 << i))
if (*ccol & (1u << i))
{
rp = rowi;
rend = rowj + rowsize;
@ -70,7 +70,7 @@ reflexive_transitive_closure(unsigned *R, int n)
rp = R;
while (rp < relend)
{
*rp |= (unsigned)(1 << i);
*rp |= (1u << i);
if (++i >= BITS_PER_WORD)
{
i = 0;