[ros-diffs] [fireball] 30845: - Cleanup kdb_cli's code: be consistent in used types, don't use unsigned vars and then check if it's below 0, don't use inline assembly if there are reactos intrinsics for this.

fireball at svn.reactos.org fireball at svn.reactos.org
Wed Nov 28 23:50:56 CET 2007


Author: fireball
Date: Thu Nov 29 01:50:55 2007
New Revision: 30845

URL: http://svn.reactos.org/svn/reactos?rev=30845&view=rev
Log:
- Cleanup kdb_cli's code: be consistent in used types, don't use unsigned vars and then check if it's below 0, don't use inline assembly if there are reactos intrinsics for this.

Modified:
    trunk/reactos/ntoskrnl/include/internal/ctype.h
    trunk/reactos/ntoskrnl/kdbg/kdb_cli.c

Modified: trunk/reactos/ntoskrnl/include/internal/ctype.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/ctype.h?rev=30845&r1=30844&r2=30845&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/include/internal/ctype.h (original)
+++ trunk/reactos/ntoskrnl/include/internal/ctype.h Thu Nov 29 01:50:55 2007
@@ -40,5 +40,6 @@
 extern inline int isdigit(int c);
 extern inline int isxdigit(int c);
 extern inline int isprint(int c);
+extern inline int isalpha(int c);
 
 #endif

Modified: trunk/reactos/ntoskrnl/kdbg/kdb_cli.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/kdbg/kdb_cli.c?rev=30845&r1=30844&r2=30845&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/kdbg/kdb_cli.c (original)
+++ trunk/reactos/ntoskrnl/kdbg/kdb_cli.c Thu Nov 29 01:50:55 2007
@@ -483,8 +483,8 @@
    else if (Argv[0][0] == 'c') /* cregs */
    {
       ULONG Cr0, Cr2, Cr3, Cr4;
-      KDESCRIPTOR Gdtr, Ldtr, Idtr;
-      ULONG Tr;
+      KDESCRIPTOR Gdtr = {0}, Ldtr = {0}, Idtr = {0};
+      ULONG Tr = 0;
       STATIC CONST PCHAR Cr0Bits[32] = { " PE", " MP", " EM", " TS", " ET", " NE", NULL, NULL,
                                          NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
                                          " WP", NULL, " AM", NULL, NULL, NULL, NULL, NULL,
@@ -500,12 +500,12 @@
       Cr4 = KdbCurrentTrapFrame->Cr4;
 
       /* Get descriptor table regs */
-      asm volatile("sgdt %0" : : "m"(Gdtr.Limit));
-      asm volatile("sldt %0" : : "m"(Ldtr.Limit));
-      asm volatile("sidt %0" : : "m"(Idtr.Limit));
+      Ke386GetGlobalDescriptorTable(*(PKDESCRIPTOR)&Gdtr.Limit);
+      Ke386GetLocalDescriptorTable(Ldtr.Limit);
+      Ke386GetInterruptDescriptorTable(*(PKDESCRIPTOR)&Idtr.Limit);
 
       /* Get the task register */
-      asm volatile("str %0" : "=g"(Tr));
+      Ke386GetTr(Tr);
 
       /* Display the control registers */
       KdbpPrint("CR0  0x%08x ", Cr0);
@@ -842,7 +842,8 @@
    KDB_BREAKPOINT_TYPE Type;
    UCHAR Size = 0;
    KDB_ACCESS_TYPE AccessType = 0;
-   UINT AddressArgIndex, ConditionArgIndex, i;
+   ULONG AddressArgIndex, i;
+   LONG ConditionArgIndex;
    BOOLEAN Global = TRUE;
 
    if (Argv[0][2] == 'x') /* software breakpoint */
@@ -1188,8 +1189,8 @@
       {
          return TRUE;
       }
-      KdbpPrint("Attached to process 0x%08x, thread 0x%08x.\n", (UINT)ul,
-                (UINT)KdbCurrentThread->Cid.UniqueThread);
+      KdbpPrint("Attached to process 0x%08x, thread 0x%08x.\n", (ULONG)ul,
+                (ULONG)KdbCurrentThread->Cid.UniqueThread);
    }
    else
    {
@@ -1289,10 +1290,7 @@
 STATIC BOOLEAN
 KdbpCmdGdtLdtIdt(ULONG Argc, PCHAR Argv[])
 {
-   struct __attribute__((packed)) {
-      USHORT Limit;
-      ULONG Base;
-   } Reg;
+    KDESCRIPTOR Reg = {0};
    ULONG SegDesc[2];
    ULONG SegBase;
    ULONG SegLimit;
@@ -1305,7 +1303,7 @@
    if (Argv[0][0] == 'i')
    {
       /* Read IDTR */
-      asm volatile("sidt %0" : : "m"(Reg));
+      Ke386GetInterruptDescriptorTable(*(PKDESCRIPTOR)&Reg.Limit);
 
       if (Reg.Limit < 7)
       {
@@ -1362,14 +1360,14 @@
       if (Argv[0][0] == 'g')
       {
          /* Read GDTR */
-         asm volatile("sgdt %0" : : "m"(Reg));
+         Ke386GetGlobalDescriptorTable(*(PKDESCRIPTOR)&Reg.Limit);
          i = 8;
       }
       else
       {
          ASSERT(Argv[0][0] == 'l');
          /* Read LDTR */
-         asm volatile("sldt %0" : : "m"(Reg));
+         Ke386GetLocalDescriptorTable(Reg.Limit);
          i = 0;
          ul = 1 << 2;
       }
@@ -1567,7 +1565,7 @@
 STATIC BOOLEAN
 KdbpCmdSet(ULONG Argc, PCHAR Argv[])
 {
-   ULONG l;
+   LONG l;
    BOOLEAN First;
    PCHAR pend = 0;
    KDB_ENTER_CONDITION ConditionFirst = KdbDoNotEnter;
@@ -1765,9 +1763,9 @@
    STATIC BOOLEAN TerminalReportsSize = TRUE;
    CHAR c = '\0';
    PCHAR p, p2;
-   UINT Length;
-   UINT i, j;
-   INT RowsPrintedByTerminal;
+   ULONG Length;
+   ULONG i, j;
+   LONG RowsPrintedByTerminal;
    ULONG ScanCode;
    va_list ap;
 
@@ -2210,7 +2208,7 @@
  * \retval TRUE   Don't continue execution.
  * \retval FALSE  Continue execution (leave KDB)
  */
-STATIC BOOL
+STATIC BOOLEAN
 KdbpDoCommand(
    IN PCHAR Command)
 {
@@ -2390,7 +2388,7 @@
    HANDLE hFile = NULL;
    INT FileSize;
    PCHAR FileBuffer;
-   ULONG OldEflags;
+   ULONG OldEflags = 0;
 
    /* Initialize the object attributes */
    RtlInitUnicodeString(&FileName, L"\\SystemRoot\\system32\\drivers\\etc\\KDBinit");




More information about the Ros-diffs mailing list