From patchwork Mon Sep 24 13:42:26 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yongjun X-Patchwork-Id: 1497671 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id DD28ADF280 for ; Mon, 24 Sep 2012 13:42:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755445Ab2IXNm1 (ORCPT ); Mon, 24 Sep 2012 09:42:27 -0400 Received: from mail-qa0-f46.google.com ([209.85.216.46]:37256 "EHLO mail-qa0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754286Ab2IXNm0 (ORCPT ); Mon, 24 Sep 2012 09:42:26 -0400 Received: by qadc26 with SMTP id c26so821562qad.19 for ; Mon, 24 Sep 2012 06:42:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:cc:content-type; bh=avxLptcRYF6XUfgIgKXMJK0pWdtW3WSDzo15tw9UB+4=; b=QsPdWsDKM/nQkGLLsSvggKS1QaOg37nKn0BHwIO1iyHWs9I4+NNN0KW7fv+0V7WKRs O+9U09yjXI5YKPnZzTrLE5Q6FXOMrukmUDxaPFRE8GU3sH6avf/P+yjEy5klRC71tbx4 QmrsVAFLFqcBu3W+FFP+84K9sJeVKoIej6OQZ+uSfvVSGT5ANKHea8U9iBMA699YTv3T Rf0jc/tHjXaDM9AYMJBRlWFPRZ8aaw5VuEVo3bZLIM5MPiQyn+U2L/ft9g2TUnWhjaz5 z+uGweYglVqQgM9xrJLEETlVaoY2+HnxJXF23braexal0wanJZvpVUQxov7xYjWnm1Ow 8QXA== MIME-Version: 1.0 Received: by 10.224.179.7 with SMTP id bo7mr31936581qab.96.1348494146071; Mon, 24 Sep 2012 06:42:26 -0700 (PDT) Received: by 10.229.146.194 with HTTP; Mon, 24 Sep 2012 06:42:26 -0700 (PDT) Date: Mon, 24 Sep 2012 21:42:26 +0800 Message-ID: Subject: [PATCH v2] Btrfs: fix return value check From: Wei Yongjun To: chris.mason@fusionio.com Cc: yongjun_wei@trendmicro.com.cn, linux-btrfs@vger.kernel.org Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org From: Wei Yongjun In case of error, the function btrfs_read_fs_root_no_name() returns ERR_PTR() and never returns NULL pointer. The NULL test in the return value check should be replaced with IS_ERR(), and remove useless NULL test. dpatch engine is used to auto generate this patch. (https://github.com/weiyj/dpatch) Signed-off-by: Wei Yongjun Reviewed-by: David Sterba --- v1 -> v2: remove null test from fs/btrfs/disk-io.c --- fs/btrfs/disk-io.c | 2 -- fs/btrfs/send.c | 8 ++------ 2 files changed, 2 insertions(+), 8 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 22e98e0..1405620 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -2593,8 +2593,6 @@ retry_root_backup: location.offset = (u64)-1; fs_info->fs_root = btrfs_read_fs_root_no_name(fs_info, &location); - if (!fs_info->fs_root) - goto fail_qgroup; if (IS_ERR(fs_info->fs_root)) { err = PTR_ERR(fs_info->fs_root); goto fail_qgroup; diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c index fb5ffe9..a617451 100644 --- a/fs/btrfs/send.c +++ b/fs/btrfs/send.c @@ -4501,10 +4501,6 @@ long btrfs_ioctl_send(struct file *mnt_file, void __user *arg_) key.type = BTRFS_ROOT_ITEM_KEY; key.offset = (u64)-1; clone_root = btrfs_read_fs_root_no_name(fs_info, &key); - if (!clone_root) { - ret = -EINVAL; - goto out; - } if (IS_ERR(clone_root)) { ret = PTR_ERR(clone_root); goto out; @@ -4520,8 +4516,8 @@ long btrfs_ioctl_send(struct file *mnt_file, void __user *arg_) key.type = BTRFS_ROOT_ITEM_KEY; key.offset = (u64)-1; sctx->parent_root = btrfs_read_fs_root_no_name(fs_info, &key); - if (!sctx->parent_root) { - ret = -EINVAL; + if (IS_ERR(sctx->parent_root)) { + ret = PTR_ERR(sctx->parent_root); goto out; } }