- Use _SEH2_YIELD when returning from an exception instead of returning outside the...
[reactos.git] / reactos / lib / rtl / debug.c
index a17367f..f34adef 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS Run-Time Library
- * FILE:            ntoskrnl/rtl/dbgprint.c
+ * FILE:            lib/rtl/debug.c
  * PURPOSE:         Debug Print and Prompt routines
  * PROGRAMMERS:     Alex Ionescu (alex@relsoft.net)
  *                  Royce Mitchel III
@@ -54,24 +54,25 @@ vDbgPrintExWithPrefixInternal(IN LPCSTR Prefix,
                               IN va_list ap,
                               IN BOOLEAN HandleBreakpoint)
 {
-    NTSTATUS Status = STATUS_SUCCESS;
+    NTSTATUS Status;
     ANSI_STRING DebugString;
     CHAR Buffer[512];
     ULONG Length, PrefixLength;
     EXCEPTION_RECORD ExceptionRecord;
 
     /* Check if we should print it or not */
-    if ((ComponentId != -1) && !(NtQueryDebugFilterState(ComponentId, Level)))
+    if ((ComponentId != -1U) &&
+        !(NtQueryDebugFilterState(ComponentId, Level)))
     {
         /* This message is masked */
-        return Status;
+        return STATUS_SUCCESS;
     }
 
     /* For user mode, don't recursively DbgPrint */
-    if (RtlpSetInDbgPrint(TRUE)) return Status;
+    if (RtlpSetInDbgPrint(TRUE)) return STATUS_SUCCESS;
 
     /* Guard against incorrect pointers */
-    _SEH_TRY
+    _SEH2_TRY
     {
         /* Get the length and normalize it */
         PrefixLength = strlen(Prefix);
@@ -86,17 +87,16 @@ vDbgPrintExWithPrefixInternal(IN LPCSTR Prefix,
                             Format,
                             ap);
     }
-    _SEH_HANDLE
+    _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
     {
         /* Fail */
         Length = PrefixLength = 0;
-        Status = _SEH_GetExceptionCode();
+        _SEH2_YIELD(return _SEH2_GetExceptionCode());
     }
-    _SEH_END;
-    if (!NT_SUCCESS(Status)) return Status;
+    _SEH2_END;
 
     /* Check if we went past the buffer */
-    if (Length == -1)
+    if (Length == -1U)
     {
         /* Terminate it if we went over-board */
         Buffer[sizeof(Buffer) - 1] = '\n';
@@ -202,19 +202,19 @@ __cdecl
 DbgPrint(PCCH Format,
          ...)
 {
-       ULONG n;
+    ULONG n;
     va_list ap;
 
     /* Call the internal routine that also handles ControlC */
     va_start(ap, Format);
     n = vDbgPrintExWithPrefixInternal("",
-                                         -1,
-                                         DPFLTR_ERROR_LEVEL,
-                                         Format,
-                                         ap,
-                                         TRUE);
+                                      -1,
+                                      DPFLTR_ERROR_LEVEL,
+                                      Format,
+                                      ap,
+                                      TRUE);
     va_end(ap);
-       return n;
+    return n;
 }
 
 /*
@@ -227,19 +227,19 @@ DbgPrintEx(IN ULONG ComponentId,
            IN PCCH Format,
            ...)
 {
-       ULONG n;
+    ULONG n;
     va_list ap;
 
     /* Call the internal routine that also handles ControlC */
     va_start(ap, Format);
     n = vDbgPrintExWithPrefixInternal("",
-                                         ComponentId,
-                                         Level,
-                                         Format,
-                                         ap,
-                                         TRUE);
+                                      ComponentId,
+                                      Level,
+                                      Format,
+                                      ap,
+                                      TRUE);
     va_end(ap);
-       return n;
+    return n;
 }
 
 /*
@@ -250,19 +250,19 @@ __cdecl
 DbgPrintReturnControlC(PCH Format,
                        ...)
 {
-       ULONG n;
+    ULONG n;
     va_list ap;
 
     /* Call the internal routine that also handles ControlC */
     va_start(ap, Format);
     n = vDbgPrintExWithPrefixInternal("",
-                                         -1,
-                                         DPFLTR_ERROR_LEVEL,
-                                         Format,
-                                         ap,
-                                         FALSE);
+                                      -1,
+                                      DPFLTR_ERROR_LEVEL,
+                                      Format,
+                                      ap,
+                                      FALSE);
     va_end(ap);
-       return n;
+    return n;
 }
 
 /*
@@ -368,5 +368,3 @@ DbgUnLoadImageSymbols(IN PANSI_STRING Name,
     /* Load the symbols */
     DebugService2(Name, &SymbolInfo, BREAKPOINT_UNLOAD_SYMBOLS);
 }
-
-/* EOF */