Message ID | ff29447dcee834c17e4e1e99725b9454c90136ca.1709178325.git.daniel@makrotopia.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-86100-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2097:b0:108:e6aa:91d0 with SMTP id gs23csp157976dyb; Wed, 28 Feb 2024 19:48:12 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWcc2SbigL5OL0DSW0ze5MePivwqAOEerB8imVLSaqa5pBjSfynlTVVo+DJksZMiJg2q6NtpbXt8EnlNBzIP7XmCYaRJQ== X-Google-Smtp-Source: AGHT+IFTH8mFg9EJWxqe/3MN9uMMi1rRdCl1ii4GBIQF897hqQbuW2VnsAJ4JegWKF7HSQZp018C X-Received: by 2002:a81:df0f:0:b0:604:a75:4274 with SMTP id c15-20020a81df0f000000b006040a754274mr1157275ywn.51.1709178491818; Wed, 28 Feb 2024 19:48:11 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709178491; cv=pass; d=google.com; s=arc-20160816; b=tx5nFzzQBzHbQ5BZdFTl/YJhygk5TyKnyDbcFxJgzqVbr2yu34X87eQkKgXe21CWbj WkgPEqVJHiDvmoOM+B592uja9LntQM9zw+0vN9nPxo2jyhi+8kgMyYkpKOYP3jdfw3/V 7ygx4z1HJyA/FA0wxa2yWwLnKp9uD3M/zZaN5eqSJdgWUA7LK8FiVEQFtW/BIizpOANo mMoZkpwnqIBwe6H51wxOrSClc1Bz1DPs+0hdAGgXc0vQp6qF+FVvKiHrx+jiGGDHd1Z7 mtrNGUZzVl5R8DXl1U5/JKRKoMIz05k9Oh/tCDEd2QaQNACFLUHqumCnbvjoIBPOCNBU s57w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-disposition:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:message-id:subject:to:from:date; bh=/EXzvmN9T3f3iYelIUbtvdakJxiYSQXo2StTuTvk7Lo=; fh=hR6DOXMpV/QGp1KiEfO/RpXoONraJJjwivRjZE+6NAY=; b=tOuYOXeqBQKwPTL12zjQeGN9i+pzpAyTK3kwpllOMWifsaE2P5m/hyhWc3WEMWsr7o nv7QSsriwfMzcfrOBeiondnbnUoPYxwQrCo7VL/NE9XvYdyiYoskLUmESKCCoRQ9v4XV TzWV2A7XZ8iSO+R2RzgECwkv64QiGgnnY5f4b40yNbWmy4oSVd8iMBBtaueeJvVODGDZ aSSauW740NqklXo/BcO6QcC/3eVy7LfdwHuxRXzwWowEBghkRJOpd9Nv1+B389KMsWX3 3GwXDbI7uJZkx43soko03Tha9B63EOoapQvMr2/3w2Objz8uJKAwkxEbzzERKR+j+ZDF UX4g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=makrotopia.org); spf=pass (google.com: domain of linux-kernel+bounces-86100-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-86100-ouuuleilei=gmail.com@vger.kernel.org" Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id d72-20020a63364b000000b005dc893fcd90si504759pga.362.2024.02.28.19.48.11 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 19:48:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-86100-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=makrotopia.org); spf=pass (google.com: domain of linux-kernel+bounces-86100-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-86100-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 970912887DA for <ouuuleilei@gmail.com>; Thu, 29 Feb 2024 03:48:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9BC4F383A9; Thu, 29 Feb 2024 03:48:01 +0000 (UTC) Received: from pidgin.makrotopia.org (pidgin.makrotopia.org [185.142.180.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CAD04381B0 for <linux-kernel@vger.kernel.org>; Thu, 29 Feb 2024 03:47:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.142.180.65 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709178480; cv=none; b=Jqykveq5XtZhJj0TW5c07ZES3ie2jaR5SgXLWuYZiTd6YsptwiGdHx8zE+yvDguJN37cbd0ivxJ3JsV0OkPLdg/V5Oe6LoLQT142FeOxtMRKwZpEbpDte7zlT2U5arx377vGmi3O3jqH72phiarixIQH2KN77kgh6ImPszF9Kms= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709178480; c=relaxed/simple; bh=fp3Mxq2ltzt6MMHBtz4FN6pPfnR8KvUSOwgEwxPR6nU=; h=Date:From:To:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition; b=j23maUC8dwDR5+shP19xqM1JmwrAoQs19CYy/aCljJHdbgFf+7GENfZ4qKMbDVMYlmJIsIRACvxt28+SRmao0+YupU3CkqXT/mUeF0opQS8sAClFkE37YNZLaIbMC3paIRMi6pETh0Ynn+VwE2TPAWoKBDqHjdE2ax2LVsodWTI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=makrotopia.org; spf=pass smtp.mailfrom=makrotopia.org; arc=none smtp.client-ip=185.142.180.65 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=makrotopia.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=makrotopia.org Received: from local by pidgin.makrotopia.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.96.2) (envelope-from <daniel@makrotopia.org>) id 1rfXOM-0006Wc-2B; Thu, 29 Feb 2024 03:47:30 +0000 Date: Thu, 29 Feb 2024 03:47:24 +0000 From: Daniel Golle <daniel@makrotopia.org> To: Richard Weinberger <richard@nod.at>, Zhihao Cheng <chengzhihao1@huawei.com>, Miquel Raynal <miquel.raynal@bootlin.com>, Vignesh Raghavendra <vigneshr@ti.com>, Daniel Golle <daniel@makrotopia.org>, linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v3] mtd: ubi: fix NVMEM over UBI volumes on 32-bit systems Message-ID: <ff29447dcee834c17e4e1e99725b9454c90136ca.1709178325.git.daniel@makrotopia.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792203546194868852 X-GMAIL-MSGID: 1792203546194868852 |
Series |
[v3] mtd: ubi: fix NVMEM over UBI volumes on 32-bit systems
|
|
Commit Message
Daniel Golle
Feb. 29, 2024, 3:47 a.m. UTC
A compiler warning related to sizeof(int) != 8 when calling do_div()
is triggered when building on 32-bit platforms.
Address this by using integer types having a well-defined size.
Fixes: 3ce485803da1 ("mtd: ubi: provide NVMEM layer over UBI volumes")
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
---
v3: use size_t also for 'to_read' variable to avoid truncation
(no problem in practise beyond the compiler warning)
v2: use size_t for 'bytes_left' variable to match parameter type
drivers/mtd/ubi/nvmem.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
Comments
在 2024/2/29 11:47, Daniel Golle 写道: > A compiler warning related to sizeof(int) != 8 when calling do_div() > is triggered when building on 32-bit platforms. > Address this by using integer types having a well-defined size. > > Fixes: 3ce485803da1 ("mtd: ubi: provide NVMEM layer over UBI volumes") > Signed-off-by: Daniel Golle <daniel@makrotopia.org> > --- > v3: use size_t also for 'to_read' variable to avoid truncation > (no problem in practise beyond the compiler warning) > v2: use size_t for 'bytes_left' variable to match parameter type > > drivers/mtd/ubi/nvmem.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com> > diff --git a/drivers/mtd/ubi/nvmem.c b/drivers/mtd/ubi/nvmem.c > index b7a93c495d172..8aeb9c428e510 100644 > --- a/drivers/mtd/ubi/nvmem.c > +++ b/drivers/mtd/ubi/nvmem.c > @@ -23,9 +23,12 @@ struct ubi_nvmem { > static int ubi_nvmem_reg_read(void *priv, unsigned int from, > void *val, size_t bytes) > { > - int err = 0, lnum = from, offs, bytes_left = bytes, to_read; > + size_t to_read, bytes_left = bytes; > struct ubi_nvmem *unv = priv; > struct ubi_volume_desc *desc; > + uint32_t offs; > + uint64_t lnum = from; > + int err = 0; > > desc = ubi_open_volume(unv->ubi_num, unv->vol_id, UBI_READONLY); > if (IS_ERR(desc)) >
On 2/28/24 19:47, Daniel Golle wrote: > A compiler warning related to sizeof(int) != 8 when calling do_div() > is triggered when building on 32-bit platforms. > Address this by using integer types having a well-defined size. > > Fixes: 3ce485803da1 ("mtd: ubi: provide NVMEM layer over UBI volumes") > Signed-off-by: Daniel Golle <daniel@makrotopia.org> > --- > v3: use size_t also for 'to_read' variable to avoid truncation > (no problem in practise beyond the compiler warning) > v2: use size_t for 'bytes_left' variable to match parameter type > > drivers/mtd/ubi/nvmem.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > Works for me. Thanks. Tested-by: Randy Dunlap <rdunlap@infradead.org>
diff --git a/drivers/mtd/ubi/nvmem.c b/drivers/mtd/ubi/nvmem.c index b7a93c495d172..8aeb9c428e510 100644 --- a/drivers/mtd/ubi/nvmem.c +++ b/drivers/mtd/ubi/nvmem.c @@ -23,9 +23,12 @@ struct ubi_nvmem { static int ubi_nvmem_reg_read(void *priv, unsigned int from, void *val, size_t bytes) { - int err = 0, lnum = from, offs, bytes_left = bytes, to_read; + size_t to_read, bytes_left = bytes; struct ubi_nvmem *unv = priv; struct ubi_volume_desc *desc; + uint32_t offs; + uint64_t lnum = from; + int err = 0; desc = ubi_open_volume(unv->ubi_num, unv->vol_id, UBI_READONLY); if (IS_ERR(desc))