fixed uninitialized variable warning
[reactos.git] / reactos / ntoskrnl / kd / kdio.c
index deecf6a..a15a8b9 100644 (file)
@@ -55,10 +55,9 @@ KdpPrintToLogInternal(PVOID Context)
 
 VOID
 STDCALL
-KdpPrintToLog(PCH String)
+KdpPrintToLog(PCH String,
+              ULONG StringLength)
 {
-    ULONG StringLength = strlen(String);
-
     /* Don't overflow */
     if ((CurrentPosition + StringLength) > BufferSize) return;
 
@@ -89,12 +88,13 @@ STDCALL
 KdpInitDebugLog(PKD_DISPATCH_TABLE DispatchTable,
                 ULONG BootPhase)
 {
-    if (!KdpDebugMode.File) return;
     NTSTATUS Status;
     OBJECT_ATTRIBUTES ObjectAttributes;
     UNICODE_STRING FileName;
     IO_STATUS_BLOCK Iosb;
 
+    if (!KdpDebugMode.File) return;
+
     if (BootPhase == 0)
     {
         /* Write out the functions that we support for now */
@@ -141,7 +141,8 @@ KdpInitDebugLog(PKD_DISPATCH_TABLE DispatchTable,
 
 VOID
 STDCALL
-KdpSerialDebugPrint(LPSTR Message)
+KdpSerialDebugPrint(LPSTR Message,
+                    ULONG Length)
 {
     PCHAR pch = (PCHAR) Message;
 
@@ -170,7 +171,11 @@ KdpSerialInit(PKD_DISPATCH_TABLE DispatchTable,
         DispatchTable->KdpPrintRoutine = KdpSerialDebugPrint;
 
         /* Initialize the Port */
-        KdPortInitializeEx(&SerialPortInfo, 0, 0);
+        if (!KdPortInitializeEx(&SerialPortInfo, 0, 0))
+        {
+            KdpDebugMode.Serial = FALSE;
+            return;
+        }
 
         /* Register as a Provider */
         InsertTailList(&KdProviders, &DispatchTable->KdProvidersList);
@@ -183,6 +188,15 @@ KdpSerialInit(PKD_DISPATCH_TABLE DispatchTable,
 
 /* SCREEN FUNCTIONS **********************************************************/
 
+VOID
+STDCALL
+KdpScreenPrint(LPSTR Message,
+               ULONG Length)
+{
+    /* Call HAL */
+    HalDisplayString(Message);
+}
+
 VOID
 STDCALL
 KdpScreenInit(PKD_DISPATCH_TABLE DispatchTable,
@@ -194,7 +208,7 @@ KdpScreenInit(PKD_DISPATCH_TABLE DispatchTable,
     {
         /* Write out the functions that we support for now */
         DispatchTable->KdpInitRoutine = KdpScreenInit;
-        DispatchTable->KdpPrintRoutine = HalDisplayString;
+        DispatchTable->KdpPrintRoutine = KdpScreenPrint;
 
         /* Register as a Provider */
         InsertTailList(&KdProviders, &DispatchTable->KdProvidersList);
@@ -246,13 +260,14 @@ KdpDetectConflicts(PCM_RESOURCE_LIST DriverList)
 
 ULONG
 STDCALL
-KdpPrintString(PANSI_STRING String)
+KdpPrintString(LPSTR String,
+               ULONG Length)
 {
-    if (!KdpDebugMode.Value) return 0;
-    PCH pch = String->Buffer;
     PLIST_ENTRY CurrentEntry;
     PKD_DISPATCH_TABLE CurrentTable;
 
+    if (!KdpDebugMode.Value) return 0;
+
     /* Call the registered handlers */
     CurrentEntry = KdProviders.Flink;
     while (CurrentEntry != &KdProviders)
@@ -263,17 +278,17 @@ KdpPrintString(PANSI_STRING String)
                                          KdProvidersList);
 
         /* Call it */
-        CurrentTable->KdpPrintRoutine(pch);
+        CurrentTable->KdpPrintRoutine(String, Length);
 
         /* Next Table */
         CurrentEntry = CurrentEntry->Flink;
     }
 
     /* Call the Wrapper Routine */
-    if (WrapperInitRoutine) WrapperTable.KdpPrintRoutine(pch);
+    if (WrapperInitRoutine) WrapperTable.KdpPrintRoutine(String, Length);
 
     /* Return the Length */
-    return((ULONG)String->Length);
+    return Length;
 }
 
 /* EOF */