From owner-svn-src-head@FreeBSD.ORG Wed Jun 26 23:20:12 2013 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 18EDB119; Wed, 26 Jun 2013 23:20:12 +0000 (UTC) (envelope-from jimharris@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 51447161F; Wed, 26 Jun 2013 23:20:10 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r5QNK9pr001966; Wed, 26 Jun 2013 23:20:09 GMT (envelope-from jimharris@svn.freebsd.org) Received: (from jimharris@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r5QNK9YB001960; Wed, 26 Jun 2013 23:20:09 GMT (envelope-from jimharris@svn.freebsd.org) Message-Id: <201306262320.r5QNK9YB001960@svn.freebsd.org> From: Jim Harris Date: Wed, 26 Jun 2013 23:20:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r252270 - head/sbin/nvmecontrol X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 26 Jun 2013 23:20:12 -0000 Author: jimharris Date: Wed Jun 26 23:20:08 2013 New Revision: 252270 URL: http://svnweb.freebsd.org/changeset/base/252270 Log: Create #defines for NVME_CTRLR_PREFIX and NVME_NS_PREFIX for the "nvme" and "ns" strings, rather than hardcoding the string values throughout the nvmecontrol code base. Sponsored by: Intel MFC after: 3 days Modified: head/sbin/nvmecontrol/devlist.c head/sbin/nvmecontrol/identify.c head/sbin/nvmecontrol/nvmecontrol.h Modified: head/sbin/nvmecontrol/devlist.c ============================================================================== --- head/sbin/nvmecontrol/devlist.c Wed Jun 26 23:11:20 2013 (r252269) +++ head/sbin/nvmecontrol/devlist.c Wed Jun 26 23:20:08 2013 (r252270) @@ -78,7 +78,7 @@ devlist(int argc, char *argv[]) while (1) { ctrlr++; - sprintf(name, "nvme%d", ctrlr); + sprintf(name, "%s%d", NVME_CTRLR_PREFIX, ctrlr); exit_code = open_dev(name, &fd, 0, 0); @@ -95,7 +95,8 @@ devlist(int argc, char *argv[]) printf("%6s: %s\n", name, cdata.mn); for (i = 0; i < cdata.nn; i++) { - sprintf(name, "nvme%dns%d", ctrlr, i+1); + sprintf(name, "%s%d%s%d", NVME_CTRLR_PREFIX, ctrlr, + NVME_NS_PREFIX, i+1); read_namespace_data(fd, i+1, &nsdata); printf(" %10s (%lldGB)\n", name, Modified: head/sbin/nvmecontrol/identify.c ============================================================================== --- head/sbin/nvmecontrol/identify.c Wed Jun 26 23:11:20 2013 (r252269) +++ head/sbin/nvmecontrol/identify.c Wed Jun 26 23:20:08 2013 (r252270) @@ -258,7 +258,7 @@ identify_ns(int argc, char *argv[]) * of the string. Don't search past 10 characters into the string, * otherwise we know it is malformed. */ - nsloc = strnstr(argv[optind], "ns", 10); + nsloc = strnstr(argv[optind], NVME_NS_PREFIX, 10); if (nsloc != NULL) nsid = strtol(nsloc + 2, NULL, 10); if (nsloc == NULL || (nsid == 0 && errno != 0)) { @@ -314,7 +314,7 @@ identify(int argc, char *argv[]) * If device node contains "ns", we consider it a namespace, * otherwise, consider it a controller. */ - if (strstr(target, "ns") == NULL) + if (strstr(target, NVME_NS_PREFIX) == NULL) identify_ctrlr(argc, argv); else identify_ns(argc, argv); Modified: head/sbin/nvmecontrol/nvmecontrol.h ============================================================================== --- head/sbin/nvmecontrol/nvmecontrol.h Wed Jun 26 23:11:20 2013 (r252269) +++ head/sbin/nvmecontrol/nvmecontrol.h Wed Jun 26 23:20:08 2013 (r252270) @@ -31,6 +31,9 @@ #include +#define NVME_CTRLR_PREFIX "nvme" +#define NVME_NS_PREFIX "ns" + #define DEVLIST_USAGE \ " nvmecontrol devlist\n"