From patchwork Fri Nov 27 08:11:31 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rasmus Villemoes X-Patchwork-Id: 7711411 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.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 25917BF90C for ; Fri, 27 Nov 2015 08:12:10 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4B20720636 for ; Fri, 27 Nov 2015 08:12:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6BB382063A for ; Fri, 27 Nov 2015 08:12:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753977AbbK0ILu (ORCPT ); Fri, 27 Nov 2015 03:11:50 -0500 Received: from mail-lf0-f42.google.com ([209.85.215.42]:33795 "EHLO mail-lf0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751302AbbK0ILt (ORCPT ); Fri, 27 Nov 2015 03:11:49 -0500 Received: by lffu14 with SMTP id u14so120843541lff.1 for ; Fri, 27 Nov 2015 00:11:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; h=from:to:cc:subject:date:message-id; bh=fwYAL/IkDtTeWvgmjkQ4aRwTill/RF9UGEO8DhnfAlU=; b=iz3MndQ2spzqBTxqulbSzPM1efzERvAae3x40cikdbrZNP9k1g2ApUWaW2eUt2jepy 3YsQLnl4NHKYSCHw4DLSmcpwE59qNgZmbdOAjZ3cII63dG0jPXrFqbgIWYFMt8l6lVkD BhimnNv4+IsRBvnVpKhS0ndhX1ukhO7mvIOm0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=fwYAL/IkDtTeWvgmjkQ4aRwTill/RF9UGEO8DhnfAlU=; b=mj70El7BW+RyByZJkfKHkuqqrBROTods8eGmjlVt2VgPUE9koR1URIAME8jwb3saa5 o0QWxjTTN27J40QypFSJ2BVFNwHWZnLMU6Zl9HcxJ3MoMZNaceq3m3+kiaqpEw+ekNVG 27coP9io3zSuu+NV2V/XCQ/ui2gw8iZg9GRHS+R5z7+QQgOtaOBjUcV1GrlcywuZH4hi XahNiwFw/5CLdY9GMGXVpBH1KLExgzGIoQea6liDBUfm1iJrzVpbrOLP+8ix5vYuBfGt 2Kf57HMNRaoo+xV+far3ux5ozuL4y+Wpv37NBkRlRBVAYvfv3xxL0X3MnmITlSMUoWb4 yrBg== X-Gm-Message-State: ALoCoQmoYfG/p7ei1H6FdDXzomo+VRe27NfJTITGY7wz9h5RjOhFiS937MQbFAehmrzk4+HByXPZ X-Received: by 10.112.199.41 with SMTP id jh9mr595121lbc.119.1448611908105; Fri, 27 Nov 2015 00:11:48 -0800 (PST) Received: from garcia.imf.au.dk ([130.225.20.51]) by smtp.gmail.com with ESMTPSA id un3sm4718607lbc.28.2015.11.27.00.11.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 27 Nov 2015 00:11:47 -0800 (PST) From: Rasmus Villemoes To: Chris Mason , Josef Bacik , David Sterba Cc: Rasmus Villemoes , linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] btrfs: use kbasename in btrfsic_mount Date: Fri, 27 Nov 2015 09:11:31 +0100 Message-Id: <1448611892-26144-1-git-send-email-linux@rasmusvillemoes.dk> X-Mailer: git-send-email 2.6.1 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID,T_RP_MATCHES_RCVD,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 This is more readable. Signed-off-by: Rasmus Villemoes Reviewed-by: David Sterba --- I think the following strlcpy may be somewhat fragile since obviously ds->name and p overlap. It certainly relies on strlcpy doing a forward copy, and since different architectures can have their own strlcpy, that's hard to verify (and also won't necessarily continue to hold). Maybe if (p != ds->name) memmove(ds->name, p, strlen(p)+1); instead. fs/btrfs/check-integrity.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/fs/btrfs/check-integrity.c b/fs/btrfs/check-integrity.c index 0340c57bf377..55a5cff390b9 100644 --- a/fs/btrfs/check-integrity.c +++ b/fs/btrfs/check-integrity.c @@ -95,6 +95,7 @@ #include #include #include +#include #include "ctree.h" #include "disk-io.h" #include "hash.h" @@ -3136,11 +3137,7 @@ int btrfsic_mount(struct btrfs_root *root, ds->state = state; bdevname(ds->bdev, ds->name); ds->name[BDEVNAME_SIZE - 1] = '\0'; - for (p = ds->name; *p != '\0'; p++); - while (p > ds->name && *p != '/') - p--; - if (*p == '/') - p++; + p = kbasename(ds->name); strlcpy(ds->name, p, sizeof(ds->name)); btrfsic_dev_state_hashtable_add(ds, &btrfsic_dev_state_hashtable);