[Freedos-kernel] patch: inthndlr.c

2004-07-14 Thread Arkady V.Belousov
Hi!

- callerARG1 declared as xreag instead UWORD.

---BeginMessage---
diff -ruNp old/kernel/inthndlr.c new/kernel/inthndlr.c
--- old/kernel/inthndlr.c   2004-07-15 00:42:06.0 +
+++ new/kernel/inthndlr.c   2004-07-15 02:16:58.0 +
@@ -1623,9 +1623,10 @@ STATIC VOID StartTrace(VOID)
 }
 #endif
 
-/* this function is called from an assembler wrapper function
-   and serves the internal dos calls - int2f/12xx and int2f/4a01,4a02.
+/* this function is called from an assembler wrapper function and
+   serves the internal dos calls - int2f/12xx and int2f/4a01,4a02
 */
+
 struct int2f12regs {
 #ifdef I386
 #ifdef __WATCOMC__
@@ -1644,7 +1645,7 @@ struct int2f12regs {
   UWORD di, si, bp;
   xreg b, d, c, a;
   UWORD ip, cs, flags;
-  UWORD callerARG1; /* used if called from INT2F/12 */
+  xreg callerARG1; /* used if called from INT2F/12 */
 };
 
 /* WARNING: modifications in `r' are used outside of int2F_12_handler()
@@ -1684,12 +1685,12 @@ VOID ASMCFUNC int2F_12_handler(struct in
   r.DS = FP_SEG(nul_dev);
   break;
 
-case 0x06: /* invoke critical error */
-
-  /* code, drive number, error, device header */
-  r.AL = CriticalError(r.callerARG1  8,
-   (r.callerARG1  (EFLG_CHAR  8)) ? 0 :
-   r.callerARG1  0xff, r.DI, MK_FP(r.BP, r.SI));
+case 0x06: /* invoke critical error*/
+  /* code, drive number, error, device header  */
+  r.AL = CriticalError(r.callerARG1.b.h,
+   (r.callerARG1.b.h  EFLG_CHAR)
+   ? 0 : r.callerARG1.b.l,
+  r.DI, MK_FP(r.BP, r.SI));
   break;
 
 case 0x08: /* decrease SFT reference count */
@@ -1747,19 +1748,19 @@ VOID ASMCFUNC int2F_12_handler(struct in
   break;
 }
 
-case 0x12: /* get length of asciiz string */
-
+case 0x12: /* get length of asciiz string  */
   r.CX = fstrlen(MK_FP(r.ES, r.DI)) + 1;
-
   break;
 
-case 0x13:
-  /* uppercase character */  
-  /* for now, ASCII only because nls.c cannot handle DS!=SS */
-  r.AL = (unsigned char)r.callerARG1;
-  if (r.AL = 'a'  r.AL = 'z')
-r.AL -= 'a' - 'A';
+case 0x13: /* uppercase character  */
+{
+  /* for now, ASCII only because nls.c cannot handle DS!=SS*/
+  UBYTE ch = r.callerARG1.b.l;
+  if (_islower(ch))
+ch -= (UBYTE)('a' - 'A');
+  r.AL = ch;
   break;
+}
 
 case 0x16:
   /* get address of system file table entry - used by NET.EXE
@@ -1795,10 +1796,9 @@ VOID ASMCFUNC int2F_12_handler(struct in
;
; probable use: get sizeof(CDSentry)
  */
-  {
-struct cds FAR *cdsp = get_cds(r.callerARG1  0xff);
-
-if (cdsp == NULL)
+{
+const struct cds FAR *cdsp;
+if ((cdsp = get_cds(r.callerARG1.b.l)) == NULL)
 {
   r.FLAGS |= FLG_CARRY;
   break;
@@ -1807,7 +1807,7 @@ VOID ASMCFUNC int2F_12_handler(struct in
 r.SI = FP_OFF(cdsp);
 r.FLAGS = ~FLG_CARRY;
 break;
-  }
+}
 
 case 0x18: /* get caller's registers */
 
---End Message---


Re: [Freedos-kernel] PATCH: inthndlr.c

2004-06-25 Thread tom ehlert
Hello Eduardo,

 I'm implementing NLSFUNC for FreeDOS and I've found that many (most) of
 the needed MUX functions are missing.

 This patch implements functions 2F1226h to 2F1229h. This, together with
 my previous nls.c patch, allowed me to make a first working
 implementation of NLSFUNC's int 2F1404h, but the patch looks so simple
 that I must have done something wrong :)  so, kernel guys, please, have
 a look at it. It is mainly cut'n'paste from int21_service()

a)
why do you need int2f/12 in the first first place ?
are you really executing this from inside KERNEL ?
do you really need to use internal functions ?

if YES, you will probably greatly overrun the kernels 384 byte stack,
which might become a problem.

if NO, why don't you use int21 functions ?


b) lseek(0x1) will fail due to fall from locng_check into
shortcheck.

