Re: [PATCH V2] filefrag: fix issues with 29758d2

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On May 29, 2014, at 11:40 AM, Eric Sandeen <sandeen@xxxxxxxxxx> 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.
> 
> Also fix a precedence problem with:
> 
> 	if (fe_flags & mask == 0)
> 
> which is equivalent to:
> 
> 	if (fe_flags & (mask == 0))
> 
> but we need:
> 
> 	if ((fe_flags & mask) == 0)

Strange.  I'm pretty sure I fixed this, because it was causing every
flag to be printed, but I guess I sent the wrong version or something.
Thanks for fixing this.

> diff --git a/misc/filefrag.c b/misc/filefrag.c
> index 37c4416..1d05f47 100644
> --- a/misc/filefrag.c
> +++ b/misc/filefrag.c
> @@ -175,7 +175,7 @@ static void print_extent_info(struct fiemap_extent *fm_extent, int cur_ex,
> 	for (mask = 1; fe_flags != 0 && mask != 0; mask <<= 1) {
> 		char hex[6];
> 
> -		if (fe_flags & mask == 0)
> +		if ((fe_flags & mask) == 0)
> 			continue;
> 		sprintf(hex, "%#04x,", mask);
> 		print_flag(&fe_flags, mask, flags, hex);
> @@ -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;

Would be better to move this above close(), instead of introducing
another case of the potential error you mentioned.

Cheers, Andreas

> 			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@xxxxxxxxxxxxxxx
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


Cheers, Andreas





Attachment: signature.asc
Description: Message signed with OpenPGP using GPGMail


[Index of Archives]     [Reiser Filesystem Development]     [Ceph FS]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite National Park]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]     [Linux Media]

  Powered by Linux