[mthca] Fix a build break. [mlnx: 4411]
authorleonidk <leonidk@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Tue, 2 Jun 2009 17:51:04 +0000 (17:51 +0000)
committerleonidk <leonidk@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Tue, 2 Jun 2009 17:51:04 +0000 (17:51 +0000)
git-svn-id: svn://openib.tc.cornell.edu/gen1/trunk@2230 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86

hw/mthca/kernel/SOURCES
hw/mthca/kernel/hca_debug.h
hw/mthca/kernel/mt_device.c

index f653d22..269da79 100644 (file)
@@ -73,6 +73,7 @@ INCLUDES=\
 C_DEFINES=$(C_DEFINES) -DDRIVER -DDEPRECATE_DDK_FUNCTIONS -D__LITTLE_ENDIAN\r
 \r
 TARGETLIBS= \\r
+        $(DDK_LIB_PATH)\ntstrsafe.lib   \\r
        $(TARGETPATH)\*\complib.lib     \\r
        $(DDK_LIB_PATH)\wdmguid.lib\r
 \r
index 924b36d..62a016c 100644 (file)
@@ -33,6 +33,7 @@
 #ifndef  _HCA_DEBUG_H_\r
 #define _HCA_DEBUG_H_\r
 \r
+#include <ntstrsafe.h>\r
 \r
 extern uint32_t                g_mthca_dbg_level;\r
 extern uint32_t                g_mthca_dbg_flags;\r
@@ -42,10 +43,18 @@ extern UCHAR g_slog_buf[ MAX_LOG_BUF_LEN ];
 \r
 static void _build_str( const char *   format, ... )\r
 {\r
+       NTSTATUS status;\r
        va_list p_arg;\r
        va_start(p_arg, format);\r
-       vsprintf((char *)g_slog_buf , format , p_arg);\r
-       swprintf(g_wlog_buf, L"%S", g_slog_buf);\r
+       status = RtlStringCbVPrintfA((char *)g_slog_buf, sizeof(g_slog_buf), format , p_arg);\r
+       if (status)\r
+               goto end;\r
+\r
+       status = RtlStringCchPrintfW(g_wlog_buf, sizeof(g_wlog_buf)/sizeof(g_wlog_buf[0]), L"%S", g_slog_buf);\r
+       if (status)\r
+               goto end;\r
+\r
+end:\r
        va_end(p_arg);\r
 }\r
 \r
index 5274569..883c986 100644 (file)
@@ -140,16 +140,18 @@ static int alloc_name(char *name)
                        continue;
                if (i < 0 || i >= PAGE_SIZE * 8)
                        continue;
-               snprintf(buf, sizeof(buf)-1, name, i);
-               buf[sizeof(buf)-1] = '\0';
+               if (RtlStringCbPrintfA(buf, sizeof buf, name, i))
+                       return -EINVAL;
+
                if (!strncmp(buf, device->name, IB_DEVICE_NAME_MAX))
                        set_bit(i, inuse);
        }
 
        i = find_first_zero_bit((const unsigned long *)inuse, PAGE_SIZE * 8);
        free_page(inuse);
-       snprintf(buf, sizeof(buf)-1, name, i);
-       buf[sizeof(buf)-1] = '\0';
+       if (RtlStringCbPrintfA(buf, sizeof buf, name, i))
+                       return -EINVAL;
+
 
        if (__ib_device_get_by_name(buf))
                return -ENFILE;