From: "Jan Beulich" Subject: [PATCH] only use legitimate shift counts in bitmap shifting Date: Wed, 23 Apr 2014 07:50:17 +0100 Message-ID: <53577EC9020000780000B223@nat28.tlf.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__PartB785BEB9.1__=" Return-path: Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Wcr0f-000475-FM for xen-devel@lists.xenproject.org; Wed, 23 Apr 2014 06:50:21 +0000 List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel Cc: Ian Campbell , Keir Fraser , Ian Jackson , Tim Deegan List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__PartB785BEB9.1__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline An alternative would be to remove these implicitly unused functions. Coverity ID 1192174 (__bitmap_shift_right) Coverity ID 1192175 (__bitmap_shift_left) Signed-off-by: Jan Beulich --- a/xen/common/bitmap.c +++ b/xen/common/bitmap.c @@ -144,7 +144,9 @@ void __bitmap_shift_right(unsigned long=20 lower =3D src[off + k]; if (left && off + k =3D=3D lim - 1) lower &=3D mask; - dst[k] =3D upper << (BITS_PER_LONG - rem) | lower >> rem; + dst[k] =3D rem + ? (upper << (BITS_PER_LONG - rem)) | (lower >> = rem) + : lower; if (left && k =3D=3D lim - 1) dst[k] &=3D mask; } @@ -185,7 +187,9 @@ void __bitmap_shift_left(unsigned long * upper =3D src[k]; if (left && k =3D=3D lim - 1) upper &=3D (1UL << left) - 1; - dst[k + off] =3D lower >> (BITS_PER_LONG - rem) | upper = << rem; + dst[k + off] =3D rem ? (lower >> (BITS_PER_LONG - rem)) + | (upper << rem) + : upper; if (left && k + off =3D=3D lim - 1) dst[k + off] &=3D (1UL << left) - 1; } --=__PartB785BEB9.1__= Content-Type: text/plain; name="bitmap-shift-counts.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="bitmap-shift-counts.patch" only use legitimate shift counts in bitmap shifting=0A=0AAn alternative = would be to remove these implicitly unused functions.=0A=0ACoverity ID = 1192174 (__bitmap_shift_right)=0ACoverity ID 1192175 (__bitmap_shift_left)= =0A=0ASigned-off-by: Jan Beulich =0A=0A--- a/xen/common/= bitmap.c=0A+++ b/xen/common/bitmap.c=0A@@ -144,7 +144,9 @@ void __bitmap_sh= ift_right(unsigned long =0A lower =3D src[off + k];=0A = if (left && off + k =3D=3D lim - 1)=0A lower &=3D = mask;=0A- dst[k] =3D upper << (BITS_PER_LONG - rem) | lower = >> rem;=0A+ dst[k] =3D rem=0A+ ? (upper = << (BITS_PER_LONG - rem)) | (lower >> rem)=0A+ : = lower;=0A if (left && k =3D=3D lim - 1)=0A = dst[k] &=3D mask;=0A }=0A@@ -185,7 +187,9 @@ void __bitmap_shift_left(un= signed long *=0A upper =3D src[k];=0A if (left = && k =3D=3D lim - 1)=0A upper &=3D (1UL << left) - = 1;=0A- dst[k + off] =3D lower >> (BITS_PER_LONG - rem) | upper = << rem;=0A+ dst[k + off] =3D rem ? (lower >> (BITS_PER_LONG - = rem))=0A+ | (upper << rem)=0A+ = : upper;=0A if (left && k + off =3D=3D lim - = 1)=0A dst[k + off] &=3D (1UL << left) - 1;=0A = }=0A --=__PartB785BEB9.1__= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --=__PartB785BEB9.1__=--