tom






 Eduardo.


 diff -uNrp ke2035.orig/kernel/inthndlr.c ke2035/kernel/inthndlr.c
 --- ke2035.orig/kernel/inthndlr.c 2004-06-24 22:41:20.0 +0200
 +++ ke2035/kernel/inthndlr.c  2004-06-24 22:41:09.0 +0200
 @@ -1656,6 +1656,9 @@ struct int2f12regs {
   */
  VOID ASMCFUNC int2F_12_handler(struct int2f12regs r)
  {
 +  COUNT rc;
 +  long lrc;
 +
if (r.AH == 0x4a)
{
  size_t size = 0, offs = 0x;
 @@ -1869,6 +1875,42 @@ VOID ASMCFUNC int2F_12_handler(struct in
r.CX = fstrlen(MK_FP(r.DS, r.SI)) + 1;
break;
 
 +case 0x26: /* open file */
 +  r.FLAGS = ~FLG_CARRY;
 +  CritErrCode = SUCCESS;
 +  lrc = DosOpen(MK_FP(r.DS, r.DX), O_LEGACY | O_OPEN | r.CL, 0);
 +  goto long_check;
 +
 +case 0x27: /* close file */
 +  r.FLAGS = ~FLG_CARRY;
 +  CritErrCode = SUCCESS;
 +  rc = DosClose(r.BX);
 +  goto short_check;
 +
 +case 0x28: /* move file pointer */
 +  r.FLAGS = ~FLG_CARRY;
 +  CritErrCode = SUCCESS;
 +  r.BP = 0x00ff;
+  if (r.BP  2)
 +goto error_invalid;
 +  lrc = DosSeek(r.BX, (LONG)ULONG) (r.CX))  16) | r.DX),
 r.BP);
 +  if (lrc == -1)
 +  {
 +lrc = DE_INVLDHNDL;
 +  }
 +  else
 +  {
 +r.DX = (UWORD)(lrc  16);
 +lrc = (UWORD) lrc;
 +  }
 +  goto long_check;
 +
 +case 0x29: /* read from file */
 +  r.FLAGS = ~FLG_CARRY;
 +  CritErrCode = SUCCESS;
 +  lrc = DosRead(r.BX, r.CX, MK_FP(r.DS, r.DX));
 +  goto long_check;
 +
  case 0x2a: /* Set FastOpen but does nothing. */
 
r.FLAGS = ~FLG_CARRY;
 @@ -1897,6 +1939,26 @@ VOID ASMCFUNC int2F_12_handler(struct in
  r.FLAGS |= FLG_CARRY;
}
}
 +  goto real_exit;
 +long_check:
