linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] gfs2: use helper macro abs()
@ 2020-10-19  6:43 Xianting Tian
  2020-10-19 13:45 ` Andreas Gruenbacher
  0 siblings, 1 reply; 2+ messages in thread
From: Xianting Tian @ 2020-10-19  6:43 UTC (permalink / raw)
  To: rpeterso, agruenba; +Cc: cluster-devel, linux-kernel, Xianting Tian

Use helper macro abs() to simplify the "x >= y || x <= -y" cmp.

Signed-off-by: Xianting Tian <tian.xianting@h3c.com>
---
 fs/gfs2/super.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/gfs2/super.c b/fs/gfs2/super.c
index 9f4d9e7be..05eb709de 100644
--- a/fs/gfs2/super.c
+++ b/fs/gfs2/super.c
@@ -304,7 +304,7 @@ void gfs2_statfs_change(struct gfs2_sbd *sdp, s64 total, s64 free,
 	if (sdp->sd_args.ar_statfs_percent) {
 		x = 100 * l_sc->sc_free;
 		y = m_sc->sc_free * sdp->sd_args.ar_statfs_percent;
-		if (x >= y || x <= -y)
+		if (abs(x) >= y)
 			need_sync = 1;
 	}
 	spin_unlock(&sdp->sd_statfs_spin);
-- 
2.17.1


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

* Re: [PATCH] gfs2: use helper macro abs()
  2020-10-19  6:43 [PATCH] gfs2: use helper macro abs() Xianting Tian
@ 2020-10-19 13:45 ` Andreas Gruenbacher
  0 siblings, 0 replies; 2+ messages in thread
From: Andreas Gruenbacher @ 2020-10-19 13:45 UTC (permalink / raw)
  To: Xianting Tian; +Cc: Bob Peterson, cluster-devel, LKML

Hi,

On Mon, Oct 19, 2020 at 10:03 AM Xianting Tian <tian.xianting@h3c.com> wrote:
> Use helper macro abs() to simplify the "x >= y || x <= -y" cmp.
>
> Signed-off-by: Xianting Tian <tian.xianting@h3c.com>
> ---
>  fs/gfs2/super.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/gfs2/super.c b/fs/gfs2/super.c
> index 9f4d9e7be..05eb709de 100644
> --- a/fs/gfs2/super.c
> +++ b/fs/gfs2/super.c
> @@ -304,7 +304,7 @@ void gfs2_statfs_change(struct gfs2_sbd *sdp, s64 total, s64 free,
>         if (sdp->sd_args.ar_statfs_percent) {
>                 x = 100 * l_sc->sc_free;
>                 y = m_sc->sc_free * sdp->sd_args.ar_statfs_percent;
> -               if (x >= y || x <= -y)
> +               if (abs(x) >= y)

x and y are signed values, so this really doesn't seem right.

>                         need_sync = 1;
>         }
>         spin_unlock(&sdp->sd_statfs_spin);
> --
> 2.17.1

Thanks,
Andreas


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

end of thread, other threads:[~2020-10-19 13:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-19  6:43 [PATCH] gfs2: use helper macro abs() Xianting Tian
2020-10-19 13:45 ` Andreas Gruenbacher

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).