From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2E7F7C2B9F8 for ; Mon, 24 May 2021 16:09:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1201B613F3 for ; Mon, 24 May 2021 16:09:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238571AbhEXQKM (ORCPT ); Mon, 24 May 2021 12:10:12 -0400 Received: from mx0a-001ae601.pphosted.com ([67.231.149.25]:30500 "EHLO mx0b-001ae601.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S235234AbhEXQCR (ORCPT ); Mon, 24 May 2021 12:02:17 -0400 Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 14OFuU53001137; Mon, 24 May 2021 10:59:47 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=PODMain02222019; bh=t7oD8o6YlaId7lQcSwE01onDIVJknueiqM/7K/h1GH8=; b=VwOAs05eR0Ez7q86KKN0qZmQ045AZ7G9ZPT/5FDRR/+kRW0BjIbwXmFhYUCRv4qA5NoH +r1ovh1gMEsPc3rasPlmvbCYOxIDRvMvKsp2w1hnlyXz+6+POyLrZv68EI6qhQKRs+hK V7mYuuDIqeMRQEnaU6koZbBpDLc0C3KdJgrrVuQsOGEnets2uDWVInpemS0ZaarL65lg Q/5P5fYMFrUwY0bDNUO5y59ld7MfJM6Jn9IEf1Wfwny21Ogt9RlJ0LjZrgW8wDpZpfcK 8rqvleo+hxnDpYjdNxVsPBdUhVAz1fKux4+tTj52ij8PsfdDqte3j5EGbJkNt7pBpI6g SQ== Received: from ediex02.ad.cirrus.com ([87.246.76.36]) by mx0a-001ae601.pphosted.com with ESMTP id 38r7ck8h1w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Mon, 24 May 2021 10:59:47 -0500 Received: from EDIEX01.ad.cirrus.com (198.61.84.80) by EDIEX02.ad.cirrus.com (198.61.84.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.4; Mon, 24 May 2021 16:59:45 +0100 Received: from ediswmail.ad.cirrus.com (198.61.86.93) by EDIEX01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server id 15.1.2242.4 via Frontend Transport; Mon, 24 May 2021 16:59:45 +0100 Received: from AUSNPC0LSNW1-debian.cirrus.com (AUSNPC0LSNW1.ad.cirrus.com [198.61.64.127]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id C8A0B11D7; Mon, 24 May 2021 15:59:43 +0000 (UTC) From: Richard Fitzgerald To: , , , , , , , , CC: , , , Richard Fitzgerald Subject: [PATCH 2/2] random32: Fix implicit truncation warning in prandom_seed_state() Date: Mon, 24 May 2021 16:59:41 +0100 Message-ID: <20210524155941.16376-3-rf@opensource.cirrus.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210524155941.16376-1-rf@opensource.cirrus.com> References: <20210524155941.16376-1-rf@opensource.cirrus.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-GUID: 8qiPNsruat1m2se0mdfX6nMFVPN21Zr7 X-Proofpoint-ORIG-GUID: 8qiPNsruat1m2se0mdfX6nMFVPN21Zr7 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxlogscore=857 adultscore=0 spamscore=0 lowpriorityscore=0 suspectscore=0 phishscore=0 priorityscore=1501 impostorscore=0 bulkscore=0 mlxscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2105240096 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org sparse generates the following warning: include/linux/prandom.h:114:45: sparse: sparse: cast truncates bits from constant value This is because the 64-bit seed value is manipulated and then placed in a u32, causing an implicit cast and truncation. A forced cast to u32 doesn't prevent this warning, which is reasonable because a typecast doesn't prove that truncation was expected. Logical-AND the value with 0xffffffff to make explicit that truncation to 32-bit is intended. Reported-by: kernel test robot Signed-off-by: Richard Fitzgerald --- include/linux/prandom.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/prandom.h b/include/linux/prandom.h index bbf4b4ad61df..056d31317e49 100644 --- a/include/linux/prandom.h +++ b/include/linux/prandom.h @@ -111,7 +111,7 @@ static inline u32 __seed(u32 x, u32 m) */ static inline void prandom_seed_state(struct rnd_state *state, u64 seed) { - u32 i = (seed >> 32) ^ (seed << 10) ^ seed; + u32 i = ((seed >> 32) ^ (seed << 10) ^ seed) & 0xffffffffUL; state->s1 = __seed(i, 2U); state->s2 = __seed(i, 8U); -- 2.20.1