All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/5] btrfs-progs: btrfs-crc: fix build error
@ 2016-06-02  8:06 Satoru Takeuchi
  2016-06-02  8:10 ` [PATCH 2/5] btrfs-progs: btrfs-crc should be ignored by git Satoru Takeuchi
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Satoru Takeuchi @ 2016-06-02  8:06 UTC (permalink / raw)
  To: linux-btrfs

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>
---
  btrfs-crc.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/btrfs-crc.c b/btrfs-crc.c
index 723e0b7..86dfe05 100644
--- a/btrfs-crc.c
+++ b/btrfs-crc.c
@@ -22,7 +22,7 @@
  #include "crc32c.h"
  #include "utils.h"

-void usage(void)
+void print_usage(void)
  {
  	printf("usage: btrfs-crc filename\n");
  	printf("    print out the btrfs crc for \"filename\"\n");
@@ -57,7 +57,7 @@ int main(int argc, char **argv)
  			seed = atol(optarg);
  			break;
  		case 'h':
-			usage();
+			print_usage();
  		case '?':
  			return 255;
  		}
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/5] btrfs-progs: btrfs-crc should be ignored by git
  2016-06-02  8:06 [PATCH 1/5] btrfs-progs: btrfs-crc: fix build error Satoru Takeuchi
@ 2016-06-02  8:10 ` Satoru Takeuchi
  2016-06-02  8:11 ` [PATCH 3/5] btrfs-progs: btrfs-crc: print usage on receiving invalid arguments Satoru Takeuchi
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Satoru Takeuchi @ 2016-06-02  8:10 UTC (permalink / raw)
  To: linux-btrfs

It's a binary built from btrfs-crc.c

Signed-off-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
---
  .gitignore | 1 +
  1 file changed, 1 insertion(+)

diff --git a/.gitignore b/.gitignore
index a27cb0d..aaf9702 100644
--- a/.gitignore
+++ b/.gitignore
@@ -33,6 +33,7 @@ btrfs-zero-log
  btrfs-corrupt-block
  btrfs-select-super
  btrfs-calc-size
+btrfs-crc
  btrfstune
  libbtrfs.a
  libbtrfs.so
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/5] btrfs-progs: btrfs-crc: print usage on receiving invalid arguments
  2016-06-02  8:06 [PATCH 1/5] btrfs-progs: btrfs-crc: fix build error Satoru Takeuchi
  2016-06-02  8:10 ` [PATCH 2/5] btrfs-progs: btrfs-crc should be ignored by git Satoru Takeuchi
@ 2016-06-02  8:11 ` Satoru Takeuchi
  2016-06-02  8:13 ` [PATCH 4/5] btrfs-progs: btrfs-crc: improve usage message Satoru Takeuchi
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Satoru Takeuchi @ 2016-06-02  8:11 UTC (permalink / raw)
  To: linux-btrfs

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>
---
  btrfs-crc.c | 10 +++++-----
  1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/btrfs-crc.c b/btrfs-crc.c
index 86dfe05..55a4c61 100644
--- a/btrfs-crc.c
+++ b/btrfs-crc.c
@@ -22,7 +22,7 @@
  #include "crc32c.h"
  #include "utils.h"

-void print_usage(void)
+void print_usage(int status)
  {
  	printf("usage: btrfs-crc filename\n");
  	printf("    print out the btrfs crc for \"filename\"\n");
@@ -30,7 +30,7 @@ void print_usage(void)
  	printf("    brute force search for file names with the given crc\n");
  	printf("      -s seed    the random seed (default: random)\n");
  	printf("      -l length  the length of the file names (default: 10)\n");
-	exit(1);
+	exit(status);
  }

  int main(int argc, char **argv)
@@ -57,9 +57,9 @@ int main(int argc, char **argv)
  			seed = atol(optarg);
  			break;
  		case 'h':
-			print_usage();
+			print_usage(1);
  		case '?':
-			return 255;
+			print_usage(255);
  		}
  	}

@@ -68,7 +68,7 @@ int main(int argc, char **argv)

  	if (!loop) {
  		if (check_argc_min(argc - optind, 1))
-			return 255;
+			print_usage(255);

  		printf("%12u - %s\n", crc32c(~1, str, strlen(str)), str);
  		return 0;
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 4/5] btrfs-progs: btrfs-crc: improve usage message
  2016-06-02  8:06 [PATCH 1/5] btrfs-progs: btrfs-crc: fix build error Satoru Takeuchi
  2016-06-02  8:10 ` [PATCH 2/5] btrfs-progs: btrfs-crc should be ignored by git Satoru Takeuchi
  2016-06-02  8:11 ` [PATCH 3/5] btrfs-progs: btrfs-crc: print usage on receiving invalid arguments Satoru Takeuchi
