summaryrefslogtreecommitdiffstats
path: root/sbin/mdconfig
diff options
context:
space:
mode:
authorhrs <hrs@FreeBSD.org>2013-06-21 01:47:22 +0000
committerhrs <hrs@FreeBSD.org>2013-06-21 01:47:22 +0000
commit0743eae837977d96ffb4caa1d0c2045acf4781a1 (patch)
tree3ae0caae0eacf73435b8dde7bc06590b9c3d3fc6 /sbin/mdconfig
parentf77f5bcc61cfb79e937125cfa87e659153465ffa (diff)
downloadFreeBSD-src-0743eae837977d96ffb4caa1d0c2045acf4781a1.zip
FreeBSD-src-0743eae837977d96ffb4caa1d0c2045acf4781a1.tar.gz
- Use length of _PATH_DEV instead of a hardcoded value[*].
- Use MD_NAME for "md". Pointed out by: trasz [*] MFC after: 1 week
Diffstat (limited to 'sbin/mdconfig')
-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 28221d4..1a33905 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;
OpenPOWER on IntegriCloud