From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtpout-03.galae.net (smtpout-03.galae.net [185.246.85.4]) (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 EB62427AC4C for ; Fri, 20 Feb 2026 14:38:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.85.4 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771598321; cv=none; b=crMyWEZq+9yoMfWSj/PNlubIveXan3R8X6dxuJjA18o6sgjk82L01zLfg+o0wbZFxwtjPZpJHc38aKbKY0DJ1B+Y+bReyAvik97nmfTyqOdroZhZyEl3eE719V7AHRPdmlNFfm8K9a4gu+J3bQLZ0txhK0hoXOYwJTC2/oPAup0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771598321; c=relaxed/simple; bh=ZQKZIuANss7mRdxhtQSOp+rsWdIqBBpVrgYTVUFdqlc=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=FSBmJ90oFJUKNPmZ0/4fSx528CyqI3izFvAa0NAt7r4/qKJw5IY5j7mTQHd11e2ihG0lWzuWVm/tBPfUd1KNBsfuQvxmL+sJ/3hpe3f2LnQvtFfQSWbItqWyop62Kqm8QqnL7w1NLI+0MH5K0ITxP0/t//8CBmqkbZEBq11AzJk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=lZOMGlXw; arc=none smtp.client-ip=185.246.85.4 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="lZOMGlXw" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id 3E2F94E408AC for ; Fri, 20 Feb 2026 14:38:36 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 0D2895FA8F; Fri, 20 Feb 2026 14:38:36 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 6076C102F19B0; Fri, 20 Feb 2026 15:38:32 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1771598315; h=from:subject:date:message-id:to:cc:mime-version:content-type: in-reply-to:references; bh=5N0Tr9nEeyaGCQQ1ZP7M9zIXF5VdXQNEcmOJxKptgNc=; b=lZOMGlXw/CXIUOZHqXdeFVLJ4H5+Mgmjxgcec9SLP4FGH7A7/P27dxhwFTxr14Wchikqjx L1CMT7hZJXbv6+qf9kHA3vx/A80D/8Tk18PM01/6uLZQ5irUP/pxRpbMQY+YifD5SKOobj YX6LTOgyDb6HwXdeV/1+a2pKNLJ4wwLI6J6G/ubJvsvhRAWDhJLKFrA+WHQ2/kKJKnnAKe IPV637cNu/AxC5jvEuD69nrzstOQlusfhEACPXSHz5OUIFwhoP1hemWgUOtr8LU+7QV3ln UVsSOwMq2g58hivMuaZJVag3vejx4Pqf/IgEiz/Z0/g3WCUU5PlgnHa9rTSsUg== Date: Fri, 20 Feb 2026 15:38:32 +0100 From: Alexandre Belloni To: "yanjun.zhu" Cc: Heiner Kallweit , Thomas =?iso-8859-1?Q?Wei=DFschuh?= , Greg Kroah-Hartman , "Rafael J. Wysocki" , Danilo Krummrich , Jason Gunthorpe , Leon Romanovsky , driver-core@lists.linux.dev, Linux Kernel Mailing List , linux-rdma@vger.kernel.org, linux-rtc@vger.kernel.org Subject: Re: [PATCH RFC 02/10] rtc: prepare for struct device member groups becoming a constant array Message-ID: <20260220143832ea0e1754@mail.local> References: <5d0951ec-42c9-453f-9966-ecca593c4153@kernel.org> <95e5af90-ed53-4009-a4ea-19ed04499ecc@kernel.org> <392127ee-11ad-4517-bb72-91af64fd191e@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <392127ee-11ad-4517-bb72-91af64fd191e@linux.dev> X-Last-TLS-Session-Version: TLSv1.3 On 18/02/2026 16:53:00-0800, yanjun.zhu wrote: > On 2/17/26 2:26 PM, Heiner Kallweit wrote: > > This prepares for making struct device member groups a constant array. > > The assignment groups = rtc->dev.groups would result in a "discarding > > const qualifier" warning with this change. > > No functional change intended. > > > > Signed-off-by: Heiner Kallweit > > --- > > drivers/rtc/sysfs.c | 8 ++++---- > > 1 file changed, 4 insertions(+), 4 deletions(-) > > > > diff --git a/drivers/rtc/sysfs.c b/drivers/rtc/sysfs.c > > index 4ab05e105a7..ae5e1252b4c 100644 > > --- a/drivers/rtc/sysfs.c > > +++ b/drivers/rtc/sysfs.c > > @@ -308,7 +308,7 @@ const struct attribute_group **rtc_get_dev_attribute_groups(void) > > int rtc_add_groups(struct rtc_device *rtc, const struct attribute_group **grps) > > { > > size_t old_cnt = 0, add_cnt = 0, new_cnt; > > - const struct attribute_group **groups, **old; > > + const struct attribute_group **groups, *const *old; > > if (grps) { > > for (groups = grps; *groups; groups++) > > @@ -320,9 +320,9 @@ int rtc_add_groups(struct rtc_device *rtc, const struct attribute_group **grps) > > return -EINVAL; > > } > > - groups = rtc->dev.groups; > > - if (groups) > > - for (; *groups; groups++) > > + old = rtc->dev.groups; > > + if (old) > > + while (*old++) > > old_cnt++; > > The change from for (; *groups; groups++) to while (*old++) is not > functionally equivalent. In the while version, the post-increment old++ > executes even when *old is NULL. This leaves the pointer old pointing one > element past the NULL terminator. While old_cnt remains correct, this is a > side-effect-heavy idiom that differs from standard kernel patterns and could > be fragile if old is used later in the function. > Thanks for pointing this out, I agree we should keep the original for loop. With that change, Acked-by: Alexandre Belloni > Best Regards, > Zhu Yanjun > > > new_cnt = old_cnt + add_cnt + 1; > -- Alexandre Belloni, co-owner and COO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com