From patchwork Wed Sep 4 15:22:23 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wang Shilong X-Patchwork-Id: 2853747 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id EF4D29F485 for ; Wed, 4 Sep 2013 15:23:05 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B1002204CF for ; Wed, 4 Sep 2013 15:23:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 85DC8204CB for ; Wed, 4 Sep 2013 15:23:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1762883Ab3IDPXA (ORCPT ); Wed, 4 Sep 2013 11:23:00 -0400 Received: from mail-pa0-f48.google.com ([209.85.220.48]:36482 "EHLO mail-pa0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756525Ab3IDPW7 (ORCPT ); Wed, 4 Sep 2013 11:22:59 -0400 Received: by mail-pa0-f48.google.com with SMTP id kp13so574261pab.35 for ; Wed, 04 Sep 2013 08:22:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=yQ6ldFPwhQlBazoyDUFSVNGf0IEUk1eu4wi3ghjmwj0=; b=y8MnO9oyAjIhCbVgw9frcbuwJV9AKqDlWJk/9FxDYiyzmLlQIia0+o+Ns6cVhBS8b9 d+pMuz8eCbYx0Z8xnAZc7/W4RI2lNhhokzCnD6mdEZuwynamTQH5AxXeUVGlEWhEF3Nr pKDiZI+I1vgAWVvUfZg6y310eVouAyIcgECSL9Z5GEEaENCUejWbMiKvesa+B4t5KJiA 5wqxMmDBqWHLiwEdgLNAdtAdct84kypUQUC7utLPd6b7/aSxqOxwm049L7/+5kLXc3R5 VdWtrhjdjNUxBHM4OQwJKb1vg+GTd5A91UL41pP0tQ5e9ZvzOKSRgZQkY6jgiA5lTUxF hHQA== X-Received: by 10.66.255.104 with SMTP id ap8mr3960742pad.53.1378308179283; Wed, 04 Sep 2013 08:22:59 -0700 (PDT) Received: from localhost.localdomain.localdomain ([223.65.191.73]) by mx.google.com with ESMTPSA id uw6sm29467271pbc.8.1969.12.31.16.00.00 (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 04 Sep 2013 08:22:58 -0700 (PDT) From: Wang Shilong To: linux-btrfs@vger.kernel.org Cc: dsterba@suse.cz, sandeen@redhat.com Subject: [PATCH 06/20] Btrfs-progs: fix magic return value in cmds-filesystem.c Date: Wed, 4 Sep 2013 23:22:23 +0800 Message-Id: <1378308157-4621-7-git-send-email-wangshilong1991@gmail.com> X-Mailer: git-send-email 1.7.11.7 In-Reply-To: <1378308157-4621-1-git-send-email-wangshilong1991@gmail.com> References: <1378308157-4621-1-git-send-email-wangshilong1991@gmail.com> Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-9.2 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Wang Shilong Signed-off-by: Wang Shilong --- cmds-filesystem.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/cmds-filesystem.c b/cmds-filesystem.c index ca0855b..815d59a 100644 --- a/cmds-filesystem.c +++ b/cmds-filesystem.c @@ -62,12 +62,14 @@ static int cmd_df(int argc, char **argv) fd = open_file_or_dir(path, &dirstream); if (fd < 0) { fprintf(stderr, "ERROR: can't access to '%s'\n", path); - return 12; + return 1; } sargs_orig = sargs = malloc(sizeof(struct btrfs_ioctl_space_args)); - if (!sargs) - return -ENOMEM; + if (!sargs) { + ret = -ENOMEM; + goto out; + } sargs->space_slots = 0; sargs->total_spaces = 0; @@ -157,7 +159,7 @@ out: close_file_or_dir(fd, dirstream); free(sargs); - return 0; + return !!ret; } static int uuid_search(struct btrfs_fs_devices *fs_devices, char *search) @@ -248,7 +250,7 @@ static int cmd_show(int argc, char **argv) if (ret){ fprintf(stderr, "ERROR: error %d while scanning\n", ret); - return 18; + return 1; } if(searchstart < argc) @@ -286,7 +288,7 @@ static int cmd_sync(int argc, char **argv) fd = open_file_or_dir(path, &dirstream); if (fd < 0) { fprintf(stderr, "ERROR: can't access to '%s'\n", path); - return 12; + return 1; } printf("FSSync '%s'\n", path); @@ -296,7 +298,7 @@ static int cmd_sync(int argc, char **argv) if( res < 0 ){ fprintf(stderr, "ERROR: unable to fs-syncing '%s' - %s\n", path, strerror(e)); - return 16; + return 1; } return 0; @@ -429,12 +431,10 @@ static int cmd_defrag(int argc, char **argv) } if (verbose) printf("%s\n", BTRFS_BUILD_VERSION); - if (errors) { + if (errors) fprintf(stderr, "total %d failures\n", errors); - exit(1); - } - return errors; + return !!errors; } static const char * const cmd_resize_usage[] = { @@ -462,13 +462,13 @@ static int cmd_resize(int argc, char **argv) if (len == 0 || len >= BTRFS_VOL_NAME_MAX) { fprintf(stderr, "ERROR: size value too long ('%s)\n", amount); - return 14; + return 1; } fd = open_file_or_dir(path, &dirstream); if (fd < 0) { fprintf(stderr, "ERROR: can't access to '%s'\n", path); - return 12; + return 1; } printf("Resize '%s' of '%s'\n", path, amount); @@ -479,7 +479,7 @@ static int cmd_resize(int argc, char **argv) if( res < 0 ){ fprintf(stderr, "ERROR: unable to resize '%s' - %s\n", path, strerror(e)); - return 30; + return 1; } return 0; }