From: Ruslan Ermilov Date: Mon, 8 Apr 2002 11:04:56 +0000 (+0000) Subject: Const poisoning. X-Git-Url: https://git.cameronkatri.com/pw-darwin.git/commitdiff_plain/ba9264c05d22d82c700f5cf5f3600dcfb1d159b9 Const poisoning. --- diff --git a/libutil/login_cap.c b/libutil/login_cap.c index 9797c8b..55784d7 100644 --- a/libutil/login_cap.c +++ b/libutil/login_cap.c @@ -344,8 +344,8 @@ login_getuserclass(const struct passwd *pwd) * an error string on error. */ -char * -login_getcapstr(login_cap_t *lc, const char *cap, char *def, char *error) +const char * +login_getcapstr(login_cap_t *lc, const char *cap, const char *def, const char *error) { char *res; int ret; @@ -373,7 +373,7 @@ login_getcaplist(login_cap_t *lc, const char *cap, const char *chars) if (chars == NULL) chars = ", \t"; - if ((lstring = login_getcapstr(lc, cap, NULL, NULL)) != NULL) + if ((lstring = (char *)login_getcapstr(lc, cap, NULL, NULL)) != NULL) return arrayize(lstring, chars, NULL); return NULL; } @@ -387,15 +387,15 @@ login_getcaplist(login_cap_t *lc, const char *cap, const char *chars) * If there is an error of any kind, return . */ -char * -login_getpath(login_cap_t *lc, const char *cap, char * error) +const char * +login_getpath(login_cap_t *lc, const char *cap, const char *error) { - char *str; + const char *str; - if ((str = login_getcapstr(lc, (char*)cap, NULL, NULL)) == NULL) + if ((str = login_getcapstr(lc, cap, NULL, NULL)) == NULL) str = error; else { - char *ptr = str; + char *ptr = (char *)str; while (*ptr) { int count = strcspn(ptr, ", \t"); @@ -764,8 +764,8 @@ login_getcapbool(login_cap_t *lc, const char *cap, int def) * login_getstyle(lc, "skey", "network"); */ -char * -login_getstyle(login_cap_t *lc, char *style, const char *auth) +const char * +login_getstyle(login_cap_t *lc, const char *style, const char *auth) { int i; char **authtypes = NULL; diff --git a/libutil/login_cap.h b/libutil/login_cap.h index 81983da..1b3f0a8 100644 --- a/libutil/login_cap.h +++ b/libutil/login_cap.h @@ -102,13 +102,13 @@ login_cap_t *login_getclass(const char *); login_cap_t *login_getpwclass(const struct passwd *); login_cap_t *login_getuserclass(const struct passwd *); -char *login_getcapstr(login_cap_t*, const char *, char *, char *); +const char *login_getcapstr(login_cap_t*, const char *, const char *, const char *); char **login_getcaplist(login_cap_t *, const char *, const char *); -char *login_getstyle(login_cap_t *, char *, const char *); +const char *login_getstyle(login_cap_t *, const char *, const char *); rlim_t login_getcaptime(login_cap_t *, const char *, rlim_t, rlim_t); rlim_t login_getcapnum(login_cap_t *, const char *, rlim_t, rlim_t); rlim_t login_getcapsize(login_cap_t *, const char *, rlim_t, rlim_t); -char *login_getpath(login_cap_t *, const char *, char *); +const char *login_getpath(login_cap_t *, const char *, const char *); int login_getcapbool(login_cap_t *, const char *, int); const char *login_setcryptfmt(login_cap_t *, const char *, const char *); diff --git a/libutil/login_crypt.c b/libutil/login_crypt.c index f3d83a8..c65fc9b 100644 --- a/libutil/login_crypt.c +++ b/libutil/login_crypt.c @@ -38,7 +38,7 @@ const char * login_setcryptfmt(login_cap_t *lc, const char *def, const char *error) { const char *cipher; - cipher = login_getcapstr(lc, "passwd_format", (char *)def, NULL); + cipher = login_getcapstr(lc, "passwd_format", def, NULL); if (getenv("CRYPT_DEBUG") != NULL) fprintf(stderr, "login_setcryptfmt: " "passwd_format = %s\n", cipher);