diff options
author | des <des@FreeBSD.org> | 2008-11-04 13:44:07 +0000 |
---|---|---|
committer | des <des@FreeBSD.org> | 2008-11-04 13:44:07 +0000 |
commit | c64f9d5600fbde0c975382c740ef636232c6760e (patch) | |
tree | 043ae1d6bd60717e1ba849b94281d5ae09391edc | |
parent | d9ae813ea1e74131d4bd84b8bfa77da974d580eb (diff) | |
download | FreeBSD-src-c64f9d5600fbde0c975382c740ef636232c6760e.zip FreeBSD-src-c64f9d5600fbde0c975382c740ef636232c6760e.tar.gz |
Avoid assigning a const char * to a char *.
MFC after: 3 weeks
-rw-r--r-- | lib/libutil/login_class.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/lib/libutil/login_class.c b/lib/libutil/login_class.c index 94cb3aa..5074519 100644 --- a/lib/libutil/login_class.c +++ b/lib/libutil/login_class.c @@ -142,14 +142,13 @@ substvar(const char * var, const struct passwd * pwd, int hlen, int pch, int nle int tildes = 0; int dollas = 0; char *p; + const char *q; if (pwd != NULL) { - /* Count the number of ~'s in var to substitute */ - for (p = (char *)var; (p = strchr(p, '~')) != NULL; p++) - ++tildes; - /* Count the number of $'s in var to substitute */ - for (p = (char *)var; (p = strchr(p, '$')) != NULL; p++) - ++dollas; + for (q = var; *q != '\0'; ++q) { + tildes += (*q == '~'); + dollas += (*q == '$'); + } } np = malloc(strlen(var) + (dollas * nlen) |