[openib-general] Re: [PATCH] printf fix for dapl/dtest
James Lentini
jlentini at netapp.com
Fri Mar 31 09:59:02 PST 2006
> James,
>
> A fix to dapl/test/dtest/dtest.c to correctly print out the cookie
> on a DTO error.
>
> Signed-off-by: Steve Wise <swise at opengridcomputing.com>
>
>
> Index: dtest.c
> ===================================================================
> --- dtest.c (revision 6031)
> +++ dtest.c (working copy)
> @@ -1155,7 +1155,7 @@
> }
> if
> ((event.event_data.dto_completion_event_data.transfered_length != buf_len ) ||
>
> (event.event_data.dto_completion_event_data.user_cookie.as_64 != 0x9999 )) {
> - fprintf(stderr, "%d: ERROR: DTO len %d or cookie %x\n",
> + fprintf(stderr, "%d: ERROR: DTO len %d or cookie %llx\n",
> getpid(),
>
> event.event_data.dto_completion_event_data.transfered_length,
>
> event.event_data.dto_completion_event_data.user_cookie.as_64 );
It looks like this will fix the problem on 32-bit platforms, but
cause a similar problem on 64-bit platforms.
I put together a fix below. I fixed all the places 64-bit cookie
values were updated and fixed some compiler warnings
Steve, Arlin, do either of you see problems with this? If not, I'll
check it in.
Index: dtest.c
===================================================================
--- dtest.c (revision 5935)
+++ dtest.c (working copy)
@@ -33,6 +33,7 @@
*/
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include <netdb.h>
#include <sys/socket.h>
#include <netinet/in.h>
@@ -40,6 +41,7 @@
#include <arpa/inet.h>
#include <sys/mman.h>
#include <getopt.h>
+#include <inttypes.h>
#ifndef DAPL_PROVIDER
#define DAPL_PROVIDER "OpenIB-ib0"
@@ -546,7 +548,7 @@
if ((event.event_data.dto_completion_event_data.transfered_length != size ) ||
(event.event_data.dto_completion_event_data.user_cookie.as_64 != 0xaaaa )) {
- fprintf(stderr, "%d: ERROR: DTO len %d or cookie %x\n",
+ fprintf(stderr, "%d: ERROR: DTO len %d or cookie " PRIx64 "\n",
getpid(),
event.event_data.dto_completion_event_data.transfered_length,
event.event_data.dto_completion_event_data.user_cookie.as_64 );
@@ -833,7 +835,7 @@
sizeof( DAT_RMR_TRIPLET )) ||
(event.event_data.dto_completion_event_data.user_cookie.as_64 !=
recv_msg_index) ) {
- fprintf(stderr,"ERR recv event: len=%d cookie=%d expected %d/%d\n",
+ fprintf(stderr,"ERR recv event: len=%d cookie=" PRIx64 " expected %d/%d\n",
(int)event.event_data.dto_completion_event_data.transfered_length,
(int)event.event_data.dto_completion_event_data.user_cookie.as_64,
sizeof(DAT_RMR_TRIPLET), recv_msg_index );
@@ -1045,7 +1047,7 @@
if ( (event.event_data.dto_completion_event_data.transfered_length != sizeof( DAT_RMR_TRIPLET )) ||
(event.event_data.dto_completion_event_data.user_cookie.as_64 != recv_msg_index) ) { +
- fprintf(stderr,"unexpected event data for receive: len=%d cookie=%d exp %d/%d\n",
+ fprintf(stderr,"unexpected event data for receive: len=%d cookie=" PRIx64 " exp %d/%d\n",
(int)event.event_data.dto_completion_event_data.transfered_length,
(int)event.event_data.dto_completion_event_data.user_cookie.as_64,
sizeof(DAT_RMR_TRIPLET), recv_msg_index );
@@ -1155,7 +1157,7 @@
}
if ((event.event_data.dto_completion_event_data.transfered_length != buf_len ) ||
(event.event_data.dto_completion_event_data.user_cookie.as_64 != 0x9999 )) {
- fprintf(stderr, "%d: ERROR: DTO len %d or cookie %x\n",
+ fprintf(stderr, "%d: ERROR: DTO len %d or cookie " PRIx64 "\n",
getpid(),
event.event_data.dto_completion_event_data.transfered_length,
event.event_data.dto_completion_event_data.user_cookie.as_64 );
@@ -1237,7 +1239,7 @@
if ( (event.event_data.dto_completion_event_data.transfered_length != sizeof( DAT_RMR_TRIPLET )) ||
(event.event_data.dto_completion_event_data.user_cookie.as_64 != recv_msg_index) ) {
- fprintf(stderr,"unexpected event data for receive: len=%d cookie=%d exp %d/%d\n",
+ fprintf(stderr,"unexpected event data for receive: len=%d cookie=" PRIx64 " exp %d/%d\n",
(int)event.event_data.dto_completion_event_data.transfered_length,
(int)event.event_data.dto_completion_event_data.user_cookie.as_64,
sizeof(DAT_RMR_TRIPLET), recv_msg_index );
@@ -1272,9 +1274,9 @@
DAT_DTO_COOKIE cookie;
DAT_LMR_TRIPLET l_iov;
DAT_RETURN ret;
- int i;
- unsigned char *snd_buf;
- unsigned char *rcv_buf;
+ int i;
+ char *snd_buf;
+ char *rcv_buf;
printf("\n %d PING DATA with SEND MSG\n\n",getpid());
@@ -1389,7 +1391,7 @@
!= buf_len) ||
(event.event_data.dto_completion_event_data.user_cookie.as_64
!= burst_msg_index) ) {
- fprintf(stderr,"ERR: recv event: len=%d cookie=%d exp %d/%d\n",
+ fprintf(stderr,"ERR: recv event: len=%d cookie=" PRIx64 " exp %d/%d\n",
(int)event.event_data.dto_completion_event_data.transfered_length,
(int)event.event_data.dto_completion_event_data.user_cookie.as_64,
buf_len, burst_msg_index );
More information about the general
mailing list