aboutsummaryrefslogtreecommitdiff
path: root/sbin/mdconfig/mdconfig.c
diff options
context:
space:
mode:
authorHiroki Sato <hrs@FreeBSD.org>2013-06-21 01:47:22 +0000
committerHiroki Sato <hrs@FreeBSD.org>2013-06-21 01:47:22 +0000
commitdb3fdd7f63eb70b128a9e7387824cd61cd428794 (patch)
tree3ae0caae0eacf73435b8dde7bc06590b9c3d3fc6 /sbin/mdconfig/mdconfig.c
parentef27aa40a510e58a0fbbbe4cf3b77290719caaa9 (diff)
downloadsrc-db3fdd7f63eb70b128a9e7387824cd61cd428794.tar.gz
src-db3fdd7f63eb70b128a9e7387824cd61cd428794.zip
- Use length of _PATH_DEV instead of a hardcoded value[*].
- Use MD_NAME for "md". Pointed out by: trasz [*] MFC after: 1 week
Notes
Notes: svn path=/head/; revision=252051
Diffstat (limited to 'sbin/mdconfig/mdconfig.c')
-rw-r--r--sbin/mdconfig/mdconfig.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/sbin/mdconfig/mdconfig.c b/sbin/mdconfig/mdconfig.c
index 28221d48993e..1a33905c1111 100644
--- a/sbin/mdconfig/mdconfig.c
+++ b/sbin/mdconfig/mdconfig.c
@@ -216,8 +216,8 @@ main(int argc, char **argv)
errx(1, "unknown suffix on -s argument");
break;
case 'u':
- if (!strncmp(optarg, _PATH_DEV, 5))
- optarg += 5;
+ if (!strncmp(optarg, _PATH_DEV, sizeof(_PATH_DEV) - 1))
+ optarg += sizeof(_PATH_DEV) - 1;
if (!strncmp(optarg, MD_NAME, sizeof(MD_NAME) - 1))
optarg += sizeof(MD_NAME) - 1;
uflag = optarg;
@@ -510,7 +510,7 @@ static int
md_find(const char *list, const char *name)
{
int ret;
- char num[16];
+ char num[PATH_MAX];
char *ptr, *p, *u;
ret = 0;
@@ -518,10 +518,10 @@ md_find(const char *list, const char *name)
if (ptr == NULL)
return (-1);
for (p = ptr; (u = strsep(&p, ",")) != NULL;) {
- if (strncmp(u, _PATH_DEV, 5) == 0)
- u += 5;
+ if (strncmp(u, _PATH_DEV, sizeof(_PATH_DEV) - 1) == 0)
+ u += sizeof(_PATH_DEV) - 1;
/* Just in case user specified number instead of full name */
- snprintf(num, sizeof(num), "md%s", u);
+ snprintf(num, sizeof(num), "%s%s", MD_NAME, u);
if (strcmp(u, name) == 0 || strcmp(num, name) == 0) {
ret = 1;
break;