summaryrefslogtreecommitdiffstats
path: root/sbin/mdmfs
diff options
context:
space:
mode:
authoryar <yar@FreeBSD.org>2007-04-30 13:21:43 +0000
committeryar <yar@FreeBSD.org>2007-04-30 13:21:43 +0000
commit99faf91c588fedeb9916bb485fab297f0fd3d5d8 (patch)
tree1fff64d42b7481bfe34fb9acc9218a5c3179ac45 /sbin/mdmfs
parent769eaedef1ba6d1b3f90c387660514d14a69a7d3 (diff)
downloadFreeBSD-src-99faf91c588fedeb9916bb485fab297f0fd3d5d8.zip
FreeBSD-src-99faf91c588fedeb9916bb485fab297f0fd3d5d8.tar.gz
Fix a typo: argv -> argvp
Rationale: We are interested in the current (last) element of the argv array there, not in its first element. The if construct is there because we want to avoid adding empty (zero-length) arguments to argv, so we just don't advance argvp if the current argument is empty, and it gets overwritten at the next iteration. Note that strsep(3) doesn't treat consecutive delim characters as a single separator, it returns empty fields between such characters, and it's up to the caller to handle them this or that way. Also add a comment that the argv array ends up null-terminated in any case (it's due to the design of the for loop) as an answer to a possible question why the whole argv isn't zero-filled. Submitted by: yongari Tested by: yongari MFC after: 3 days
Diffstat (limited to 'sbin/mdmfs')
-rw-r--r--sbin/mdmfs/mdmfs.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/sbin/mdmfs/mdmfs.c b/sbin/mdmfs/mdmfs.c
index acc6e00..59e194e 100644
--- a/sbin/mdmfs/mdmfs.c
+++ b/sbin/mdmfs/mdmfs.c
@@ -583,12 +583,13 @@ run(int *ofd, const char *cmdline, ...)
argv = (char **)malloc(sizeof(*argv) * (argc + 1));
assert(argv != NULL);
for (p = cmd, argvp = argv; (*argvp = strsep(&p, " ")) != NULL;)
- if (**argv != '\0')
+ if (**argvp != '\0')
if (++argvp >= &argv[argc]) {
*argvp = NULL;
break;
}
assert(*argv);
+ /* The argv array ends up NULL-terminated here. */
/* Make sure the above loop works as expected. */
if (debug) {
OpenPOWER on IntegriCloud