From patchwork Mon Aug 12 11:41:10 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 2843046 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id C1B69BF546 for ; Mon, 12 Aug 2013 11:41:36 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1BCEA203EB for ; Mon, 12 Aug 2013 11:41:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D0E92203EA for ; Mon, 12 Aug 2013 11:41:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756043Ab3HLLlY (ORCPT ); Mon, 12 Aug 2013 07:41:24 -0400 Received: from mga14.intel.com ([143.182.124.37]:8265 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754984Ab3HLLlX (ORCPT ); Mon, 12 Aug 2013 07:41:23 -0400 Received: from azsmga002.ch.intel.com ([10.2.17.35]) by azsmga102.ch.intel.com with ESMTP; 12 Aug 2013 04:41:22 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.89,862,1367996400"; d="scan'208";a="280815454" Received: from smile.fi.intel.com (HELO smile) ([10.237.72.173]) by AZSMGA002.ch.intel.com with ESMTP; 12 Aug 2013 04:41:21 -0700 Received: from andy by smile with local (Exim 4.80) (envelope-from ) id 1V8qUo-00072R-PO; Mon, 12 Aug 2013 14:41:10 +0300 From: Andy Shevchenko To: Chris Mason , linux-btrfs@vger.kernel.org Cc: Andy Shevchenko Subject: [PATCH] btrfs: reuse kbasename helper Date: Mon, 12 Aug 2013 14:41:10 +0300 Message-Id: <1376307670-27010-1-git-send-email-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 1.8.4.rc1 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.7 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 To get name of the file from a pathname let's use kbasename() helper. It allows to simplify code a bit. Signed-off-by: Andy Shevchenko --- fs/btrfs/send.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c index d3f3b43..4fdc99d 100644 --- a/fs/btrfs/send.c +++ b/fs/btrfs/send.c @@ -26,6 +26,7 @@ #include #include #include +#include #include "send.h" #include "backref.h" @@ -2591,20 +2592,14 @@ static int record_ref(struct list_head *head, u64 dir, ref->dir_gen = dir_gen; ref->full_path = path; - tmp = strrchr(ref->full_path->start, '/'); - if (!tmp) { - ref->name_len = ref->full_path->end - ref->full_path->start; - ref->name = ref->full_path->start; + ref->name = kbasename(ref->full_path->start); + ref->name_len = ref->full_path->end - ref->name; + ref->dir_path = ref->full_path->start; + if (ref->name == ref->full_path->start) ref->dir_path_len = 0; - ref->dir_path = ref->full_path->start; - } else { - tmp++; - ref->name_len = ref->full_path->end - tmp; - ref->name = tmp; - ref->dir_path = ref->full_path->start; + else ref->dir_path_len = ref->full_path->end - ref->full_path->start - 1 - ref->name_len; - } list_add_tail(&ref->list, head); return 0;