+  if (lrc = SUCCESS)
 +  {
 +r.AX = (UWORD)lrc;
 +goto real_exit;
 +  }
 +  rc = (int)lrc;
 +short_check:
 +  if (rc  SUCCESS)
 +goto error_exit;
 +  goto real_exit;
 +error_invalid:
 +  rc = DE_INVLDFUNC;
 +error_exit:
 +  r.AX = -rc;
 +  if (CritErrCode == SUCCESS)
 +CritErrCode = r.AX;  /* Maybe set */
 +  r.FLAGS |= FLG_CARRY;
 +real_exit:;
  }
 
  /*




 ---
 This SF.Net email sponsored by Black Hat Briefings  Training.
 Attend Black Hat Briefings  Training, Las Vegas July 24-29 - 
 digital self defense, top technical experts, no vendor pitches, 
 unmatched networking opportunities. Visit www.blackhat.com
 ___
 Freedos-kernel mailing list
 [EMAIL PROTECTED]
 https://lists.sourceforge.net/lists/listinfo/freedos-kernel


-- 
Best regards,
Tom Ehlert
mailto:[EMAIL PROTECTED]
+49-241-79886



---
This SF.Net email sponsored by Black Hat Briefings  Training.
Attend Black Hat Briefings  Training, Las Vegas July 24-29 - 
digital self defense, top technical experts, no vendor pitches, 
unmatched networking opportunities. Visit www.blackhat.com
___
Freedos-kernel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/freedos-kernel


Re: [Freedos-kernel] PATCH: inthndlr.c

2004-06-25 Thread Eduardo Casino
Hi Tom,

 a)
 why do you need int2f/12 in the first first place ?
 are you really executing this from inside KERNEL ?
 do you really need to use internal functions ?

Yes. NLSFUNC implements kernel extensions to access NLS data from an
external file (namely COUNTRY.SYS) and these extensions are called from
inside the kernel (int 21/65, int 21/38)

 if YES, you will probably greatly overrun the kernels 384 byte stack,
 which might become a problem.

OK. How do I setup a different stack for these functions? 

 b) lseek(0x1) will fail due to fall from locng_check into
 shortcheck.

Then we have a real problem, because this was copied from the int 21/42
implementation.

Eduardo.



---
This SF.Net email sponsored by Black Hat Briefings  Training.
Attend Black Hat Briefings  Training, Las Vegas July 24-29 - 
digital self defense, top technical experts, no vendor pitches, 
unmatched networking opportunities. Visit www.blackhat.com
___
Freedos-kernel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/freedos-kernel


[Freedos-kernel] PATCH: inthndlr.c

2004-06-24 Thread Eduardo Casino
Hi!

I'm implementing NLSFUNC for FreeDOS and I've found that many (most) of
the needed MUX functions are missing.

This patch implements functions 2F1226h to 2F1229h. This, together with
my previous nls.c patch, allowed me to make a first working
implementation of NLSFUNC's int 2F1404h, but the patch looks so simple
that I must have done something wrong :)  so, kernel guys, please, have
a look at it. It is mainly cut'n'paste from int21_service()

Eduardo.


diff -uNrp ke2035.orig/kernel/inthndlr.c ke2035/kernel/inthndlr.c
--- ke2035.orig/kernel/inthndlr.c   2004-06-24 22:41:20.0 +0200
+++ ke2035/kernel/inthndlr.c2004-06-24 22:41:09.0 +0200
@@ -1656,6 +1656,9 @@ struct int2f12regs {
  */
 VOID ASMCFUNC int2F_12_handler(struct int2f12regs r)
 {
+  COUNT rc;
+  long lrc;
+
   if (r.AH == 0x4a)
   {
 size_t size = 0, offs = 0x;
@@ -1869,6 +1875,42 @@ VOID ASMCFUNC int2F_12_handler(struct in
   r.CX = fstrlen(MK_FP(r.DS, r.SI)) + 1;
   break;
 
+case 0x26: /* open file */
+  r.FLAGS = ~FLG_CARRY;
+  CritErrCode = SUCCESS;
+  lrc = DosOpen(MK_FP(r.DS, r.DX), O_LEGACY | O_OPEN | r.CL, 0);
+  goto long_check;
+
+case 0x27: /* close file */
+  r.FLAGS = ~FLG_CARRY;
+  CritErrCode = SUCCESS;
+  rc = DosClose(r.BX);
+  goto short_check;
+
+case 0x28: /* move file pointer */
+  r.FLAGS = ~FLG_CARRY;
+  CritErrCode = SUCCESS;
+  r.BP = 0x00ff;
+  if (r.BP  2)
+goto error_invalid;
+  lrc = DosSeek(r.BX, (LONG)ULONG) (r.CX))  16) | r.DX),
r.BP);
+  if (lrc == -1)
+  {
+lrc = DE_INVLDHNDL;
+  }
+  else
+  {
+r.DX = (UWORD)(lrc  16);
+lrc = (UWORD) lrc;
+  }
+  goto long_check;
+
+case 0x29: /* read from file */
+  r.FLAGS = ~FLG_CARRY;
+  CritErrCode = SUCCESS;
+  lrc = DosRead(r.BX, r.CX, MK_FP(r.DS, r.DX));
+  goto long_check;
+
 case 0x2a: /* Set FastOpen but does nothing. */
 
   r.FLAGS = ~FLG_CARRY;
