From f686b1710a74b897ae8b2df6b360ff2ffb4def2d Mon Sep 17 00:00:00 2001 From: Kirk McKusick Date: Wed, 21 Feb 2018 19:56:19 +0000 Subject: [PATCH] Refactor fix in r329600 to do its check once in readsuper() rather than in the two places that call readsuper(). No semantic change intended. Reviewed by: kib --- sys/ufs/ffs/ffs_subr.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/sys/ufs/ffs/ffs_subr.c b/sys/ufs/ffs/ffs_subr.c index c478ec2e2c5f..cc529da412fc 100644 --- a/sys/ufs/ffs/ffs_subr.c +++ b/sys/ufs/ffs/ffs_subr.c @@ -174,17 +174,12 @@ ffs_sbget(void *devfd, struct fs **fsp, off_t altsuperblock, *fsp = NULL; if (altsuperblock != -1) { - ret = readsuper(devfd, fsp, altsuperblock, readfunc); - if (*fsp != NULL) - (*fsp)->fs_csp = NULL; - if (ret != 0) + if ((ret = readsuper(devfd, fsp, altsuperblock, readfunc)) != 0) return (ret); } else { for (i = 0; sblock_try[i] != -1; i++) { - ret = readsuper(devfd, fsp, sblock_try[i], readfunc); - if (*fsp != NULL) - (*fsp)->fs_csp = NULL; - if (ret == 0) + if ((ret = readsuper(devfd, fsp, sblock_try[i], + readfunc)) == 0) break; if (ret == ENOENT) continue; @@ -193,13 +188,11 @@ ffs_sbget(void *devfd, struct fs **fsp, off_t altsuperblock, if (sblock_try[i] == -1) return (ENOENT); } - /* - * Not filling in summary information, return. + * If not filling in summary information, return. */ if (filltype == NULL) return (0); - /* * Read in the superblock summary information. */ @@ -252,6 +245,8 @@ readsuper(void *devfd, struct fs **fsp, off_t sblockloc, int error; error = (*readfunc)(devfd, sblockloc, (void **)fsp, SBLOCKSIZE); + if (*fsp != NULL) + (*fsp)->fs_csp = NULL; /* Not yet any summary information */ if (error != 0) return (error); fs = *fsp;