public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1 1/1] s390/cio: Use while (i--) pattern to clean up
@ 2024-02-22 13:45 Andy Shevchenko
  2024-03-04 14:43 ` Andy Shevchenko
  2024-03-13 14:57 ` Vineeth Vijayan
  0 siblings, 2 replies; 6+ messages in thread
From: Andy Shevchenko @ 2024-02-22 13:45 UTC (permalink / raw)
  To: linux-s390, linux-kernel
  Cc: Vineeth Vijayan, Peter Oberparleiter, Heiko Carstens,
	Vasily Gorbik, Alexander Gordeev, Christian Borntraeger,
	Sven Schnelle, Andy Shevchenko

Use more natural while (i--) patter to clean up allocated resources.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/s390/cio/ccwgroup.c | 4 ++--
 drivers/s390/cio/chsc.c     | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/s390/cio/ccwgroup.c b/drivers/s390/cio/ccwgroup.c
index 6eb8bcd948dc..b72f672a7720 100644
--- a/drivers/s390/cio/ccwgroup.c
+++ b/drivers/s390/cio/ccwgroup.c
@@ -240,7 +240,7 @@ static int __ccwgroup_create_symlinks(struct ccwgroup_device *gdev)
 		rc = sysfs_create_link(&gdev->cdev[i]->dev.kobj,
 				       &gdev->dev.kobj, "group_device");
 		if (rc) {
-			for (--i; i >= 0; i--)
+			while (i--)
 				sysfs_remove_link(&gdev->cdev[i]->dev.kobj,
 						  "group_device");
 			return rc;
@@ -251,7 +251,7 @@ static int __ccwgroup_create_symlinks(struct ccwgroup_device *gdev)
 		rc = sysfs_create_link(&gdev->dev.kobj,
 				       &gdev->cdev[i]->dev.kobj, str);
 		if (rc) {
-			for (--i; i >= 0; i--) {
+			while (i--) {
 				sprintf(str, "cdev%d", i);
 				sysfs_remove_link(&gdev->dev.kobj, str);
 			}
diff --git a/drivers/s390/cio/chsc.c b/drivers/s390/cio/chsc.c
index 3d88899dff7c..8714aa312724 100644
--- a/drivers/s390/cio/chsc.c
+++ b/drivers/s390/cio/chsc.c
@@ -844,7 +844,7 @@ chsc_add_cmg_attr(struct channel_subsystem *css)
 	}
 	return ret;
 cleanup:
-	for (--i; i >= 0; i--) {
+	while (i--) {
 		if (!css->chps[i])
 			continue;
 		chp_remove_cmg_attr(css->chps[i]);
-- 
2.43.0.rc1.1.gbec44491f096


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v1 1/1] s390/cio: Use while (i--) pattern to clean up
  2024-02-22 13:45 [PATCH v1 1/1] s390/cio: Use while (i--) pattern to clean up Andy Shevchenko
@ 2024-03-04 14:43 ` Andy Shevchenko
  2024-03-07 13:54   ` Heiko Carstens
  2024-03-13 14:57 ` Vineeth Vijayan
  1 sibling, 1 reply; 6+ messages in thread
From: Andy Shevchenko @ 2024-03-04 14:43 UTC (permalink / raw)
  To: linux-s390, linux-kernel
  Cc: Vineeth Vijayan, Peter Oberparleiter, Heiko Carstens,
	Vasily Gorbik, Alexander Gordeev, Christian Borntraeger,
	Sven Schnelle

On Thu, Feb 22, 2024 at 03:45:01PM +0200, Andy Shevchenko wrote:
> Use more natural while (i--) patter to clean up allocated resources.

Any comments?

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v1 1/1] s390/cio: Use while (i--) pattern to clean up
  2024-03-04 14:43 ` Andy Shevchenko
@ 2024-03-07 13:54   ` Heiko Carstens
  2024-03-07 13:58     ` Andy Shevchenko
  0 siblings, 1 reply; 6+ messages in thread
From: Heiko Carstens @ 2024-03-07 13:54 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: linux-s390, linux-kernel, Vineeth Vijayan, Peter Oberparleiter,
	Vasily Gorbik, Alexander Gordeev, Christian Borntraeger,
	Sven Schnelle

On Mon, Mar 04, 2024 at 04:43:18PM +0200, Andy Shevchenko wrote:
> On Thu, Feb 22, 2024 at 03:45:01PM +0200, Andy Shevchenko wrote:
> > Use more natural while (i--) patter to clean up allocated resources.
> 
> Any comments?

It is up to Vineeth and Peter to decide what to do with this.

But in general I'm not a fan of such patches. It depends on what people
prefer, and you can send literally thousands of similar patches where the
code looks "more natural" afterwards.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v1 1/1] s390/cio: Use while (i--) pattern to clean up
  2024-03-07 13:54   ` Heiko Carstens
@ 2024-03-07 13:58     ` Andy Shevchenko
  0 siblings, 0 replies; 6+ messages in thread
From: Andy Shevchenko @ 2024-03-07 13:58 UTC (permalink / raw)
  To: Heiko Carstens
  Cc: linux-s390, linux-kernel, Vineeth Vijayan, Peter Oberparleiter,
	Vasily Gorbik, Alexander Gordeev, Christian Borntraeger,
	Sven Schnelle

On Thu, Mar 07, 2024 at 02:54:42PM +0100, Heiko Carstens wrote:
> On Mon, Mar 04, 2024 at 04:43:18PM +0200, Andy Shevchenko wrote:
> > On Thu, Feb 22, 2024 at 03:45:01PM +0200, Andy Shevchenko wrote:
> > > Use more natural while (i--) patter to clean up allocated resources.
> > 
> > Any comments?
> 
> It is up to Vineeth and Peter to decide what to do with this.
> 
> But in general I'm not a fan of such patches. It depends on what people
> prefer, and you can send literally thousands of similar patches where the
> code looks "more natural" afterwards.

I understand your point, however, the lesser characters to parse, the better
readability is (usually). At least the proposed pattern is mainly used in
the kernel (you may grep for different patterns). It also has an educational
effect in case somebody takes this code as an example (for whatever reason).
With this we will show that *in practice* kernel prefers this style over
others.

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v1 1/1] s390/cio: Use while (i--) pattern to clean up
  2024-02-22 13:45 [PATCH v1 1/1] s390/cio: Use while (i--) pattern to clean up Andy Shevchenko
  2024-03-04 14:43 ` Andy Shevchenko
@ 2024-03-13 14:57 ` Vineeth Vijayan
  2024-03-13 15:24   ` Heiko Carstens
  1 sibling, 1 reply; 6+ messages in thread
From: Vineeth Vijayan @ 2024-03-13 14:57 UTC (permalink / raw)
  To: Andy Shevchenko, linux-s390, linux-kernel
  Cc: Peter Oberparleiter, Heiko Carstens, Vasily Gorbik,
	Alexander Gordeev, Christian Borntraeger, Sven Schnelle



On 2/22/24 14:45, Andy Shevchenko wrote:
> Use more natural while (i--) patter 

typo: pattern

to clean up allocated resources.
> 
> Signed-off-by: Andy Shevchenko<andriy.shevchenko@linux.intel.com>
> ---
>   drivers/s390/cio/ccwgroup.c | 4 ++--
>   drivers/s390/cio/chsc.c     | 2 +-
>   2 files changed, 3 insertions(+), 3 deletions(-)

Otherwise, looks sane to me.
Acked-by: Vineeth Vijayan <vneethv@linux.ibm.com>

Sorry for taking a while to get back to this.The patch ended up getting
lost in the shuffle after my vacation.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v1 1/1] s390/cio: Use while (i--) pattern to clean up
  2024-03-13 14:57 ` Vineeth Vijayan
@ 2024-03-13 15:24   ` Heiko Carstens
  0 siblings, 0 replies; 6+ messages in thread
From: Heiko Carstens @ 2024-03-13 15:24 UTC (permalink / raw)
  To: Vineeth Vijayan
  Cc: Andy Shevchenko, linux-s390, linux-kernel, Peter Oberparleiter,
	Vasily Gorbik, Alexander Gordeev, Christian Borntraeger,
	Sven Schnelle

On Wed, Mar 13, 2024 at 03:57:53PM +0100, Vineeth Vijayan wrote:
> 
> 
> On 2/22/24 14:45, Andy Shevchenko wrote:
> > Use more natural while (i--) patter
> 
> typo: pattern
> 
> to clean up allocated resources.
> > 
> > Signed-off-by: Andy Shevchenko<andriy.shevchenko@linux.intel.com>
> > ---
> >   drivers/s390/cio/ccwgroup.c | 4 ++--
> >   drivers/s390/cio/chsc.c     | 2 +-
> >   2 files changed, 3 insertions(+), 3 deletions(-)
> 
> Otherwise, looks sane to me.
> Acked-by: Vineeth Vijayan <vneethv@linux.ibm.com>

Applied with typo fixed, thanks!

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-03-13 15:24 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-22 13:45 [PATCH v1 1/1] s390/cio: Use while (i--) pattern to clean up Andy Shevchenko
2024-03-04 14:43 ` Andy Shevchenko
2024-03-07 13:54   ` Heiko Carstens
2024-03-07 13:58     ` Andy Shevchenko
2024-03-13 14:57 ` Vineeth Vijayan
2024-03-13 15:24   ` Heiko Carstens

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox