linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] w1: w1_therm: use swap() to make code cleaner
@ 2021-12-18  1:58 davidcomponentone
  2021-12-18  9:54 ` Dan Carpenter
  0 siblings, 1 reply; 4+ messages in thread
From: davidcomponentone @ 2021-12-18  1:58 UTC (permalink / raw)
  To: zbr
  Cc: davidcomponentone, gregkh, yangyingliang, unixbhaskar,
	dan.carpenter, ivan.zaentsev, yang.guang5, linux-kernel,
	Zeal Robot

From: Yang Guang <yang.guang5@zte.com.cn>

Use the macro 'swap()' defined in 'include/linux/minmax.h' to avoid
opencoding it.

Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: David Yang <davidcomponentone@gmail.com>
Signed-off-by: Yang Guang <yang.guang5@zte.com.cn>
---
 drivers/w1/slaves/w1_therm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/w1/slaves/w1_therm.c b/drivers/w1/slaves/w1_therm.c
index ca70c5f03206..c743cb3d277a 100644
--- a/drivers/w1/slaves/w1_therm.c
+++ b/drivers/w1/slaves/w1_therm.c
@@ -1785,7 +1785,7 @@ static ssize_t alarms_store(struct device *device,
 	u8 new_config_register[3];	/* array of data to be written */
 	int temp, ret;
 	char *token = NULL;
-	s8 tl, th, tt;	/* 1 byte per value + temp ring order */
+	s8 tl, th;	/* 1 byte per value + temp ring order */
 	char *p_args, *orig;
 
 	p_args = orig = kmalloc(size, GFP_KERNEL);
@@ -1837,7 +1837,7 @@ static ssize_t alarms_store(struct device *device,
 
 	/* Reorder if required th and tl */
 	if (tl > th) {
-		tt = tl; tl = th; th = tt;
+		swap(tl, th);
 	}
 
 	/*
-- 
2.30.2


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

* Re: [PATCH] w1: w1_therm: use swap() to make code cleaner
  2021-12-18  1:58 [PATCH] w1: w1_therm: use swap() to make code cleaner davidcomponentone
@ 2021-12-18  9:54 ` Dan Carpenter
  0 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2021-12-18  9:54 UTC (permalink / raw)
  To: davidcomponentone
  Cc: zbr, gregkh, yangyingliang, unixbhaskar, ivan.zaentsev,
	yang.guang5, linux-kernel, Zeal Robot

On Sat, Dec 18, 2021 at 09:58:44AM +0800, davidcomponentone@gmail.com wrote:
> @@ -1837,7 +1837,7 @@ static ssize_t alarms_store(struct device *device,
>  
>  	/* Reorder if required th and tl */
>  	if (tl > th) {
> -		tt = tl; tl = th; th = tt;
> +		swap(tl, th);
>  	}

Delete the curly {} braces as well since they are no longer required.

regards,
dan carpenter


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

* Re: [PATCH] w1: w1_therm: use swap() to make code cleaner
  2021-11-04  1:11 davidcomponentone
@ 2021-11-04 11:09 ` Dan Carpenter
  0 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2021-11-04 11:09 UTC (permalink / raw)
  To: davidcomponentone
  Cc: zbr, gregkh, ivan.zaentsev, yangyingliang, unixbhaskar,
	yang.guang5, linux-kernel, Zeal Robot

On Thu, Nov 04, 2021 at 09:11:23AM +0800, davidcomponentone@gmail.com wrote:
> From: Yang Guang <yang.guang5@zte.com.cn>
> 
> Use the macro 'swap()' defined in 'include/linux/minmax.h' to avoid
> opencoding it.
> 
> Reported-by: Zeal Robot <zealci@zte.com.cn>
> Signed-off-by: Yang Guang <yang.guang5@zte.com.cn>
> ---

I'm confused by the signed-off-by list.  Are you Yang Guang and David is
your "English name"?  If so then this is fine, but if you are different
people then everyone who handles the patch needs to add their own
signed-off-by.


> @@ -1837,7 +1837,7 @@ static ssize_t alarms_store(struct device *device,
>  
>  	/* Reorder if required th and tl */
>  	if (tl > th) {
> -		tt = tl; tl = th; th = tt;
> +		swap(tl, th);
>  	}

Remove the curly {} braces as well because they are no longer required.

regards,
dan carpenter


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

* [PATCH] w1: w1_therm: use swap() to make code cleaner
@ 2021-11-04  1:11 davidcomponentone
  2021-11-04 11:09 ` Dan Carpenter
  0 siblings, 1 reply; 4+ messages in thread
From: davidcomponentone @ 2021-11-04  1:11 UTC (permalink / raw)
  To: zbr
  Cc: davidcomponentone, gregkh, ivan.zaentsev, yangyingliang,
	unixbhaskar, dan.carpenter, yang.guang5, linux-kernel,
	Zeal Robot

From: Yang Guang <yang.guang5@zte.com.cn>

Use the macro 'swap()' defined in 'include/linux/minmax.h' to avoid
opencoding it.

Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: Yang Guang <yang.guang5@zte.com.cn>
---
 drivers/w1/slaves/w1_therm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/w1/slaves/w1_therm.c b/drivers/w1/slaves/w1_therm.c
index ca70c5f03206..c743cb3d277a 100644
--- a/drivers/w1/slaves/w1_therm.c
+++ b/drivers/w1/slaves/w1_therm.c
@@ -1785,7 +1785,7 @@ static ssize_t alarms_store(struct device *device,
 	u8 new_config_register[3];	/* array of data to be written */
 	int temp, ret;
 	char *token = NULL;
-	s8 tl, th, tt;	/* 1 byte per value + temp ring order */
+	s8 tl, th;	/* 1 byte per value + temp ring order */
 	char *p_args, *orig;
 
 	p_args = orig = kmalloc(size, GFP_KERNEL);
@@ -1837,7 +1837,7 @@ static ssize_t alarms_store(struct device *device,
 
 	/* Reorder if required th and tl */
 	if (tl > th) {
-		tt = tl; tl = th; th = tt;
+		swap(tl, th);
 	}
 
 	/*
-- 
2.30.2


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

end of thread, other threads:[~2021-12-18  9:55 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-18  1:58 [PATCH] w1: w1_therm: use swap() to make code cleaner davidcomponentone
2021-12-18  9:54 ` Dan Carpenter
  -- strict thread matches above, loose matches on Subject: below --
2021-11-04  1:11 davidcomponentone
2021-11-04 11:09 ` Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).