From patchwork Thu Jun 2 08:11:51 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Satoru Takeuchi X-Patchwork-Id: 9149483 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id CD72960467 for ; Thu, 2 Jun 2016 08:12:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BE1D920120 for ; Thu, 2 Jun 2016 08:12:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B30A12654B; Thu, 2 Jun 2016 08:12:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4BED920120 for ; Thu, 2 Jun 2016 08:12:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932168AbcFBIMN (ORCPT ); Thu, 2 Jun 2016 04:12:13 -0400 Received: from mgwkm03.jp.fujitsu.com ([202.219.69.170]:34671 "EHLO mgwkm03.jp.fujitsu.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752954AbcFBIMD (ORCPT ); Thu, 2 Jun 2016 04:12:03 -0400 Received: from kw-mxq.gw.nic.fujitsu.com (unknown [192.168.231.130]) by mgwkm03.jp.fujitsu.com with smtp id 3b0c_0530_3a6d94f4_257a_41df_aca7_78f1617ea02f; Thu, 02 Jun 2016 17:11:57 +0900 Received: from m3050.s.css.fujitsu.com (msm.b.css.fujitsu.com [10.134.21.208]) by kw-mxq.gw.nic.fujitsu.com (Postfix) with ESMTP id A269FAC0287 for ; Thu, 2 Jun 2016 17:11:56 +0900 (JST) X-SecurityPolicyCheck: OK by SHieldMailChecker v2.4.6 X-SHieldMailCheckerPolicyVersion: FJ-ISEC-20160122 X-SHieldMailCheckerMailID: 3b8005827e594ba78a488533b0cde52c Subject: [PATCH 3/5] btrfs-progs: btrfs-crc: print usage on receiving invalid arguments To: "linux-btrfs@vger.kernel.org" References: <08faf8d3-0cc4-5164-b583-f69c8c3eb5bc@jp.fujitsu.com> From: Satoru Takeuchi Message-ID: Date: Thu, 2 Jun 2016 17:11:51 +0900 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.1.0 MIME-Version: 1.0 In-Reply-To: <08faf8d3-0cc4-5164-b583-f69c8c3eb5bc@jp.fujitsu.com> X-TM-AS-MML: disable Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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;