Message ID | 53876D7D.8050108@redhat.com |
---|---|
State | Superseded, archived |
Headers | show |
On 5/29/14, 12:25 PM, Eric Sandeen wrote: > 29758d2 filefrag: exit with error code if an error is hit > > introduced a couple errors; in one case it missed returning > a value, and in the other used a test where it needed an > assignment. > > Signed-off-by: Eric Sandeen <sandeen@redhat.com> > --- > > diff --git a/misc/filefrag.c b/misc/filefrag.c > index 37c4416..b2826ad 100644 > --- a/misc/filefrag.c > +++ b/misc/filefrag.c > @@ -387,8 +387,9 @@ static int frag_report(const char *filename) > if (last_device != st.st_dev) { > if (fstatfs(fd, &fsinfo) < 0) { > close(fd); > + rc = -errno; > perror("fstatfs"); > - return; > + return rc; > } And as an aside, here and other places where we do: if (syscall() < 0) { close (fd); rc = -errno; perror("syscall"); return rc; } we actually run the risk of close failing, and getting errno/perror from THAT, but *shrug* for now... -Eric > if (verbose) > printf("Filesystem type is: %lx\n", > @@ -556,7 +557,7 @@ int main(int argc, char**argv) > int rc2 = frag_report(*cpp); > > if (rc2 < 0 && rc == 0) > - rc == rc2; > + rc = rc2; > } > > return rc; > > -- > To unsubscribe from this list: send the line "unsubscribe linux-ext4" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > -- To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Thu, 29 May 2014, Eric Sandeen wrote: > Date: Thu, 29 May 2014 12:25:17 -0500 > From: Eric Sandeen <sandeen@redhat.com> > To: ext4 development <linux-ext4@vger.kernel.org> > Cc: Andreas Dilger <adilger@dilger.ca> > Subject: [PATCH] filefrag: fix minor issues with 29758d2 > > 29758d2 filefrag: exit with error code if an error is hit > > introduced a couple errors; in one case it missed returning > a value, and in the other used a test where it needed an > assignment. Looks good, although I wonder if we can just return -errno or goto out_close ? (same with fstat failure). Thanks! -Lukas > > Signed-off-by: Eric Sandeen <sandeen@redhat.com> > --- > > diff --git a/misc/filefrag.c b/misc/filefrag.c > index 37c4416..b2826ad 100644 > --- a/misc/filefrag.c > +++ b/misc/filefrag.c > @@ -387,8 +387,9 @@ static int frag_report(const char *filename) > if (last_device != st.st_dev) { > if (fstatfs(fd, &fsinfo) < 0) { > close(fd); > + rc = -errno; > perror("fstatfs"); > - return; > + return rc; > } > if (verbose) > printf("Filesystem type is: %lx\n", > @@ -556,7 +557,7 @@ int main(int argc, char**argv) > int rc2 = frag_report(*cpp); > > if (rc2 < 0 && rc == 0) > - rc == rc2; > + rc = rc2; > } > > return rc; > > -- > To unsubscribe from this list: send the line "unsubscribe linux-ext4" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > -- To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On 5/29/14, 12:34 PM, Lukáš Czerner wrote: > On Thu, 29 May 2014, Eric Sandeen wrote: > >> Date: Thu, 29 May 2014 12:25:17 -0500 >> From: Eric Sandeen <sandeen@redhat.com> >> To: ext4 development <linux-ext4@vger.kernel.org> >> Cc: Andreas Dilger <adilger@dilger.ca> >> Subject: [PATCH] filefrag: fix minor issues with 29758d2 >> >> 29758d2 filefrag: exit with error code if an error is hit >> >> introduced a couple errors; in one case it missed returning >> a value, and in the other used a test where it needed an >> assignment. > > Looks good, although I wonder if we can just return -errno or goto > out_close ? (same with fstat failure). Perhaps; I was just following the style of the error handling block before it, rather than refactoring w/ gotos and such. :) Going for the "small fix." -Eric > Thanks! > -Lukas > >> >> Signed-off-by: Eric Sandeen <sandeen@redhat.com> >> --- >> >> diff --git a/misc/filefrag.c b/misc/filefrag.c >> index 37c4416..b2826ad 100644 >> --- a/misc/filefrag.c >> +++ b/misc/filefrag.c >> @@ -387,8 +387,9 @@ static int frag_report(const char *filename) >> if (last_device != st.st_dev) { >> if (fstatfs(fd, &fsinfo) < 0) { >> close(fd); >> + rc = -errno; >> perror("fstatfs"); >> - return; >> + return rc; >> } >> if (verbose) >> printf("Filesystem type is: %lx\n", >> @@ -556,7 +557,7 @@ int main(int argc, char**argv) >> int rc2 = frag_report(*cpp); >> >> if (rc2 < 0 && rc == 0) >> - rc == rc2; >> + rc = rc2; >> } >> >> return rc; >> >> -- >> To unsubscribe from this list: send the line "unsubscribe linux-ext4" in >> the body of a message to majordomo@vger.kernel.org >> More majordomo info at http://vger.kernel.org/majordomo-info.html >> -- To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/misc/filefrag.c b/misc/filefrag.c index 37c4416..b2826ad 100644 --- a/misc/filefrag.c +++ b/misc/filefrag.c @@ -387,8 +387,9 @@ static int frag_report(const char *filename) if (last_device != st.st_dev) { if (fstatfs(fd, &fsinfo) < 0) { close(fd); + rc = -errno; perror("fstatfs"); - return; + return rc; } if (verbose) printf("Filesystem type is: %lx\n", @@ -556,7 +557,7 @@ int main(int argc, char**argv) int rc2 = frag_report(*cpp); if (rc2 < 0 && rc == 0) - rc == rc2; + rc = rc2; } return rc;
29758d2 filefrag: exit with error code if an error is hit introduced a couple errors; in one case it missed returning a value, and in the other used a test where it needed an assignment. Signed-off-by: Eric Sandeen <sandeen@redhat.com> --- -- To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html