Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 22 May 2021 19:26:03 GMT
From:      Robert Wing <rew@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 20123b25ee51 - main - fsck_ffs(8): fix divide by zero when debug messages are enabled
Message-ID:  <202105221926.14MJQ3bW087005@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by rew:

URL: https://cgit.FreeBSD.org/src/commit/?id=20123b25ee51e9b122676a30d45c21a506bf1461

commit 20123b25ee51e9b122676a30d45c21a506bf1461
Author:     Robert Wing <rew@FreeBSD.org>
AuthorDate: 2021-05-20 20:53:52 +0000
Commit:     Robert Wing <rew@FreeBSD.org>
CommitDate: 2021-05-22 19:03:36 +0000

    fsck_ffs(8): fix divide by zero when debug messages are enabled
    
    Only print buffer cache debug message when a cache lookup has been done.
    
    When running `fsck_ffs -d` on a gjournal'ed filesystem, it's possible
    that totalreads is greater than zero when no cache lookup has been
    done - causing a divide by zero. This commit fixes the following error:
    
        Floating point exception (core dumped)
    
    Reviewed by:    mckusick
    Differential Revision:  https://reviews.freebsd.org/D30370
---
 sbin/fsck_ffs/fsutil.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sbin/fsck_ffs/fsutil.c b/sbin/fsck_ffs/fsutil.c
index b13ba4c54bde..db22ee5b20cf 100644
--- a/sbin/fsck_ffs/fsutil.c
+++ b/sbin/fsck_ffs/fsutil.c
@@ -576,7 +576,7 @@ ckfini(int markclean)
 			rerun = 1;
 		}
 	}
-	if (debug && totalreads > 0)
+	if (debug && cachelookups > 0)
 		printf("cache with %d buffers missed %d of %d (%d%%)\n",
 		    numbufs, cachereads, cachelookups,
 		    (int)(cachereads * 100 / cachelookups));



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202105221926.14MJQ3bW087005>