Discovered with cppcheck. Fix signed/unsigned int mismatches, sizeof and
long formats.
Pull-request: #197
Signed-off-by: Rosen Penev <rosenp@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
The error message about the unsatisfied argument count is scrolled away
by the full usage string dump. This is not considered a good usability
practice.
This commit switches all direct usage -> return patterns, where the
argument check has no other constraint, eg. dependency on an option.
Signed-off-by: David Sterba <dsterba@suse.com>
- If -c is set, filename argument is ignored.
- Describe about -h option
Signed-off-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Usage is only printed if -h option is set. However it's nice to
do it when wrong option is set or the number of argument is wrong.
Signed-off-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Remove the following build error.
====================================
$ make btrfs-crc
[CC] btrfs-crc.o
[LD] btrfs-crc
btrfs-crc.o: In function `usage':
/home/sat/src/btrfs-progs/btrfs-crc.c:26: multiple definition of `usage'
help.o:/home/sat/src/btrfs-progs/help.c:125: first defined here
collect2: error: ld returned 1 exit status
Makefile:294: recipe for target 'btrfs-crc' failed
make: *** [btrfs-crc] Error 1
=====================================
Signed-off-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Replace old and not so informal srand()/rand() calls to new random
number API.
Including btrfs-corrupt-block(main user), btrfs-image and btrfs-crc.
Some tests like dir-test/random-test/quick-test is not modified.
As random-test itself can't even pass build.
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Since this patch:
btrfs-progs: move the check_argc_* functions into utils.c
All tools including the independent tools(e.g. btrfs-image, btrfs-convert)
can share the convenience of the check_argc_* functions, so this patch
adopt the argc check functions globally.
Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
(same as commit bb0eabc383)
There, 'char' is unsigned, so once assigned '-1' from getopt, it gets
the value 255. Then, it compared to '-1' gives false.
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
This tool can be used to compute btrfs' style crc32c checksums for filenames
as done by the kernel. Additionally, there is -c mode to do a brute force
search for file names with a given checksum.
Signed-off-by: Jan Schmidt <list.btrfs@jan-o-sch.net>