@@ -1897,6 +1939,26 @@ VOID ASMCFUNC int2F_12_handler(struct in
 r.FLAGS |= FLG_CARRY;
   }
   }
+  goto real_exit;
+long_check:
+  if (lrc = SUCCESS)
+  {
+r.AX = (UWORD)lrc;
+goto real_exit;
+  }
+  rc = (int)lrc;
+short_check:
+  if (rc  SUCCESS)
+goto error_exit;
+  goto real_exit;
+error_invalid:
+  rc = DE_INVLDFUNC;
+error_exit:
+  r.AX = -rc;
+  if (CritErrCode == SUCCESS)
+CritErrCode = r.AX;  /* Maybe set */
+  r.FLAGS |= FLG_CARRY;
+real_exit:;
 }
 
 /*




---
This SF.Net email sponsored by Black Hat Briefings  Training.
Attend Black Hat Briefings  Training, Las Vegas July 24-29 - 
digital self defense, top technical experts, no vendor pitches, 
unmatched networking opportunities. Visit www.blackhat.com
___
Freedos-kernel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/freedos-kernel


[Freedos-kernel] patch: inthndlr.c

2004-05-30 Thread Arkady V.Belousov
Hi!

- bugfix for INT21/3301: MS-DOS clears high buts of DL.

---BeginMessage---
diff -ruNp old/kernel/inthndlr.c new/kernel/inthndlr.c
--- old/kernel/inthndlr.c   2004-05-28 12:08:32.0 +
+++ new/kernel/inthndlr.c   2004-05-31 07:29:14.0 +
@@ -78,14 +78,14 @@ VOID ASMCFUNC int21_syscall(iregs FAR * 
 case 0x33:
   switch (irp-AL)
   {
-  /* Get Ctrl-C flag  */
-case 0x00:
-  irp-DL = break_ena;
-  break;
-
   /* Set Ctrl-C flag  */
 case 0x01:
   break_ena = irp-DL  1;
+  /* fall through */
+
+  /* Get Ctrl-C flag  */
+case 0x00:
+  irp-DL = break_ena;
   break;
 
 case 0x02: /* andrew schulman: get/set extended control break  */
@@ -1049,7 +1049,7 @@ dispatch:
   /* dta for this call is set on entry.  This */
   /* needs to be changed for new versions.*/
   rc = DosFindFirst(lr.CX, FP_DS_DX);
-  lr.AX = 0;
+  lr.AX = 0; /* ??? - avb */
   goto short_check;
 
   /* Dos Find Next*/
@@ -1057,7 +1057,7 @@ dispatch:
   /* dta for this call is set on entry.  This */
   /* needs to be changed for new versions.*/
   rc = DosFindNext();
