Skip to contentSkip to conversation

gfs2: use helper macro abs()

PATCH In review Xianting Tian 2 participants 2 messages Oct 19, 2020 GFS2 file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gfs2: use helper macro abs()

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

---
 fs/gfs2/super.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/gfs2/super.c +1 -1
index 9f4d9e7be..05eb709de 100644
@@ -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);
Signature · 1 line
2.17.1
#1 lore raw

Hi,

Quoted 12 lines · Xianting Tian

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

---
 fs/gfs2/super.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/gfs2/super.c +0 -0
index 9f4d9e7be..05eb709de 100644

fs/gfs2/super.c void gfs2_statfs_change(struct gfs2_sbd *sdp, s64 total, s64 free, · line 307

Quoted 5 lines
fs/gfs2/super.c +1 -1
@@ -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.

Quoted 5 lines
fs/gfs2/super.c +0 -1
                        need_sync = 1;
        }
        spin_unlock(&sdp->sd_statfs_spin);
--

2.17.1

Thanks,
Andreas