Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752294AbbLCWDA (ORCPT ); Thu, 3 Dec 2015 17:03:00 -0500 Received: from aserp1040.oracle.com ([141.146.126.69]:24470 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750731AbbLCWC6 (ORCPT ); Thu, 3 Dec 2015 17:02:58 -0500 From: Sasha Levin To: torvalds@linux-foundation.org Cc: mingo@kernel.org, linux-kernel@vger.kernel.org, Sasha Levin Subject: [PATCH] bitops.h: correctly handle rol32 with 0 byte shift Date: Thu, 3 Dec 2015 17:02:45 -0500 Message-Id: <1449180165-5629-1-git-send-email-sasha.levin@oracle.com> X-Mailer: git-send-email 2.5.0 X-Source-IP: aserv0022.oracle.com [141.146.126.234] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 983 Lines: 30 rol on a 32 bit integer with a shift of 32 or more is undefined and the result is arch-dependent. Avoid this by handling the trivial case of roling by 0 correctly. Signed-off-by: Sasha Levin --- include/linux/bitops.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/bitops.h b/include/linux/bitops.h index 2b8ed12..7047a06 100644 --- a/include/linux/bitops.h +++ b/include/linux/bitops.h @@ -107,7 +107,7 @@ static inline __u64 ror64(__u64 word, unsigned int shift) */ static inline __u32 rol32(__u32 word, unsigned int shift) { - return (word << shift) | (word >> (32 - shift)); + return shift ? (word << shift) | (word >> (32 - shift)) : word; } /** -- 1.7.10.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/