From patchwork Wed Sep 4 15:22:28 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wang Shilong X-Patchwork-Id: 2853753 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 AA48C9F485 for ; Wed, 4 Sep 2013 15:23:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 72A1F204CB for ; Wed, 4 Sep 2013 15:23:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BD495204D3 for ; Wed, 4 Sep 2013 15:23:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1762948Ab3IDPXP (ORCPT ); Wed, 4 Sep 2013 11:23:15 -0400 Received: from mail-pd0-f175.google.com ([209.85.192.175]:58622 "EHLO mail-pd0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1762934Ab3IDPXM (ORCPT ); Wed, 4 Sep 2013 11:23:12 -0400 Received: by mail-pd0-f175.google.com with SMTP id q10so463932pdj.6 for ; Wed, 04 Sep 2013 08:23:12 -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=RWYY+cb4JzUAKG02g9mzWrwjY9lPEZX9n3wNDqcjMQo=; b=UFTc/M68zFiWegaqCafVs++cie8HXS9h+ZB3H22V5YiJpQPCK+de3TCWpt1baS6zWN ipgak5A8Qv7OabriNPaWiuat6fHreB+2CsPXeA9XwqXtqDc70glfYO6fy52WAM4eshIg 419+i1lUQsP1CaQrSKW1LZT5jhpkbHqt6fKDahjLbIJFPGDhoJiBhPdNZZQSafZGOcDH 5OVta27Va51m0+4bNtjmqGel1X41awmRc+VZV8cdtO+FG8yJ6K/sEPxcHlqsOq4llJH9 abjkTn5lafP2vSwVvo4M66lpgs1TPnD6AtCVDevA2CZM0ooEKkeio5UuekuVlZxRG8sP aMVw== X-Received: by 10.68.189.5 with SMTP id ge5mr3950505pbc.42.1378308192153; Wed, 04 Sep 2013 08:23:12 -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:23:11 -0700 (PDT) From: Wang Shilong To: linux-btrfs@vger.kernel.org Cc: dsterba@suse.cz, sandeen@redhat.com Subject: [PATCH 11/20] Btrfs-progs: fix magic return value in cmds-restore.c Date: Wed, 4 Sep 2013 23:22:28 +0800 Message-Id: <1378308157-4621-12-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-restore.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/cmds-restore.c b/cmds-restore.c index 4c87483..04a8382 100644 --- a/cmds-restore.c +++ b/cmds-restore.c @@ -247,7 +247,7 @@ static int copy_one_inline(int fd, struct btrfs_path *path, u64 pos) outbuf = malloc(ram_size); if (!outbuf) { fprintf(stderr, "No memory\n"); - return -1; + return -ENOMEM; } ret = decompress(buf, outbuf, len, &ram_size, compress); @@ -305,7 +305,7 @@ static int copy_one_extent(struct btrfs_root *root, int fd, inbuf = malloc(disk_size); if (!inbuf) { fprintf(stderr, "No memory\n"); - return -1; + return -ENOMEM; } if (compress != BTRFS_COMPRESS_NONE) { @@ -313,7 +313,7 @@ static int copy_one_extent(struct btrfs_root *root, int fd, if (!outbuf) { fprintf(stderr, "No memory\n"); free(inbuf); - return -1; + return -ENOMEM; } } again: @@ -543,7 +543,7 @@ static int copy_file(struct btrfs_root *root, int fd, struct btrfs_key *key, path = btrfs_alloc_path(); if (!path) { fprintf(stderr, "Ran out of memory\n"); - return -1; + return -ENOMEM; } path->skip_locking = 1; @@ -676,7 +676,7 @@ static int search_dir(struct btrfs_root *root, struct btrfs_key *key, path = btrfs_alloc_path(); if (!path) { fprintf(stderr, "Ran out of memory\n"); - return -1; + return -ENOMEM; } path->skip_locking = 1; @@ -823,7 +823,7 @@ static int search_dir(struct btrfs_root *root, struct btrfs_key *key, if (!dir) { fprintf(stderr, "Ran out of memory\n"); btrfs_free_path(path); - return -1; + return -ENOMEM; } if (location.type == BTRFS_ROOT_ITEM_KEY) { @@ -917,7 +917,7 @@ static int do_list_roots(struct btrfs_root *root) path = btrfs_alloc_path(); if (!path) { fprintf(stderr, "Failed to alloc path\n"); - return -1; + return -ENOMEM; } key.offset = 0; @@ -1210,7 +1210,7 @@ int cmd_restore(int argc, char **argv) if ((ret = check_mounted(argv[optind])) < 0) { fprintf(stderr, "Could not check mount status: %s\n", strerror(-ret)); - return ret; + return 1; } else if (ret) { fprintf(stderr, "%s is currently mounted. Aborting.\n", argv[optind]); return 1; @@ -1284,5 +1284,5 @@ out: if (mreg) regfree(mreg); close_ctree(root); - return ret; + return !!ret; }