@ 2016-06-02  8:13 ` Satoru Takeuchi
  2016-06-02  8:14 ` [PATCH 5/5] btrfs-progs: btrfs-crc: make argc check more strict Satoru Takeuchi
  2016-06-03 13:21 ` [PATCH 1/5] btrfs-progs: btrfs-crc: fix build error David Sterba
  4 siblings, 0 replies; 6+ messages in thread
From: Satoru Takeuchi @ 2016-06-02  8:13 UTC (permalink / raw)
  To: linux-btrfs

- If -c is set, filename argument is ignored.
- Describe about -h option

Signed-off-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
---
  btrfs-crc.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/btrfs-crc.c b/btrfs-crc.c
index 55a4c61..c2b5f00 100644
--- a/btrfs-crc.c
+++ b/btrfs-crc.c
@@ -26,10 +26,12 @@ void print_usage(int status)
  {
  	printf("usage: btrfs-crc filename\n");
  	printf("    print out the btrfs crc for \"filename\"\n");
-	printf("usage: btrfs-crc filename -c crc [-s seed] [-l length]\n");
+	printf("usage: btrfs-crc -c crc [-s seed] [-l length]\n");
  	printf("    brute force search for file names with the given crc\n");
  	printf("      -s seed    the random seed (default: random)\n");
  	printf("      -l length  the length of the file names (default: 10)\n");
+	printf("usage: btrfs-crc -h\n");
+	printf("    print this message\n");
  	exit(status);
  }

-- 
2.5.5

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 5/5] btrfs-progs: btrfs-crc: make argc check more strict
  2016-06-02  8:06 [PATCH 1/5] btrfs-progs: btrfs-crc: fix build error Satoru Takeuchi
                   ` (2 preceding siblings ...)
  2016-06-02  8:13 ` [PATCH 4/5] btrfs-progs: btrfs-crc: improve usage message Satoru Takeuchi
@ 2016-06-02  8:14 ` Satoru Takeuchi
  2016-06-03 13:21 ` [PATCH 1/5] btrfs-progs: btrfs-crc: fix build error David Sterba
  4 siblings, 0 replies; 6+ messages in thread
From: Satoru Takeuchi @ 2016-06-02  8:14 UTC (permalink / raw)
  To: linux-btrfs

Signed-off-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
---
  btrfs-crc.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/btrfs-crc.c b/btrfs-crc.c
index c2b5f00..d433ff3 100644
--- a/btrfs-crc.c
+++ b/btrfs-crc.c
@@ -69,12 +69,14 @@ int main(int argc, char **argv)
  	str = argv[optind];

  	if (!loop) {
-		if (check_argc_min(argc - optind, 1))
+		if (check_argc_exact(argc - optind, 1))
  			print_usage(255);

  		printf("%12u - %s\n", crc32c(~1, str, strlen(str)), str);
  		return 0;
  	}
+	if (check_argc_exact(argc - optind, 0))
+		print_usage(255);

  	buf = malloc(length);
  	if (!buf)
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/5] btrfs-progs: btrfs-crc: fix build error
  2016-06-02  8:06 [PATCH 1/5] btrfs-progs: btrfs-crc: fix build error Satoru Takeuchi
                   ` (3 preceding siblings ...)
  2016-06-02  8:14 ` [PATCH 5/5] btrfs-progs: btrfs-crc: make argc check more strict Satoru Takeuchi
@ 2016-06-03 13:21 ` David Sterba
  4 siblings, 0 replies; 6+ messages in thread
From: David Sterba @ 2016-06-03 13:21 UTC (permalink / raw)
  To: Satoru Takeuchi; +Cc: linux-btrfs

On Thu, Jun 02, 2016 at 05:06:37PM +0900, Satoru Takeuchi wrote:
> 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>

1-5 applied, thanks.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-06-03 13:22 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-02  8:06 [PATCH 1/5] btrfs-progs: btrfs-crc: fix build error Satoru Takeuchi
2016-06-02  8:10 ` [PATCH 2/5] btrfs-progs: btrfs-crc should be ignored by git Satoru Takeuchi
2016-06-02  8:11 ` [PATCH 3/5] btrfs-progs: btrfs-crc: print usage on receiving invalid arguments Satoru Takeuchi
2016-06-02  8:13 ` [PATCH 4/5] btrfs-progs: btrfs-crc: improve usage message Satoru Takeuchi
2016-06-02  8:14 ` [PATCH 5/5] btrfs-progs: btrfs-crc: make argc check more strict Satoru Takeuchi
2016-06-03 13:21 ` [PATCH 1/5] btrfs-progs: btrfs-crc: fix build error David Sterba

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.