-  lr.AX = 0;
+  lr.AX = 0; /* ??? - avb */
   goto short_check;
 /*
 case 0x50:  
---End Message---


[Freedos-kernel] patch: inthndlr.c

2004-05-12 Thread Arkady V.Belousov
Hi!

Changes:

- rc != SUCCESS after DosDevIOctl() replaced by rc  SUCCESS.

Cleanups:

- some zeros replaced by SUCCESS.
- used -DE_INVLDDRV expression instead 0x0f value.
- instead ((lr.AX  0xff) != 0)) used nicer lr.AL ? 1 : 0.

Optimizations:

- removed extraneous assignments to `rc'.
- removed extraneous if (rc = SUCCESS) checks before assignments to lr.AX.
- reused goto short_check whenever possible instead if (rc  SUCCESS).

TGROUP reduced from 0e131h (01e41h before previous bigfixes) to 0e111h,
HMA_TEXT reduced from 0a614h (0a623h) to 0a5f8h.



t2
Description: Binary data


[Freedos-kernel] patch: inthndlr.c

2004-05-12 Thread Arkady V.Belousov
Hi!

Changes:

- rc != SUCCESS after DosDevIOctl() replaced by rc  SUCCESS.

Cleanups:

- some zeros replaced by SUCCESS.
- used -DE_INVLDDRV expression instead 0x0f value.
- instead ((lr.AX  0xff) != 0)) used nicer lr.AL ? 1 : 0.

Optimizations:

- removed extraneous assignments to `rc'.
- removed extraneous if (rc = SUCCESS) checks before assignments to lr.AX.
- reused goto short_check whenever possible instead if (rc  SUCCESS).

TGROUP reduced from 0e131h (01e41h before previous bigfixes) to 0e111h,
HMA_TEXT reduced from 0a614h (0a623h) to 0a5f8h.

---BeginMessage---
diff -ruNp old/kernel/inthndlr.c new/kernel/inthndlr.c
--- old/kernel/inthndlr.c   2004-05-13 05:42:04.0 +
+++ new/kernel/inthndlr.c   2004-05-13 06:33:08.0 +
@@ -382,7 +382,7 @@ int int21_fat32(lregs *r)
 
 VOID ASMCFUNC int21_service(iregs FAR * r)
 {
-  COUNT rc = 0;
+  COUNT rc;
   long lrc;
   lregs lr; /* 8 local registers (ax, bx, cx, dx, si, di, ds, es) */
 
@@ -765,8 +765,8 @@ dispatch:
 
 if (dpb == NULL)
 {
+  CritErrCode = -DE_INVLDDRV;
   lr.AL = 0xFF;
-  CritErrCode = 0x0f;
   break;
 }
 /* hazard: no error checking! */
@@ -779,8 +779,8 @@ dispatch:
 if (media_check(dpb)  0)
 #endif
 {
+  CritErrCode = -DE_INVLDDRV;
   lr.AL = 0xff;
-  CritErrCode = 0x0f;
   break;
 }
 lr.DS = FP_SEG(dpb);
@@ -839,7 +839,7 @@ dispatch:
 if (0x == lr.DX)
 {
   /* Set Country Code */
-  if ((rc = DosSetCountry(cntry))  0)
+  if (DosSetCountry(cntry)  0)
 goto error_invalid;
 }
 else
@@ -847,7 +847,7 @@ dispatch:
   if (cntry == 0)
 cntry--;
   /* Get Country Information */
-  if ((rc = DosGetCountryInformation(cntry, FP_DS_DX))  0)
+  if (DosGetCountryInformation(cntry, FP_DS_DX)  0)
 goto error_invalid;
   /* HACK FIXME */
   if (cntry == (UWORD) - 1)
@@ -927,7 +927,6 @@ dispatch:
 
 case 0x01:
   rc = DosSetFattr((BYTE FAR *) FP_DS_DX, lr.CX);
-  if (rc = SUCCESS)
 lr.AX = lr.CX;
   break;
 
@@ -939,12 +938,11 @@ dispatch:
   /* Device I/O Control   */
 case 0x44:
   rc = DosDevIOctl(lr);  /* can set critical error code! */
-
-  if (rc != SUCCESS)
+  if (rc  SUCCESS)
   {
 lr.AX = -rc;
 if (rc != DE_DEVICE  rc != DE_ACCESS)
-  CritErrCode = -rc;
+  CritErrCode = lr.AX;
 goto error_carry;
   }
   break;
@@ -962,52 +960,40 @@ dispatch:
   /* Get Current Directory*/
 case 0x47:
   rc = DosGetCuDir(lr.DL, MK_FP(lr.DS, lr.SI));
-  if (rc = SUCCESS)
 lr.AX = 0x0100; /*jpp: from interrupt list */
   goto short_check;
 
   /* Allocate memory */
 case 0x48:
-  if ((rc =
-   DosMemAlloc(lr.BX, mem_access_mode, (lr.AX), (lr.BX)))  0)
+  if ((rc = DosMemAlloc(lr.BX, mem_access_mode, lr.AX, lr.BX))  SUCCESS)
   {
-DosMemLargest((lr.BX));
-{
+DosMemLargest(lr.BX);
 if (DosMemCheck() != SUCCESS)
 panic(MCB chain corrupted);
-}
 goto error_exit;
   }
