* [PATCH] staging: fieldbus: remove unnecessary double negation
@ 2022-04-25 14:54 Ian Cowan
2022-04-25 15:47 ` Greg Kroah-Hartman
0 siblings, 1 reply; 3+ messages in thread
From: Ian Cowan @ 2022-04-25 14:54 UTC (permalink / raw)
To: Sven Van Asbroeck
Cc: Greg Kroah-Hartman, linux-staging, linux-kernel, Ian Cowan
Remove the double negation (!!) from the code since this does nothing
and may create confusion on whether or not those values are negated.
Signed-off-by: Ian Cowan <ian@linux.cowan.aero>
---
drivers/staging/fieldbus/dev_core.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/staging/fieldbus/dev_core.c b/drivers/staging/fieldbus/dev_core.c
index 5aab734606ea..6766b2b13482 100644
--- a/drivers/staging/fieldbus/dev_core.c
+++ b/drivers/staging/fieldbus/dev_core.c
@@ -28,7 +28,7 @@ static ssize_t online_show(struct device *dev, struct device_attribute *attr,
{
struct fieldbus_dev *fb = dev_get_drvdata(dev);
- return sprintf(buf, "%d\n", !!fb->online);
+ return sprintf(buf, "%d\n", fb->online);
}
static DEVICE_ATTR_RO(online);
@@ -39,7 +39,7 @@ static ssize_t enabled_show(struct device *dev, struct device_attribute *attr,
if (!fb->enable_get)
return -EINVAL;
- return sprintf(buf, "%d\n", !!fb->enable_get(fb));
+ return sprintf(buf, "%d\n", fb->enable_get(fb));
}
static ssize_t enabled_store(struct device *dev, struct device_attribute *attr,
--
2.35.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] staging: fieldbus: remove unnecessary double negation
2022-04-25 14:54 [PATCH] staging: fieldbus: remove unnecessary double negation Ian Cowan
@ 2022-04-25 15:47 ` Greg Kroah-Hartman
2022-04-25 22:26 ` Ian Cowan
0 siblings, 1 reply; 3+ messages in thread
From: Greg Kroah-Hartman @ 2022-04-25 15:47 UTC (permalink / raw)
To: Ian Cowan; +Cc: Sven Van Asbroeck, linux-staging, linux-kernel
On Mon, Apr 25, 2022 at 10:54:40AM -0400, Ian Cowan wrote:
> Remove the double negation (!!) from the code since this does nothing
> and may create confusion on whether or not those values are negated.
>
> Signed-off-by: Ian Cowan <ian@linux.cowan.aero>
> ---
> drivers/staging/fieldbus/dev_core.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/staging/fieldbus/dev_core.c b/drivers/staging/fieldbus/dev_core.c
> index 5aab734606ea..6766b2b13482 100644
> --- a/drivers/staging/fieldbus/dev_core.c
> +++ b/drivers/staging/fieldbus/dev_core.c
> @@ -28,7 +28,7 @@ static ssize_t online_show(struct device *dev, struct device_attribute *attr,
> {
> struct fieldbus_dev *fb = dev_get_drvdata(dev);
>
> - return sprintf(buf, "%d\n", !!fb->online);
> + return sprintf(buf, "%d\n", fb->online);
> }
> static DEVICE_ATTR_RO(online);
>
> @@ -39,7 +39,7 @@ static ssize_t enabled_show(struct device *dev, struct device_attribute *attr,
>
> if (!fb->enable_get)
> return -EINVAL;
> - return sprintf(buf, "%d\n", !!fb->enable_get(fb));
> + return sprintf(buf, "%d\n", fb->enable_get(fb));
This is a common pattern to turn any value into a boolean (0/1). The
fact that this is a boolean to start with makes this change not affect
anything. So you should say that in the changelog, the values are
obviously not negated.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] staging: fieldbus: remove unnecessary double negation
2022-04-25 15:47 ` Greg Kroah-Hartman
@ 2022-04-25 22:26 ` Ian Cowan
0 siblings, 0 replies; 3+ messages in thread
From: Ian Cowan @ 2022-04-25 22:26 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: Sven Van Asbroeck, linux-staging, linux-kernel
On Mon, Apr 25, 2022 at 05:47:35PM +0200, Greg Kroah-Hartman wrote:
> This is a common pattern to turn any value into a boolean (0/1). The
> fact that this is a boolean to start with makes this change not affect
> anything. So you should say that in the changelog, the values are
> obviously not negated.
>
I just resubmitted with that change.
Thanks!
Ian
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-04-25 22:26 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-25 14:54 [PATCH] staging: fieldbus: remove unnecessary double negation Ian Cowan
2022-04-25 15:47 ` Greg Kroah-Hartman
2022-04-25 22:26 ` Ian Cowan
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.