From: Ken Raeburn Date: Tue, 15 Jun 2004 17:52:23 +0000 (+0000) Subject: * rc_io.c (dir, dirlen): Top-level variables deleted. X-Git-Tag: krb5-1.4-beta1~329 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=f72d1775ac0c5b9bb4d04d9081bac959ff08cb7a;p=krb5.git * rc_io.c (dir, dirlen): Top-level variables deleted. (getdir): Now returns the pointer, doesn't set top-level variables. (GETDIR): Set local variables dir and dirlen using the function's return value. (krb5_rc_io_creat, krb5_rc_io_open_internal): Add the new local variables. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@16450 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/lib/krb5/rcache/ChangeLog b/src/lib/krb5/rcache/ChangeLog index 496cd57b5..185874199 100644 --- a/src/lib/krb5/rcache/ChangeLog +++ b/src/lib/krb5/rcache/ChangeLog @@ -1,3 +1,13 @@ +2004-06-15 Ken Raeburn + + * rc_io.c (dir, dirlen): Top-level variables deleted. + (getdir): Now returns the pointer, doesn't set top-level + variables. + (GETDIR): Set local variables dir and dirlen using the function's + return value. + (krb5_rc_io_creat, krb5_rc_io_open_internal): Add the new local + variables. + 2004-06-02 Ken Raeburn * rc-int.h (struct krb5_rc_st, struct _krb5_rc_ops, krb5_rc_ops): diff --git a/src/lib/krb5/rcache/rc_io.c b/src/lib/krb5/rcache/rc_io.c index 706bd759a..e2e81dede 100644 --- a/src/lib/krb5/rcache/rc_io.c +++ b/src/lib/krb5/rcache/rc_io.c @@ -42,18 +42,13 @@ #define FREE(x) ((void) free((char *) (x))) #define UNIQUE getpid() /* hopefully unique number */ -static unsigned int dirlen = 0; -static char *dir; +#define GETDIR (dir = getdir(), dirlen = strlen(dir) + sizeof(PATH_SEPARATOR) - 1) -/* The do ... while(0) is required to insure that GETDIR looks like a - single statement in all situations (just {}'s may cause troubles in - certain situations, such as nested if/else clauses. */ - -#define GETDIR do { if (!dirlen) getdir(); } while(0) - -static void +static char * getdir(void) { + char *dir; + if (!(dir = getenv("KRB5RCACHEDIR"))) { #if defined(_WIN32) if (!(dir = getenv("TEMP"))) @@ -69,7 +64,7 @@ getdir(void) } #endif } - dirlen = strlen(dir) + sizeof(PATH_SEPARATOR) - 1; + return dir; } krb5_error_code @@ -79,6 +74,8 @@ krb5_rc_io_creat(krb5_context context, krb5_rc_iostuff *d, char **fn) krb5_int16 rc_vno = htons(KRB5_RC_VNO); krb5_error_code retval = 0; int do_not_unlink = 0; + char *dir; + size_t dirlen; GETDIR; if (fn && *fn) @@ -182,6 +179,8 @@ krb5_rc_io_open_internal(krb5_context context, krb5_rc_iostuff *d, char *fn, #ifndef NO_USERID struct stat statb; #endif + char *dir; + size_t dirlen; GETDIR; if (full_pathname) {