-  else
-++(lr.AX);  /* DosMemAlloc() returns seg of MCB rather than data 
*/
+  lr.AX++; /* DosMemAlloc() returns seg of MCB rather than data */
   break;
 
   /* Free memory */
 case 0x49:
-  if ((rc = DosMemFree((lr.ES) - 1))  0)
-{
+  if ((rc = DosMemFree(lr.ES - 1))  SUCCESS)
+  {
 if (DosMemCheck() != SUCCESS)
 panic(MCB chain corrupted);
-goto error_exit;
-}
+goto error_exit;
+  }
   break;
 
   /* Set memory block size */
 case 0x4a:
-if (DosMemCheck() != SUCCESS)
-  panic(before 4a: MCB chain corrupted);
-
-  if ((rc = DosMemChange(lr.ES, lr.BX, lr.BX))  0)
+  if (DosMemCheck() != SUCCESS)
+panic(before 4a: MCB chain corrupted);
+  if ((rc = DosMemChange(lr.ES, lr.BX, lr.BX))  SUCCESS)
   {
 #if 0
 if (cu_psp == lr.ES)
-{
-
-  psp FAR *p;
-  
-  p = MK_FP(cu_psp, 0);
-  p-ps_size = lr.BX + cu_psp;
-}
+  ((psp FAR*)MK_FP(cu_psp, 0))-ps_size = lr.BX + cu_psp;
 #endif
 if (DosMemCheck() != SUCCESS)
   panic(after 4a: MCB chain corrupted);
@@ -1031,21 +1017,17 @@ dispatch:
   if (((psp FAR *)MK_FP(cu_psp, 0))-ps_parent == cu_psp)
 break;
   tsr = FALSE;
+  return_code = lr.AL;
   if (ErrorMode)
   {
 ErrorMode = FALSE;
-rc = 2;
+return_code |= 0x200;
   }
   else if (break_flg)
   {
 

[Freedos-kernel] patch: inthndlr.c

2004-05-09 Thread Arkady V.Belousov
Hi!

- fix for INT21/38 (AL=0 processed as is for DX=-1).
- INT21/5C: parameter `unlock' of DosLockUnlock now explicitly receives 1
  when lr.AL nonzero.
- code optimization; some cleanups using previously defined macros.

DGROUP reduced from 164A to 1648;
HMA_TEXT reduced from 0a63eh to 0a633h.

---BeginMessage---
diff -ruNp old/kernel/inthndlr.c new/kernel/inthndlr.c
--- old/kernel/inthndlr.c   2004-05-10 01:23:44.0 +
+++ new/kernel/inthndlr.c   2004-05-10 04:07:56.0 +
@@ -247,10 +247,10 @@ int int21_fat32(lregs *r)
   ULONG cluster = xdffp-xdff_f.setdpbcounts.cluster;
   if (ISFAT32(dpb))
   {
-if ((dpb-dpb_xfsinfosec == 0x
-  (nfreeclst != 0 || cluster != 0))
-|| nfreeclst == 1 || nfreeclst  dpb-dpb_xsize
-|| cluster == 1 || cluster  dpb-dpb_xsize)
+if ((nfreeclst != 0 || cluster != 0) 
+(dpb-dpb_xfsinfosec == 0x ||
+ nfreeclst == 1 || nfreeclst  dpb-dpb_xsize ||
+ cluster   == 1 || clusterdpb-dpb_xsize))
 {
   return DE_INVLDPARM;
 }
@@ -260,8 +260,9 @@ int int21_fat32(lregs *r)
   }
   else
   {
-if ((unsigned)nfreeclst == 1 || (unsigned)nfreeclst  dpb-dpb_size ||
-(unsigned)cluster == 1 || (unsigned)cluster  dpb-dpb_size)
+if (((unsigned)nfreeclst | (unsigned)cluster) == 1 ||
+(unsigned)nfreeclst  dpb-dpb_size ||
+(unsigned)cluster  dpb-dpb_size)
 {
   return DE_INVLDPARM;
 }
@@ -271,13 +272,11 @@ int int21_fat32(lregs *r)
   break;
 }
 case 0x01:
-{
-  ddt *pddt = getddt(r-DL);
-  fmemcpy(pddt-ddt_bpb, xdffp-xdff_f.rebuilddpb.bpbp,
+  fmemcpy(getddt(r-DL)-ddt_bpb, xdffp-xdff_f.rebuilddpb.bpbp,
   sizeof(bpb));
-}
+  /*goto rebuild_dpb;*/
+
 case 0x02:
-{
 rebuild_dpb:
 /* hazard: no error checking! */
   flush_buffers(dpb-dpb_unit);
@@ -286,17 +285,14 @@ int int21_fat32(lregs *r)
   if (media_check(dpb)  0)
 return DE_INVLDDRV;
   break;
-}
+
 case 0x03:
 {
-  struct buffer FAR *bp;
-  bpb FAR *bpbp;
   DWORD newmirroring =
 xdffp-xdff_f.setmirroring.newmirroring;
-  
-  if (newmirroring != -1
-   (ISFAT32(dpb)
-   (newmirroring  ~(0xf | 0x80
+  if (newmirroring != -1 
+  (newmirroring  ~0x8f) 
+  ISFAT32(dpb))
   {
 return DE_INVLDPARM;
   }
@@ -304,39 +300,33 @@ int int21_fat32(lregs *r)
 (ISFAT32(dpb) ? dpb-dpb_xflags : 0);
   if (newmirroring != -1  ISFAT32(dpb))
   {
-bp = getblock(1, dpb-dpb_unit);
+struct buffer FAR *bp = getblock(1, dpb-dpb_unit);
 bp-b_flag = ~(BFR_DATA | BFR_DIR | BFR_FAT);
 bp-b_flag |= BFR_VALID | BFR_DIRTY;
-bpbp = (bpb FAR *)  bp-b_buffer[BT_BPB];
-bpbp-bpb_xflags = (UWORD)newmirroring;
+((bpb FAR*)(bp-b_buffer + BT_BPB))-bpb_xflags = (UWORD)newmirroring;
   }
   goto rebuild_dpb;
 }
 case 0x04:
 {
-  struct buffer FAR *bp;
-  bpb FAR *bpbp;
   DWORD rootclst = xdffp-xdff_f.setroot.newrootclst;
-  if (!ISFAT32(dpb)
-  || (rootclst != -1
-   (rootclst == 1
-  || (ULONG)rootclst  dpb-dpb_xsize)))
+  if (!ISFAT32(dpb) ||
+  rootclst == 1 ||
+  rootclst != -1  (ULONG)rootclst  dpb-dpb_xsize)
   {
 return DE_INVLDPARM;
   }
   xdffp-xdff_f.setroot.oldrootclst = dpb-dpb_xrootclst;
   if (rootclst != -1)
   {
-bp = getblock(1, dpb-dpb_unit);
+struct buffer FAR *bp = getblock(1, dpb-dpb_unit);
 bp-b_flag = ~(BFR_DATA | BFR_DIR | BFR_FAT);
 bp-b_flag |= BFR_VALID | BFR_DIRTY;
-bpbp = (bpb FAR *)  bp-b_buffer[BT_BPB];
-bpbp-bpb_xrootclst = rootclst;
+((bpb FAR*)(bp-b_buffer + BT_BPB))-bpb_xrootclst = rootclst;
   }
   goto rebuild_dpb;
 }
   }
-
   break;
 }
 /* Extended absolute disk read/write */
@@ -671,10 +661,8 @@ dispatch:
 
   /* Parse File Name  */
 case 0x29:
-  {
-lr.SI = FcbParseFname(rc, MK_FP(lr.DS, lr.SI), FP_ES_DI);
-lr.AL = rc;
-  }
+  lr.SI = FcbParseFname(rc, MK_FP(lr.DS, lr.SI), FP_ES_DI);
+  lr.AL = rc;
   break;
 
   /* Get Date */
@@ -832,10 +820,7 @@ dispatch:
 case 0x38:
   {
 UWORD cntry =