svn commit: r184633 - head/lib/libutil
Dag-Erling Smorgrav
des at FreeBSD.org
Tue Nov 4 05:49:54 PST 2008
Author: des
Date: Tue Nov 4 13:49:53 2008
New Revision: 184633
URL: http://svn.freebsd.org/changeset/base/184633
Log:
Avoid assigning a const char * to a char *.
MFC after: 3 weeks
Modified:
head/lib/libutil/login_cap.c
head/lib/libutil/login_class.c
Modified: head/lib/libutil/login_cap.c
==============================================================================
--- head/lib/libutil/login_cap.c Tue Nov 4 13:49:18 2008 (r184632)
+++ head/lib/libutil/login_cap.c Tue Nov 4 13:49:53 2008 (r184633)
@@ -61,6 +61,8 @@ static char * internal_string = NULL;
static size_t internal_arraysz = 0;
static const char ** internal_array = NULL;
+static char path_login_conf[] = _PATH_LOGIN_CONF;
+
static char *
allocstr(const char *str)
{
@@ -215,15 +217,14 @@ login_getclassbyname(char const *name, c
if (dir && snprintf(userpath, MAXPATHLEN, "%s/%s", dir,
_FILE_LOGIN_CONF) < MAXPATHLEN) {
- login_dbarray[i] = userpath;
if (_secure_path(userpath, pwd->pw_uid, pwd->pw_gid) != -1)
- i++; /* only use 'secure' data */
+ login_dbarray[i++] = userpath;
}
/*
* XXX: Why to add the system database if the class is `me'?
*/
- if (_secure_path(_PATH_LOGIN_CONF, 0, 0) != -1)
- login_dbarray[i++] = _PATH_LOGIN_CONF;
+ if (_secure_path(path_login_conf, 0, 0) != -1)
+ login_dbarray[i++] = path_login_conf;
login_dbarray[i] = NULL;
memset(lc, 0, sizeof(login_cap_t));
Modified: head/lib/libutil/login_class.c
==============================================================================
--- head/lib/libutil/login_class.c Tue Nov 4 13:49:18 2008 (r184632)
+++ head/lib/libutil/login_class.c Tue Nov 4 13:49:53 2008 (r184633)
@@ -142,14 +142,13 @@ substvar(const char * var, const struct
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)
More information about the svn-src-head
mailing list