From patchwork Mon Sep 18 14:35:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Grafin X-Patchwork-Id: 9956879 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 75A3C60385 for ; Mon, 18 Sep 2017 14:54:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 66A1128473 for ; Mon, 18 Sep 2017 14:54:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5B53128A51; Mon, 18 Sep 2017 14:54:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3C14328473 for ; Mon, 18 Sep 2017 14:54:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755814AbdIROyf (ORCPT ); Mon, 18 Sep 2017 10:54:35 -0400 Received: from us-edge-1.acronis.com ([69.20.59.99]:38714 "EHLO us-edge-1.acronis.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755804AbdIROyd (ORCPT ); Mon, 18 Sep 2017 10:54:33 -0400 X-Greylist: delayed 1154 seconds by postgrey-1.27 at vger.kernel.org; Mon, 18 Sep 2017 10:54:33 EDT DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=acronis.com ; s=exim; h=Content-Type:MIME-Version:Message-ID:Date:Subject:CC:To:From: Sender:Reply-To:Content-Transfer-Encoding:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=LIsk+9IUScntF0VEkOTbRGTGEJwVquwzP6W2bt/VQD0=; b=RelDo+j1a4hf+lHeX7+nlgwbHQ HCB2MqiD7gzT5SfVfbO9mb0aIvqCg9vNEl5TgaRSzP0y/y7mrFsoOOZze0ukV4/evOsiXFXolYl/u eFVvim39/r3HwRrZ2wNl+KfrYsJG8fu7yZuSfQqjxfnNOXNMa4OhdRRc+LEWbP0tCwEA=; Received: from 31.nat.acronis.net ([91.195.22.31] helo=ru-exch-1.corp.acronis.com) by us-edge-1.acronis.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-SHA384:256) (Exim 4.89) (envelope-from ) id 1dtx8o-0000TK-KA for linux-scsi@vger.kernel.org; Mon, 18 Sep 2017 10:35:18 -0400 Received: from agrafin-desktop.corp.acronis.com (10.246.144.37) by ru-exch-1.corp.acronis.com (10.250.32.14) with Microsoft SMTP Server (TLS) id 15.0.1178.4; Mon, 18 Sep 2017 17:35:16 +0300 From: Andrey Grafin To: CC: Andrey Grafin Subject: [PATCH] fcoe-utils: Fix get_ctlr_num() for large ctlr_* indices Date: Mon, 18 Sep 2017 17:35:08 +0300 Message-ID: <20170918143508.4659-1-Andrey.Grafin@acronis.com> X-Mailer: git-send-email 2.11.0 MIME-Version: 1.0 X-Originating-IP: [10.246.144.37] X-ClientProxiedBy: ru-exch-2.corp.acronis.com (10.250.32.15) To ru-exch-1.corp.acronis.com (10.250.32.14) Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Each creation of a FCoE device increases counter which is used as a suffix in a FCoE device name in sysfs (i.e. /sys/bus/fcoe/devices/ctlr_1). Once this counter reaches the value of two digits (10 and larger), get_ctlr_num() stopped working properly and a command like `fcoeadm -i` which depends on get_ctlr_num() call doesn't show anything. This patch solves this problem. Signed-off-by: Andrey Grafin Reviewed-by: Hannes Reinecke --- lib/sysfs_hba.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sysfs_hba.c b/lib/sysfs_hba.c index 5cb7fd3fa5d..786215440ba 100644 --- a/lib/sysfs_hba.c +++ b/lib/sysfs_hba.c @@ -606,7 +606,7 @@ static int get_ctlr_num(const char *netdev) if (!ctlr) continue; - ctlr_num = atoi(&ctlr[strlen(ctlr) - 1]); + ctlr_num = atoi(&ctlr[sizeof("ctlr_") - 1]); break; }