[ofw][patch][CORE] bugfix in debug prints
Leonid Keller
leonid at mellanox.co.il
Sun Jan 25 01:22:31 PST 2009
Applied in 1880
________________________________
From: ofw-bounces at lists.openfabrics.org
[mailto:ofw-bounces at lists.openfabrics.org] On Behalf Of Leonid Keller
Sent: Sunday, January 18, 2009 6:23 PM
To: ofw at lists.openfabrics.org
Subject: [ofw][patch][CORE] bugfix in debug prints
On x86 platform casting expression like
(LONG_PTR)p_obj
doesn't increase the size of pointer.
As a result printf() function - driven by %I64 size modifier -
takes the next parameter as a second part of the previous one.
It causes a corrupted print at least and a crash at most.
The patch replaces %I64Ix fixed-size format modifier by the
variable-sized %p one.
Index: core/al/al_common.c
===================================================================
--- core/al/al_common.c (revision 1835)
+++ core/al/al_common.c (working copy)
@@ -180,7 +180,7 @@
CL_ASSERT( p_obj && pfn_free );
CL_ASSERT( p_obj->state == CL_UNINITIALIZED );
AL_PRINT( TRACE_LEVEL_INFORMATION, AL_DBG_AL_OBJ,
- ("%016I64x\n", (LONG_PTR)p_obj ) );
+ ("%p\n", p_obj ) );
/* Initialize the object. */
p_obj->async_item.pfn_callback = async_destroy_cb;
@@ -278,9 +278,9 @@
CL_ASSERT( p_child_obj->state == CL_INITIALIZED );
AL_PRINT( TRACE_LEVEL_INFORMATION, AL_DBG_AL_OBJ,
- ("%016I64x(%s) to %016I64x(%s)\n",
- (LONG_PTR)p_child_obj, ib_get_obj_type( p_child_obj ),
- (LONG_PTR)p_parent_obj, ib_get_obj_type( p_parent_obj ) ) );
+ ("%p(%s) to %p(%s)\n",
+ p_child_obj, ib_get_obj_type( p_child_obj ),
+ p_parent_obj, ib_get_obj_type( p_parent_obj ) ) );
/* Insert the object into the parent's object tracking list.
*/
p_child_obj->p_ci_ca = p_parent_obj->p_ci_ca;
@@ -347,9 +347,9 @@
p_parent_obj->state == CL_DESTROYING );
AL_PRINT( TRACE_LEVEL_INFORMATION, AL_DBG_AL_OBJ,
- ("%016I64x(%s) from %016I64x(%s)\n",
- (LONG_PTR)p_obj, ib_get_obj_type( p_obj ),
- (LONG_PTR)p_parent_obj, ib_get_obj_type( p_parent_obj ) ) );
+ ("%p(%s) from %p(%s)\n",
+ p_obj, ib_get_obj_type( p_obj ),
+ p_parent_obj, ib_get_obj_type( p_parent_obj ) ) );
/* Remove the object from the parent's list. */
cl_spinlock_acquire( &p_parent_obj->lock );
@@ -373,7 +373,7 @@
AL_ENTER( AL_DBG_AL_OBJ );
AL_PRINT( TRACE_LEVEL_INFORMATION, AL_DBG_AL_OBJ,
- ("%016I64x(%s)\n", (LONG_PTR)p_obj, ib_get_obj_type( p_obj )
) );
+ ("%p(%s)\n", p_obj, ib_get_obj_type( p_obj ) ) );
ref_cnt = cl_atomic_inc( &p_obj->ref_cnt );
CL_ASSERT( ref_cnt != 1 || p_obj->type == AL_OBJ_TYPE_H_CQ );
@@ -401,7 +401,7 @@
CL_ASSERT( p_obj->ref_cnt );
AL_PRINT( TRACE_LEVEL_INFORMATION, AL_DBG_AL_OBJ,
- ("%016I64x(%s)\n", (LONG_PTR)p_obj, ib_get_obj_type( p_obj )
) );
+ ("%p(%s)\n", p_obj, ib_get_obj_type( p_obj ) ) );
ref_cnt = cl_atomic_dec( &p_obj->ref_cnt );
@@ -569,7 +569,7 @@
p_obj->state == CL_DESTROYING );
AL_PRINT( TRACE_LEVEL_INFORMATION, AL_DBG_AL_OBJ,
- ("%016I64x(%s)\n", (LONG_PTR)p_obj, ib_get_obj_type( p_obj )
) );
+ ("%p(%s)\n", p_obj, ib_get_obj_type( p_obj ) ) );
/*
* Lock to synchronize with asynchronous event processing.
@@ -614,7 +614,7 @@
p_child_obj = PARENT_STRUCT( p_list_item, al_obj_t, pool_item
);
CL_ASSERT( p_child_obj->pfn_destroy );
AL_PRINT( TRACE_LEVEL_INFORMATION, AL_DBG_AL_OBJ,
- ("bye bye: %016I64x(%s)\n", (LONG_PTR)p_child_obj,
+ ("bye bye: %p(%s)\n", p_child_obj,
ib_get_obj_type( p_child_obj ) ) );
ref_al_obj( p_child_obj );
p_child_obj->pfn_destroy( p_child_obj, NULL );
@@ -659,7 +659,7 @@
CL_ASSERT( !p_obj->ref_cnt );
AL_PRINT( TRACE_LEVEL_INFORMATION, AL_DBG_AL_OBJ,
- ("%016I64x\n", (LONG_PTR)p_obj ) );
+ ("%p\n", p_obj ) );
/* Cleanup any hardware related resources. */
if( p_obj->pfn_cleanup )
Index: core/al/al_common.h
===================================================================
--- core/al/al_common.h (revision 1835)
+++ core/al/al_common.h (working copy)
@@ -326,7 +326,7 @@
ib_get_obj_type(
IN al_obj_t * const p_obj )
{
- if( AL_BASE_TYPE( p_obj->type ) > AL_OBJ_TYPE_INVALID )
+ if( AL_BASE_TYPE( p_obj->type ) >= AL_OBJ_TYPE_INVALID )
return( ib_obj_type_str[AL_OBJ_TYPE_UNKNOWN] );
return( ib_obj_type_str[ AL_BASE_TYPE( p_obj->type ) ] );
Index: core/al/al_mad.c
===================================================================
--- core/al/al_mad.c (revision 1835)
+++ core/al/al_mad.c (working copy)
@@ -680,13 +680,13 @@
cl_ptr_vector_set( p_method_ptr_vector, i, h_mad_reg );
AL_PRINT( TRACE_LEVEL_INFORMATION, AL_DBG_MAD_SVC,
- ("Register version:%u (%u) class:0x%02X(%u) method:0x%02X
Hdl:%016I64x\n",
+ ("Register version:%u (%u) class:0x%02X(%u) method:0x%02X
Hdl:%p\n",
p_mad_svc->mgmt_version,
__mgmt_version_index( p_mad_svc->mgmt_version ),
p_mad_svc->mgmt_class,
__mgmt_class_index( p_mad_svc->mgmt_class ),
i,
- (LONG_PTR)h_mad_reg) );
+ h_mad_reg) );
}
}
@@ -841,7 +841,7 @@
AL_ENTER( AL_DBG_MAD_SVC );
AL_PRINT( TRACE_LEVEL_INFORMATION, AL_DBG_MAD_SVC,
- ("p_mad_wr 0x%016I64x\n", (LONG_PTR)p_mad_wr ) );
+ ("p_mad_wr 0x%p\n", p_mad_wr ) );
/* Get the MAD header. */
p_mad_hdr = get_mad_hdr_from_wr( p_mad_wr );
Index: core/al/kernel/al_dev.c
===================================================================
--- core/al/kernel/al_dev.c (revision 1835)
+++ core/al/kernel/al_dev.c (working copy)
@@ -443,8 +443,8 @@
p_open_context = p_io_stack->FileObject->FsContext;
AL_PRINT( TRACE_LEVEL_INFORMATION, AL_DBG_DEV,
- ("al_dev_ioctl: buf_size (%d) p_buf (%016I64x).\n",
- cl_ioctl_in_size( h_ioctl ), (LONG_PTR)cl_ioctl_in_buf(
h_ioctl )) );
+ ("al_dev_ioctl: buf_size (%d) p_buf (%p).\n",
+ cl_ioctl_in_size( h_ioctl ), cl_ioctl_in_buf( h_ioctl )) );
/* Process the ioctl command. */
if( IS_AL_PROXY_IOCTL(cl_ioctl_ctl_code( h_ioctl )) )
Index: core/al/kernel/al_mad_pool.c
===================================================================
--- core/al/kernel/al_mad_pool.c (revision 1835)
+++ core/al/kernel/al_mad_pool.c (working copy)
@@ -271,7 +271,7 @@
if( busy )
{
AL_PRINT( TRACE_LEVEL_ERROR, AL_DBG_ERROR,
- ("h_pool (0x%016I64x) is busy!.\n",
(ULONG64)(ULONG_PTR)h_pool) );
+ ("h_pool (0x%p) is busy!.\n", h_pool) );
return IB_RESOURCE_BUSY;
}
Index: core/al/kernel/al_proxy.c
===================================================================
--- core/al/kernel/al_proxy.c (revision 1835)
+++ core/al/kernel/al_proxy.c (working copy)
@@ -301,8 +301,8 @@
if( (uintn_t)p_io_stack->FileObject->FsContext2 !=
AL_OBJ_TYPE_H_CQ )
{
AL_PRINT_EXIT( TRACE_LEVEL_ERROR, AL_DBG_ERROR,
- ("Invalid file object type for request: %016I64x\n",
- (LONG_PTR)p_io_stack->FileObject->FsContext2) );
+ ("Invalid file object type for request: %p\n",
+ p_io_stack->FileObject->FsContext2) );
return CL_INVALID_PARAMETER;
}
@@ -343,8 +343,8 @@
if( (uintn_t)p_io_stack->FileObject->FsContext2 !=
AL_OBJ_TYPE_AL_MGR )
{
AL_PRINT_EXIT( TRACE_LEVEL_ERROR, AL_DBG_ERROR,
- ("Invalid file object type for request: %016I64x\n",
- (LONG_PTR)p_io_stack->FileObject->FsContext2) );
+ ("Invalid file object type for request: %p\n",
+ p_io_stack->FileObject->FsContext2) );
return CL_INVALID_PARAMETER;
}
@@ -891,8 +891,8 @@
if( (uintn_t)p_io_stack->FileObject->FsContext2 !=
AL_OBJ_TYPE_PNP_MGR )
{
AL_PRINT_EXIT( TRACE_LEVEL_ERROR, AL_DBG_ERROR,
- ("Invalid file object type for request: %016I64x\n",
- (LONG_PTR)p_io_stack->FileObject->FsContext2) );
+ ("Invalid file object type for request: %p\n",
+ p_io_stack->FileObject->FsContext2) );
return CL_INVALID_PARAMETER;
}
@@ -1035,8 +1035,8 @@
if( (uintn_t)p_io_stack->FileObject->FsContext2 !=
AL_OBJ_TYPE_PNP_MGR )
{
AL_PRINT_EXIT( TRACE_LEVEL_ERROR, AL_DBG_ERROR,
- ("Invalid file object type for request: %016I64x\n",
- (LONG_PTR)p_io_stack->FileObject->FsContext2) );
+ ("Invalid file object type for request: %p\n",
+ p_io_stack->FileObject->FsContext2) );
return CL_INVALID_PARAMETER;
}
@@ -1117,8 +1117,8 @@
if( (uintn_t)p_io_stack->FileObject->FsContext2 !=
AL_OBJ_TYPE_PNP_MGR )
{
AL_PRINT_EXIT( TRACE_LEVEL_ERROR, AL_DBG_ERROR,
- ("Invalid file object type for request: %016I64x\n",
- (LONG_PTR)p_io_stack->FileObject->FsContext2) );
+ ("Invalid file object type for request: %p\n",
+ p_io_stack->FileObject->FsContext2) );
return CL_INVALID_PARAMETER;
}
Index: core/al/kernel/al_proxy_cep.c
===================================================================
--- core/al/kernel/al_proxy_cep.c (revision 1835)
+++ core/al/kernel/al_proxy_cep.c (working copy)
@@ -835,8 +835,8 @@
if( (uintn_t)p_io_stack->FileObject->FsContext2 !=
AL_OBJ_TYPE_CM )
{
AL_PRINT_EXIT( TRACE_LEVEL_ERROR, AL_DBG_ERROR,
- ("Invalid file object type for request: %016I64x\n",
- (LONG_PTR)p_io_stack->FileObject->FsContext2) );
+ ("Invalid file object type for request: %p\n",
+ p_io_stack->FileObject->FsContext2) );
return CL_INVALID_PARAMETER;
}
Index: core/al/kernel/al_proxy_subnet.c
===================================================================
--- core/al/kernel/al_proxy_subnet.c (revision 1835)
+++ core/al/kernel/al_proxy_subnet.c (working copy)
@@ -230,8 +230,8 @@
(uintn_t)p_io_stack->FileObject->FsContext2 !=
AL_OBJ_TYPE_SA_REQ_SVC )
{
AL_PRINT_EXIT( TRACE_LEVEL_ERROR, AL_DBG_ERROR,
- ("Invalid file object type for request: %016I64x\n",
- (LONG_PTR)p_io_stack->FileObject->FsContext2) );
+ ("Invalid file object type for request: %p\n",
+ p_io_stack->FileObject->FsContext2) );
return CL_INVALID_PARAMETER;
}
Index: core/al/kernel/al_smi.c
===================================================================
--- core/al/kernel/al_smi.c (revision 1835)
+++ core/al/kernel/al_smi.c (working copy)
@@ -3430,8 +3430,8 @@
if( status != IB_SUCCESS )
{
AL_PRINT( TRACE_LEVEL_ERROR, AL_DBG_ERROR,
- ("Failed to post receive %016I64x\n",
- (LONG_PTR)p_al_element) );
+ ("Failed to post receive %p\n",
+ p_al_element) );
cl_qlist_remove_item( &p_spl_qp_svc->recv_queue,
&p_al_element->list_item );
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openfabrics.org/pipermail/ofw/attachments/20090125/ac6dde05/attachment.html>
More information about the ofw
mailing list