]> git.openfabrics.org - ~shefty/rdma-win.git/commitdiff
[MLX4] Enable Event Log writing on DISPATCH_LEVEL
authorleonidk <leonidk@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Thu, 25 Sep 2008 14:00:11 +0000 (14:00 +0000)
committerleonidk <leonidk@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Thu, 25 Sep 2008 14:00:11 +0000 (14:00 +0000)
The patch replaces a standard buffer conversion function, requiring PASSIVE_LEVEL, by a home-made one, which doesn't.
It prevents reported crash upon fatal error handling.

git-svn-id: svn://openib.tc.cornell.edu/gen1@1618 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86

branches/WOF2-0/trunk/hw/mlx4/kernel/bus/core/l2w_debug.c

index 60843030548dfeeeef6d0528309fd2ca96692ff5..c2dd7a2422a93740f6f658a4eb1d099ea74f54d4 100644 (file)
@@ -107,6 +107,16 @@ Return Value:
 
 } /* WriteEventLogEntry */
 
+// bsize is to be a strlen(src)
+// dest has to have enough place, i.e at least (2*strlen(src) + 2)
+void __ansi_to_wchar( USHORT *dest, UCHAR *src, int bsize)
+{
+       int i;
+
+       for (i=0; i<bsize; ++i)
+               *dest++ = *src++;
+       *dest = 0;
+}
 
 VOID
 mlx4_err(
@@ -122,13 +132,15 @@ mlx4_err(
        // print to Debugger
        va_start(list, format);
        buf[MAX_BUFFER_SIZE - 1] = '\0';
-       RtlStringCbVPrintfA( (char*)buf, sizeof(buf), format, list);
+       if (RtlStringCbVPrintfA( (char*)buf, sizeof(buf), format, list))
+               return;
        DbgPrint( (char*)buf );
        va_end(list);
 
        // print to Event Log
-       if (!RtlStringCchPrintfW(wbuf, sizeof(wbuf)/sizeof(wbuf[0]), L"%S", buf))
-               WriteEventLogEntryStr( mdev->pdev->p_self_do, (ULONG)EVENT_MLX4_ANY_ERROR, 0, 0, wbuf, 0, 0 ); 
+       // print to Event Log
+       __ansi_to_wchar( wbuf, buf, (int)strlen((void*)buf) );
+       WriteEventLogEntryStr( mdev->pdev->p_self_do, (ULONG)EVENT_MLX4_ANY_ERROR, 0, 0, wbuf, 0, 0 ); 
 }
 
 VOID