Try harder to retain the "brand" string in the shared library
authorKen Raeburn <raeburn@mit.edu>
Sat, 23 Oct 2010 22:25:51 +0000 (22:25 +0000)
committerKen Raeburn <raeburn@mit.edu>
Sat, 23 Oct 2010 22:25:51 +0000 (22:25 +0000)
Make the brand array non-static, and actually use the value in (the
infrequently-called) krb5_init_secure_context.

git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@24471 dc483132-0cff-0310-8789-dd5450dbe970

src/lib/krb5/krb/brand.c
src/lib/krb5/krb/init_ctx.c

index fc098ddb51d0aeeaa74ff1bb4b62aba8f6eec5e1..c7b8a61dca11c7e6f85701ea544b30961be379c7 100644 (file)
@@ -70,4 +70,4 @@
 
 #define BRANDSTR RELTAG " " RELNAME " " RELDATE
 
-static char krb5_brand[] = "KRB5_BRAND: " BRANDSTR;
+char krb5_brand[] = "KRB5_BRAND: " BRANDSTR;
index 30ae2efc0764fe85acb6fa82df3a6a7b1b55cfe8..91ed6e1c7ec01bdf6080d1783a720315e1200cb9 100644 (file)
@@ -91,10 +91,19 @@ krb5_init_context(krb5_context *context)
 krb5_error_code KRB5_CALLCONV
 krb5_init_secure_context(krb5_context *context)
 {
-
-    /* This is to make gcc -Wall happy */
-    if(0) krb5_brand[0] = krb5_brand[0];
-    return init_common (context, TRUE, FALSE);
+    /*
+     * This is rather silly, but should improve our chances of
+     * retaining the krb5_brand array in the final linked library,
+     * better than a static variable that's unreferenced after
+     * optimization, or even a non-static symbol that's not exported
+     * from the library nor referenced from anywhere else in the
+     * library.
+     *
+     * If someday we grow an API to actually return the string, we can
+     * get rid of this silliness.
+     */
+    int my_false = (krb5_brand[0] == 0);
+    return init_common (context, TRUE, my_false);
 }
 
 krb5_error_code