summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStef Walter <stefw@collabora.co.uk>2011-10-24 09:47:03 +0200
committerStef Walter <stefw@collabora.co.uk>2011-10-24 09:47:03 +0200
commit138c046a5ff1b0e532896b4d640c0cba6ead4027 (patch)
tree2b2b848f2dfe47a80f2f9e46ca94e96ff88c9570
parent5507dc4946f0a68cece5ec9e7096e0f9b8c55984 (diff)
downloadp11-kit-138c046a5ff1b0e532896b4d640c0cba6ead4027.tar.gz
More fixes for non-static function names
* See previous commit * Initialize library before debug statements
-rw-r--r--p11-kit/conf.c8
-rw-r--r--p11-kit/debug.c7
-rw-r--r--p11-kit/debug.h16
-rw-r--r--p11-kit/modules.c62
-rw-r--r--p11-kit/proxy.c14
-rw-r--r--p11-kit/uri.c2
6 files changed, 53 insertions, 56 deletions
diff --git a/p11-kit/conf.c b/p11-kit/conf.c
index d607bfd..6b82d53 100644
--- a/p11-kit/conf.c
+++ b/p11-kit/conf.c
@@ -165,7 +165,7 @@ read_config_file (const char* filename, int flags)
error = errno;
if ((flags & CONF_IGNORE_MISSING) &&
(error == ENOENT || error == ENOTDIR)) {
- debug ("config file does not exist");
+ _p11_debug ("config file does not exist");
config = strdup ("\n");
if (!config)
errno = ENOMEM;
@@ -262,7 +262,7 @@ _p11_conf_parse_file (const char* filename, int flags)
assert (filename);
- debug ("reading config file: %s", filename);
+ _p11_debug ("reading config file: %s", filename);
/* Adds an extra newline to end of file */
data = read_config_file (filename, flags);
@@ -314,7 +314,7 @@ _p11_conf_parse_file (const char* filename, int flags)
break;
}
- debug ("config value: %s: %s", name, value);
+ _p11_debug ("config value: %s: %s", name, value);
if (!_p11_hash_set (map, name, value)) {
free (name);
@@ -532,7 +532,7 @@ load_configs_from_directory (const char *directory, hashmap *configs)
char *path;
int count = 0;
- debug ("loading module configs in: %s", directory);
+ _p11_debug ("loading module configs in: %s", directory);
/* First we load all the modules */
dir = opendir (directory);
diff --git a/p11-kit/debug.c b/p11-kit/debug.c
index b332407..6616459 100644
--- a/p11-kit/debug.c
+++ b/p11-kit/debug.c
@@ -60,7 +60,6 @@ static struct DebugKey debug_keys[] = {
};
static int debug_inited = 0;
-static mutex_t debug_mutex;
/* global variable exported in debug.h */
int _p11_debug_current_flags = ~0;
@@ -114,7 +113,6 @@ void
_p11_debug_init (void)
{
_p11_debug_current_flags = parse_environ_flags ();
- _p11_mutex_init (&debug_mutex);
debug_inited = 1;
}
@@ -125,9 +123,6 @@ _p11_debug_message (int flag,
char buffer[512];
va_list args;
- assert (debug_inited);
- _p11_mutex_lock (&debug_mutex);
-
if (flag & _p11_debug_current_flags) {
va_start (args, format);
vsnprintf (buffer, sizeof (buffer), format, args);
@@ -135,6 +130,4 @@ _p11_debug_message (int flag,
va_end (args);
fprintf (stderr, "(p11-kit:%d) %s\n", getpid(), buffer);
}
-
- _p11_mutex_unlock (&debug_mutex);
}
diff --git a/p11-kit/debug.h b/p11-kit/debug.h
index fab6800..e5b970e 100644
--- a/p11-kit/debug.h
+++ b/p11-kit/debug.h
@@ -73,24 +73,24 @@ void _p11_debug_message (int flag,
#ifdef DEBUG_FLAG
#ifdef WITH_DEBUG
-#undef debug
-#define debug(format, ...) do { \
+#undef _p11_debug
+#define _p11_debug(format, ...) do { \
if (DEBUG_FLAG & _p11_debug_current_flags) \
_p11_debug_message (DEBUG_FLAG, "%s: " format, __PRETTY_FUNCTION__, ##__VA_ARGS__); \
} while (0)
-#undef debugging
-#define debugging \
+#undef _p11_debugging
+#define _p11_debugging \
(DEBUG_FLAG & _p11_debug_current_flags)
#else /* !defined (WITH_DEBUG) */
-#undef debug
-#define debug(format, ...) \
+#undef _p11_debug
+#define _p11_debug(format, ...) \
do {} while (0)
-#undef debugging
-#define debugging 0
+#undef _p11_debugging
+#define _p11_debugging 0
#endif /* !defined (WITH_DEBUG) */
diff --git a/p11-kit/modules.c b/p11-kit/modules.c
index 1c56208..c0660c7 100644
--- a/p11-kit/modules.c
+++ b/p11-kit/modules.c
@@ -282,7 +282,7 @@ dlopen_and_get_function_list (Module *mod, const char *path)
return rv;
}
- debug ("opened module: %s", path);
+ _p11_debug ("opened module: %s", path);
return CKR_OK;
}
@@ -307,7 +307,7 @@ load_module_from_file_unlocked (const char *path, Module **result)
prev = _p11_hash_get (gl.modules, mod->funcs);
if (prev != NULL) {
- debug ("duplicate module %s, using previous", path);
+ _p11_debug ("duplicate module %s, using previous", path);
free_module_unlocked (mod);
mod = prev;
@@ -327,7 +327,7 @@ expand_module_path (const char *filename)
char *path;
if (is_relative_path (filename)) {
- debug ("module path is relative, loading from: %s", P11_MODULE_PATH);
+ _p11_debug ("module path is relative, loading from: %s", P11_MODULE_PATH);
path = build_path (P11_MODULE_PATH, filename);
} else {
path = strdup (filename);
@@ -351,7 +351,7 @@ take_config_and_load_module_unlocked (char **name, hashmap **config)
module_filename = _p11_hash_get (*config, "module");
if (module_filename == NULL) {
- debug ("no module path for module, skipping: %s", *name);
+ _p11_debug ("no module path for module, skipping: %s", *name);
return CKR_OK;
}
@@ -506,12 +506,12 @@ initialize_module_unlocked_reentrant (Module *mod)
if (!mod->initialize_called) {
- debug ("C_Initialize: calling");
+ _p11_debug ("C_Initialize: calling");
assert (mod->funcs);
rv = mod->funcs->C_Initialize (&mod->init_args);
- debug ("C_Initialize: result: %lu", rv);
+ _p11_debug ("C_Initialize: result: %lu", rv);
/* Module was initialized and C_Finalize should be called */
if (rv == CKR_OK)
@@ -542,7 +542,7 @@ reinitialize_after_fork (void)
Module *mod;
/* WARNING: This function must be reentrant */
- debug ("forked");
+ _p11_debug ("forked");
_p11_lock ();
@@ -687,7 +687,7 @@ _p11_kit_initialize_registered_unlocked_reentrant (void)
rv = initialize_module_unlocked_reentrant (mod);
if (rv != CKR_OK) {
- debug ("failed to initialize module: %s: %s",
+ _p11_debug ("failed to initialize module: %s: %s",
mod->name, p11_kit_strerror (rv));
break;
}
@@ -719,11 +719,11 @@ p11_kit_initialize_registered (void)
{
CK_RV rv;
- /* WARNING: This function must be reentrant */
- debug ("in");
-
_p11_library_init_once ();
+ /* WARNING: This function must be reentrant */
+ _p11_debug ("in");
+
_p11_lock ();
_p11_kit_clear_message ();
@@ -739,7 +739,7 @@ p11_kit_initialize_registered (void)
if (rv != CKR_OK)
p11_kit_finalize_registered ();
- debug ("out: %lu", rv);
+ _p11_debug ("out: %lu", rv);
return rv;
}
@@ -769,7 +769,7 @@ _p11_kit_finalize_registered_unlocked_reentrant (void)
to_finalize[count++] = mod;
}
- debug ("finalizing %d modules", count);
+ _p11_debug ("finalizing %d modules", count);
for (i = 0; i < count; ++i) {
/* WARNING: Reentrant calls can occur here */
@@ -806,11 +806,11 @@ p11_kit_finalize_registered (void)
{
CK_RV rv;
- /* WARNING: This function must be reentrant */
- debug ("in");
-
_p11_library_init_once ();
+ /* WARNING: This function must be reentrant */
+ _p11_debug ("in");
+
_p11_lock ();
_p11_kit_clear_message ();
@@ -822,7 +822,7 @@ p11_kit_finalize_registered (void)
_p11_unlock ();
- debug ("out: %lu", rv);
+ _p11_debug ("out: %lu", rv);
return rv;
}
@@ -1025,11 +1025,11 @@ p11_kit_initialize_module (CK_FUNCTION_LIST_PTR module)
Module *mod;
CK_RV rv = CKR_OK;
- /* WARNING: This function must be reentrant for the same arguments */
- debug ("in");
-
_p11_library_init_once ();
+ /* WARNING: This function must be reentrant for the same arguments */
+ _p11_debug ("in");
+
_p11_lock ();
_p11_kit_clear_message ();
@@ -1039,7 +1039,7 @@ p11_kit_initialize_module (CK_FUNCTION_LIST_PTR module)
mod = _p11_hash_get (gl.modules, module);
if (mod == NULL) {
- debug ("allocating new module");
+ _p11_debug ("allocating new module");
allocated = mod = alloc_module_unlocked ();
if (mod == NULL)
rv = CKR_HOST_MEMORY;
@@ -1076,7 +1076,7 @@ p11_kit_initialize_module (CK_FUNCTION_LIST_PTR module)
_p11_unlock ();
- debug ("out: %lu", rv);
+ _p11_debug ("out: %lu", rv);
return rv;
}
@@ -1110,18 +1110,18 @@ p11_kit_finalize_module (CK_FUNCTION_LIST_PTR module)
Module *mod;
CK_RV rv = CKR_OK;
- /* WARNING: This function must be reentrant for the same arguments */
- debug ("in");
-
_p11_library_init_once ();
+ /* WARNING: This function must be reentrant for the same arguments */
+ _p11_debug ("in");
+
_p11_lock ();
_p11_kit_clear_message ();
mod = gl.modules ? _p11_hash_get (gl.modules, module) : NULL;
if (mod == NULL) {
- debug ("module not found");
+ _p11_debug ("module not found");
rv = CKR_ARGUMENTS_BAD;
} else {
/* WARNING: Rentrancy can occur here */
@@ -1132,7 +1132,7 @@ p11_kit_finalize_module (CK_FUNCTION_LIST_PTR module)
_p11_unlock ();
- debug ("out: %lu", rv);
+ _p11_debug ("out: %lu", rv);
return rv;
}
@@ -1176,11 +1176,11 @@ p11_kit_load_initialize_module (const char *module_path,
Module *mod;
CK_RV rv = CKR_OK;
- /* WARNING: This function must be reentrant for the same arguments */
- debug ("in: %s", module_path);
-
_p11_library_init_once ();
+ /* WARNING: This function must be reentrant for the same arguments */
+ _p11_debug ("in: %s", module_path);
+
_p11_lock ();
_p11_kit_clear_message ();
@@ -1211,6 +1211,6 @@ p11_kit_load_initialize_module (const char *module_path,
_p11_unlock ();
- debug ("out: %lu", rv);
+ _p11_debug ("out: %lu", rv);
return rv;
}
diff --git a/p11-kit/proxy.c b/p11-kit/proxy.c
index d6e5006..882924e 100644
--- a/p11-kit/proxy.c
+++ b/p11-kit/proxy.c
@@ -204,7 +204,7 @@ proxy_C_Finalize (CK_VOID_PTR reserved)
{
CK_RV rv;
- debug ("in");
+ _p11_debug ("in");
/* WARNING: This function must be reentrant */
@@ -227,7 +227,7 @@ proxy_C_Finalize (CK_VOID_PTR reserved)
_p11_unlock ();
}
- debug ("out: %lu", rv);
+ _p11_debug ("out: %lu", rv);
return rv;
}
@@ -309,9 +309,11 @@ proxy_C_Initialize (CK_VOID_PTR init_args)
{
CK_RV rv;
+ _p11_library_init_once ();
+
/* WARNING: This function must be reentrant */
- debug ("in");
+ _p11_debug ("in");
_p11_lock ();
@@ -324,12 +326,12 @@ proxy_C_Initialize (CK_VOID_PTR init_args)
_p11_unlock ();
- debug ("here");
+ _p11_debug ("here");
if (rv != CKR_OK)
proxy_C_Finalize (NULL);
- debug ("out: %lu", rv);
+ _p11_debug ("out: %lu", rv);
return rv;
}
@@ -338,6 +340,8 @@ proxy_C_GetInfo (CK_INFO_PTR info)
{
CK_RV rv = CKR_OK;
+ _p11_library_init_once ();
+
if (info == NULL)
return CKR_ARGUMENTS_BAD;
diff --git a/p11-kit/uri.c b/p11-kit/uri.c
index e9989c8..ffcf6cc 100644
--- a/p11-kit/uri.c
+++ b/p11-kit/uri.c
@@ -1420,7 +1420,7 @@ p11_kit_uri_message (int code)
case P11_KIT_URI_NOT_FOUND:
return "The URI component was not found";
default:
- debug ("unknown error code: %d", code);
+ _p11_debug ("unknown error code: %d", code);
return "Unknown error";
}
}