btrfs-progs: defrag: fix threshold overflow again

Commit dedb1ebeee broke commit
96cfbbf0ea.

Casting thresh value greater than (u32)-1 simply truncates bits while
desired value is (u32)-1 for max defrag threshold.

I.e. "btrfs fi defrag -t 4g" is trimmed/truncated to 0
and "-t 5g" to 1073741824.

Also added a missing newline.

Signed-off-by: Patrik Lundquist <patrik.lundquist@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
Patrik Lundquist 2015-07-24 10:35:02 +02:00 committed by David Sterba
parent 8cb5ff857a
commit 44de34b14d

View file

@ -1172,8 +1172,9 @@ static int cmd_filesystem_defrag(int argc, char **argv)
thresh = parse_size(optarg);
if (thresh > (u32)-1) {
fprintf(stderr,
"WARNING: target extent size %llu too big, trimmed to %u",
"WARNING: target extent size %llu too big, trimmed to %u\n",
thresh, (u32)-1);
thresh = (u32)-1;
}
defrag_global_fancy_ioctl = 1;
break;