Cleanup log_printf to use gnu attributes to do automatic type checking.

git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@1166 fd59a12c-fef9-0310-b244-a6a79926bd2f
This commit is contained in:
Steven Dake 2006-07-26 07:39:53 +00:00
parent 6b8e9e6264
commit 806258b5c3
14 changed files with 815 additions and 797 deletions

View File

@ -507,7 +507,7 @@ static void message_handler_req_exec_amf_clc_cleanup_completed (
comp = amf_comp_find (amf_cluster, &req_exec->compName);
if (comp == NULL) {
log_printf (LOG_ERR, "'%s' not found", &req_exec->compName.value);
log_printf (LOG_ERR, "'%s' not found", req_exec->compName.value);
return;
}
@ -523,7 +523,7 @@ static void message_handler_req_exec_amf_healthcheck_tmo (
comp = amf_comp_find (amf_cluster, &req_exec->compName);
if (comp == NULL) {
log_printf (LOG_ERR, "'%s' not found", &req_exec->compName.value);
log_printf (LOG_ERR, "'%s' not found", req_exec->compName.value);
return;
}
@ -567,7 +567,7 @@ static void message_handler_req_lib_amf_componentregister (
struct iovec iovec;
struct amf_pd *amf_pd = openais_conn_private_data_get (conn);
TRACE2("Lib comp register '%s'", &req_lib->compName.value);
TRACE2("Lib comp register '%s'", req_lib->compName.value);
comp->conn = conn;
amf_pd->comp = comp;
req_exec.header.size = sizeof (struct req_exec_amf_comp_register);
@ -582,7 +582,7 @@ static void message_handler_req_lib_amf_componentregister (
&iovec, 1, TOTEMPG_AGREED) == 0);
} else {
struct res_lib_amf_componentregister res_lib;
log_printf (LOG_ERR, "Lib comp register: comp '%s' not found", &req_lib->compName.value);
log_printf (LOG_ERR, "Lib comp register: comp '%s' not found", req_lib->compName.value);
res_lib.header.id = MESSAGE_RES_AMF_COMPONENTREGISTER;
res_lib.header.size = sizeof (struct res_lib_amf_componentregister);
res_lib.header.error = SA_AIS_ERR_INVALID_PARAM;
@ -869,7 +869,7 @@ static void message_handler_req_lib_amf_componenterrorreport (
struct req_exec_amf_comp_error_report req_exec;
struct iovec iovec;
TRACE2("Lib comp error report for '%s'", &comp->name.value);
TRACE2("Lib comp error report for '%s'", comp->name.value);
req_exec.header.size = sizeof (struct req_exec_amf_comp_error_report);
req_exec.header.id = SERVICE_ID_MAKE (AMF_SERVICE,
@ -895,7 +895,7 @@ static void message_handler_req_lib_amf_componenterrorreport (
struct res_lib_amf_componenterrorreport res_lib;
log_printf (LOG_ERR, "Component %s not found",
&req_lib->erroneousComponent.value);
req_lib->erroneousComponent.value);
res_lib.header.size = sizeof (struct res_lib_amf_componenterrorreport);
res_lib.header.id = MESSAGE_RES_AMF_COMPONENTERRORREPORT;
res_lib.header.error = SA_AIS_ERR_NOT_EXIST;

View File

@ -1130,7 +1130,7 @@ static void lib_csi_set_request (
SaAisErrorT amf_comp_register (struct amf_comp *comp)
{
TRACE2("Exec comp register '%s'", &comp->name.value);
TRACE2("Exec comp register '%s'", comp->name.value);
if (comp->saAmfCompPresenceState == SA_AMF_PRESENCE_RESTARTING) {
comp_presence_state_set (comp, SA_AMF_PRESENCE_INSTANTIATED);
@ -1150,7 +1150,7 @@ void amf_comp_error_report (
{
struct res_lib_amf_componenterrorreport res_lib;
TRACE2("Exec comp error report '%s'", &comp->name.value);
TRACE2("Exec comp error report '%s'", comp->name.value);
if (amf_su_is_local (comp->su)) {
res_lib.header.size = sizeof (struct res_lib_amf_componenterrorreport);
@ -1171,7 +1171,7 @@ void amf_comp_error_report (
void amf_comp_healthcheck_tmo (
struct amf_comp *comp, struct amf_healthcheck *healthcheck)
{
TRACE2("Exec healthcheck tmo for '%s'", &comp->name.value);
TRACE2("Exec healthcheck tmo for '%s'", comp->name.value);
/* report to SU and let it handle the problem */
report_error_suspected (comp, healthcheck->recommendedRecovery);
@ -1190,7 +1190,7 @@ static void clear_ha_state (
*/
void amf_comp_cleanup_completed (struct amf_comp *comp)
{
TRACE2("Exec CLC cleanup completed for '%s'", &comp->name.value);
TRACE2("Exec CLC cleanup completed for '%s'", comp->name.value);
/* Set all CSI's confirmed HA state to unknown */
amf_comp_foreach_csi_assignment (comp, clear_ha_state);

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -155,6 +155,7 @@ static int response_init_send_response (
void *message)
{
SaAisErrorT error = SA_AIS_ERR_ACCESS;
size_t cinfo = (size_t)conn_info;
mar_req_lib_response_init_t *req_lib_response_init = (mar_req_lib_response_init_t *)message;
mar_res_lib_response_init_t res_lib_response_init;
@ -165,7 +166,7 @@ static int response_init_send_response (
res_lib_response_init.header.size = sizeof (mar_res_lib_response_init_t);
res_lib_response_init.header.id = MESSAGE_RES_INIT;
res_lib_response_init.header.error = error;
res_lib_response_init.conn_info = (unsigned long long)conn_info;
res_lib_response_init.conn_info = (mar_uint64_t)cinfo;
openais_conn_send_response (
conn_info,
@ -184,6 +185,7 @@ static int dispatch_init_send_response (
void *message)
{
SaAisErrorT error = SA_AIS_ERR_ACCESS;
size_t cinfo;
mar_req_lib_dispatch_init_t *req_lib_dispatch_init = (mar_req_lib_dispatch_init_t *)message;
mar_res_lib_dispatch_init_t res_lib_dispatch_init;
struct conn_info *msg_conn_info;
@ -195,10 +197,11 @@ static int dispatch_init_send_response (
else
error = SA_AIS_OK;
conn_info->conn_info_partner = (struct conn_info *)req_lib_dispatch_init->conn_info;
cinfo = (size_t)req_lib_dispatch_init->conn_info;
conn_info->conn_info_partner = (struct conn_info *)cinfo;
conn_info->conn_info_partner->shared_mutex = conn_info->shared_mutex;
msg_conn_info = (struct conn_info *)req_lib_dispatch_init->conn_info;
msg_conn_info = (struct conn_info *)cinfo;
msg_conn_info->conn_info_partner = conn_info;
if (error == SA_AIS_OK) {

View File

@ -69,7 +69,7 @@ enum lck_message_req_types {
MESSAGE_REQ_EXEC_LCK_RESOURCELOCK = 2,
MESSAGE_REQ_EXEC_LCK_RESOURCEUNLOCK = 3,
MESSAGE_REQ_EXEC_LCK_RESOURCELOCKORPHAN = 4,
MESSAGE_REQ_EXEC_LCK_LOCKPURGE = 5
MESSAGE_REQ_EXEC_LCK_LOCKPURGE = 5
};
struct resource;
@ -312,7 +312,7 @@ struct openais_service_handler lck_service_handler = {
.exec_service_count = sizeof (lck_exec_service) / sizeof (struct openais_exec_handler),
.exec_dump_fn = NULL,
.confchg_fn = lck_confchg_fn,
.sync_init = NULL,
.sync_init = NULL,
// .sync_init = lck_sync_init,
.sync_process = lck_sync_process,
.sync_activate = lck_sync_activate,
@ -490,23 +490,23 @@ static void exec_lck_lockpurge_endian_convert (void *msg)
}
#ifdef TODO
static void lck_sync_init (void)
static void lck_sync_init (void)
{
return;
}
#endif
static int lck_sync_process (void)
static int lck_sync_process (void)
{
return (0);
}
static void lck_sync_activate (void)
{
return;
static void lck_sync_activate (void)
{
return;
}
static void lck_sync_abort (void)
static void lck_sync_abort (void)
{
return;
}
@ -516,7 +516,7 @@ static void lck_confchg_fn (
unsigned int *member_list, int member_list_entries,
unsigned int *left_list, int left_list_entries,
unsigned int *joined_list, int joined_list_entries,
struct memb_ring_id *ring_id)
struct memb_ring_id *ring_id)
{
}
@ -581,7 +581,7 @@ struct resource_cleanup *lck_resource_cleanup_find (
}
return (0);
}
int lck_resource_close (struct resource *resource)
{
@ -652,7 +652,7 @@ void lck_resource_cleanup_remove (
void *conn,
SaLckResourceHandleT resource_handle)
{
struct list_head *list;
struct resource_cleanup *resource_cleanup;
struct lck_pd *lck_pd = (struct lck_pd *)openais_conn_private_data_get (conn);
@ -686,25 +686,25 @@ static int lck_lib_exit_fn (void *conn)
struct resource_cleanup *resource_cleanup;
struct list_head *cleanup_list;
struct lck_pd *lck_pd = (struct lck_pd *)openais_conn_private_data_get (conn);
log_printf(LOG_LEVEL_NOTICE, "lck_exit_fn conn_info %p\n", conn);
/*
* close all resources opened on this fd
*/
cleanup_list = lck_pd->resource_cleanup_list.next;
while (!list_empty(cleanup_list)) {
resource_cleanup = list_entry (cleanup_list, struct resource_cleanup, list);
if (resource_cleanup->resource->name.length > 0) {
if (resource_cleanup->resource->name.length > 0) {
lck_resource_cleanup_lock_remove (resource_cleanup);
lck_resource_close (resource_cleanup->resource);
}
list_del (&resource_cleanup->list);
list_del (&resource_cleanup->list);
free (resource_cleanup);
cleanup_list = lck_pd->resource_cleanup_list.next;
}
@ -791,8 +791,8 @@ static void message_handler_req_exec_lck_resourceopen (
}
resource->refcount += 1;
}
/*
* Send error result to LCK library
*/
@ -856,7 +856,7 @@ static void message_handler_req_exec_lck_resourceclose (
if (resource == 0) {
goto error_exit;
}
resource->refcount -= 1;
if (resource->refcount == 0) {
}
@ -976,12 +976,12 @@ void lock_queue (
* Add lock to the list
*/
if (resource_lock->lock_mode == SA_LCK_PR_LOCK_MODE) {
list_add_tail (&resource_lock->list,
list_add_tail (&resource_lock->list,
&resource->pr_pending_list_head);
waiter_notification_send (resource->ex_granted);
} else
if (resource_lock->lock_mode == SA_LCK_EX_LOCK_MODE) {
list_add_tail (&resource_lock->list,
list_add_tail (&resource_lock->list,
&resource->ex_pending_list_head);
waiter_notification_list_send (&resource->pr_granted_list_head);
}
@ -995,7 +995,7 @@ The algorithm:
if ex lock granted
if ex pending list has locks
send waiter notification to ex lock granted
send waiter notification to ex lock granted
else
if ex pending list has locks
if pr granted list has locks
@ -1044,13 +1044,13 @@ void lock_algorithm (
}
/*
* if lock in ex, set ex to null
* if lock in ex, set ex to null
* delete resource lock from list
*
*
* if ex lock not granted
* if ex pending list has locks
* if ex pending list has locks
* grant first ex pending list lock to ex lock
* if ex lock not granted
* if ex lock not granted
* if pr pending list has locks
* assign all pr pending locks to pr granted lock list
*/
@ -1102,7 +1102,7 @@ void unlock_algorithm (
*/
if (resource->ex_granted == 0) {
if (list_empty (&resource->pr_pending_list_head) == 0) {
/*
/*
* assign all pr pending locks to pr granted lock list
*/
@ -1122,7 +1122,7 @@ void unlock_algorithm (
/*
* Add pending locks to granted list
*/
list_p = &resource->pr_pending_list_head.next;
list_p = resource->pr_pending_list_head.next;
list_del (&resource->pr_pending_list_head);
list_add_tail (list_p,
&resource->pr_granted_list_head);
@ -1183,7 +1183,7 @@ static void message_handler_req_exec_lck_resourcelock (
req_exec_lck_resourcelock->req_lib_lck_resourcelock.async_call;
resource_lock->invocation =
req_exec_lck_resourcelock->req_lib_lck_resourcelock.invocation;
/*
* Waiter callback source
*/
@ -1202,7 +1202,7 @@ static void message_handler_req_exec_lck_resourcelock (
req_exec_lck_resourcelock->resource_handle);
assert (resource_cleanup);
list_add (&resource_lock->resource_cleanup_list,
&resource_cleanup->resource_lock_list_head);
@ -1211,7 +1211,7 @@ static void message_handler_req_exec_lck_resourcelock (
*/
if (resource_lock->lock_status != SA_LCK_LOCK_NO_STATUS) {
/*
* If lock granted or denied, deliver callback or
* If lock granted or denied, deliver callback or
* response to library for non-async calls
*/
lock_response_deliver (
@ -1249,8 +1249,8 @@ static void message_handler_req_exec_lck_resourceunlock (
struct req_exec_lck_resourceunlock *req_exec_lck_resourceunlock = (struct req_exec_lck_resourceunlock *)message;
struct res_lib_lck_resourceunlock res_lib_lck_resourceunlock;
struct res_lib_lck_resourceunlockasync res_lib_lck_resourceunlockasync;
struct resource *resource = 0;
struct resource_lock *resource_lock = 0;
struct resource *resource = NULL;
struct resource_lock *resource_lock = NULL;
SaAisErrorT error = SA_AIS_OK;
log_printf (LOG_LEVEL_NOTICE, "EXEC request: saLckResourceUnlock %s\n",
@ -1339,7 +1339,7 @@ static void message_handler_req_exec_lck_lockpurge (
if (resource == 0) {
goto error_exit;
}
error_exit:
if (message_source_is_local(&req_exec_lck_lockpurge->source)) {
// lck_resource_cleanup_remove (req_exec_lck_lockpurge->source.conn,
@ -1374,7 +1374,7 @@ static void message_handler_req_lib_lck_resourceopen (
memcpy (&req_exec_lck_resourceopen.resource_name,
&req_lib_lck_resourceopen->lockResourceName,
sizeof (SaNameT));
req_exec_lck_resourceopen.open_flags = req_lib_lck_resourceopen->resourceOpenFlags;
req_exec_lck_resourceopen.async_call = 0;
req_exec_lck_resourceopen.invocation = 0;
@ -1488,7 +1488,7 @@ static void message_handler_req_lib_lck_resourcelock (
memcpy (&req_exec_lck_resourcelock.req_lib_lck_resourcelock,
req_lib_lck_resourcelock,
sizeof (struct req_lib_lck_resourcelock));
req_exec_lck_resourcelock.resource_handle = req_lib_lck_resourcelock->resourceHandle;
req_exec_lck_resourcelock.async_call = 0;
req_exec_lck_resourcelock.invocation = 0;
@ -1521,7 +1521,7 @@ static void message_handler_req_lib_lck_resourcelockasync (
memcpy (&req_exec_lck_resourcelock.req_lib_lck_resourcelock,
req_lib_lck_resourcelock,
sizeof (struct req_lib_lck_resourcelock));
req_exec_lck_resourcelock.resource_handle = req_lib_lck_resourcelock->resourceHandle;
req_exec_lck_resourcelock.async_call = 1;
req_exec_lck_resourcelock.invocation = req_lib_lck_resourcelock->invocation;
@ -1617,7 +1617,7 @@ static void message_handler_req_lib_lck_lockpurge (
memcpy (&req_exec_lck_lockpurge.req_lib_lck_lockpurge,
req_lib_lck_lockpurge,
sizeof (struct req_lib_lck_lockpurge));
iovecs[0].iov_base = (char *)&req_exec_lck_lockpurge;
iovecs[0].iov_len = sizeof (req_exec_lck_lockpurge);

View File

@ -218,7 +218,7 @@ static void aisexec_gid_determine (struct main_config *main_config)
struct group *group;
group = getgrnam (main_config->group);
if (group == 0) {
log_printf (LOG_LEVEL_ERROR, "ERROR: The '%s' group is not found in /etc/group, please read the documentation.\n", group);
log_printf (LOG_LEVEL_ERROR, "ERROR: The '%s' group is not found in /etc/group, please read the documentation.\n", group->gr_name);
openais_exit_error (AIS_DONE_GID_DETERMINE);
}
gid_valid = group->gr_gid;

View File

@ -1,12 +1,9 @@
/*
* Copyright (c) 2002-2004 MontaVista Software, Inc.
* Copyright (c) 2006 Ericsson AB.
*
* Author: Steven Dake (sdake@mvista.com)
*
* Copyright (c) 2006 Ericsson AB.
* Author: Hans Feldt
* Description: Added support for runtime installed loggers, tags tracing,
* and file & line printing.
* Hans Feldt
*
* All rights reserved.
*

View File

@ -1,6 +1,5 @@
/*
* Copyright (c) 2002-2004 MontaVista Software, Inc.
*
* Author: Steven Dake (sdake@mvista.com)
*
* Copyright (c) 2006 Ericsson AB.
@ -8,6 +7,8 @@
* Description: Added support for runtime installed loggers, tags tracing,
* and file & line printing.
*
* Copyright (c) 2006 Sun Microsystems, Inc.
*
* All rights reserved.
*
* This software licensed under BSD license, the text of which follows:
@ -93,9 +94,9 @@ extern struct logger loggers[];
*/
static int logger_identifier __attribute__((unused));
extern void internal_log_printf (char *file, int line, int priority, char *format, ...);
extern void internal_log_printf2 (char *file, int line, int level, int id, char *format, ...);
extern void trace (char *file, int line, int tag, int id, char *format, ...);
extern void internal_log_printf (char *file, int line, int priority, char *format, ...) __attribute__((format(printf, 4, 5)));
extern void internal_log_printf2 (char *file, int line, int level, int id, char *format, ...) __attribute__((format(printf, 5, 6)));
extern void trace (char *file, int line, int tag, int id, char *format, ...) __attribute__((format(printf, 5, 6)));
extern void log_flush(void);
#define LEVELMASK 0x07 /* 3 bits */

View File

@ -1,10 +1,12 @@
/*
* Copyright (c) 2005 MontaVista Software, Inc.
*
* All rights reserved.
* Copyright (c) 2006 Red Hat, Inc.
* Copyright (c) 2006 Sun Microsystems, Inc.
*
* Author: Steven Dake (sdake@mvista.com)
*
* All rights reserved.
*
* This software licensed under BSD license, the text of which follows:
*
* Redistribution and use in source and binary forms, with or without
@ -71,7 +73,7 @@ struct totem_interface {
};
struct totem_logging_configuration {
void (*log_printf) (char *, int, int, char *, ...);
void (*log_printf) (char *, int, int, char *, ...) __attribute__((format(printf, 4, 5)));
int log_level_security;
int log_level_error;
int log_level_warning;

View File

@ -1,10 +1,12 @@
/*
* Copyright (c) 2005 MontaVista Software, Inc.
* Copyright (c) 2006 Red Hat, Inc.
* Copyright (c) 2006 Sun Microsystems, Inc.
*
* All rights reserved.
*
* Author: Steven Dake (sdake@mvista.com)
*
* This software licensed under BSD license, the text of which follows:
*
* Redistribution and use in source and binary forms, with or without
@ -32,7 +34,6 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <assert.h>
#include <pthread.h>
#include <sys/mman.h>
@ -137,7 +138,7 @@ struct totemnet_instance {
int totemnet_log_level_debug;
void (*totemnet_log_printf) (char *file, int line, int level, char *format, ...);
void (*totemnet_log_printf) (char *file, int line, int level, char *format, ...) __attribute__((format(printf, 4, 5)));
totemnet_handle handle;

View File

@ -1,6 +1,7 @@
/*
* Copyright (c) 2003-2005 MontaVista Software, Inc.
* Copyright (c) 2005 OSDL.
* Copyright (c) 2006 Sun Microsystems, Inc.
*
* All rights reserved.
*
@ -150,7 +151,7 @@ static int totempg_log_level_error;
static int totempg_log_level_warning;
static int totempg_log_level_notice;
static int totempg_log_level_debug;
static void (*totempg_log_printf) (char *file, int line, int level, char *format, ...) = NULL;
static void (*totempg_log_printf) (char *file, int line, int level, char *format, ...) __attribute__((format(printf, 4, 5))) = NULL;
struct totem_config *totempg_totem_config;

View File

@ -1,6 +1,7 @@
/*
* Copyright (c) 2005 MontaVista Software, Inc.
* Copyright (c) 2006 Red Hat, Inc.
* Copyright (c) 2006 Sun Microsystems, Inc.
*
* All rights reserved.
*
@ -33,7 +34,6 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <assert.h>
#include <pthread.h>
#include <sys/mman.h>
@ -194,7 +194,7 @@ struct totemrrp_instance {
int totemrrp_log_level_debug;
void (*totemrrp_log_printf) (char *file, int line, int level, char *format, ...);
void (*totemrrp_log_printf) (char *file, int line, int level, char *format, ...) __attribute__((format(printf, 4, 5)));
totemrrp_handle handle;

View File

@ -1,6 +1,7 @@
/*
* Copyright (c) 2003-2006 MontaVista Software, Inc.
* Copyright (c) 2006 Red Hat, Inc.
* Copyright (c) 2006 Sun Microsystems, Inc.
*
* All rights reserved.
*
@ -423,7 +424,7 @@ struct totemsrp_instance {
int totemsrp_log_level_debug;
void (*totemsrp_log_printf) (char *file, int line, int level, char *format, ...);
void (*totemsrp_log_printf) (char *file, int line, int level, char *format, ...) __attribute__((format(printf, 4, 5)));
enum memb_state memb_state;
@ -1350,7 +1351,7 @@ static void timer_function_orf_token_timeout (void *data)
struct totemsrp_instance *instance = (struct totemsrp_instance *)data;
log_printf (instance->totemsrp_log_level_notice,
"The token was lost in state %d from timer %x\n", instance->memb_state, data);
"The token was lost in state %d from timer %p\n", instance->memb_state, data);
switch (instance->memb_state) {
case MEMB_STATE_OPERATIONAL:
totemrrp_iface_check (instance->totemrrp_handle);
@ -2799,7 +2800,7 @@ static void memb_ring_id_store (
return;
}
log_printf (instance->totemsrp_log_level_notice,
"Storing new sequence id for ring %d\n", commit_token->ring_id.seq);
"Storing new sequence id for ring %llx\n", commit_token->ring_id.seq);
//assert (fd > 0);
res = write (fd, &commit_token->ring_id.seq, sizeof (unsigned long long));
assert (res == sizeof (unsigned long long));