Added explicit (UWORD) type casts to avoid compiler warnings and sometimes

save a few bytes too. Also changed the FcbParseFname return value:
returns offset portion of pointer (SI) instead of the number of bytes to
be added to SI.


git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@775 6ac86273-5f31-0410-b378-82cca8765d1b
This commit is contained in:
Bart Oldeman 2004-02-07 18:04:50 +00:00
parent 005e8cc35f
commit 0e0abcd685
9 changed files with 75 additions and 76 deletions

View File

@ -412,7 +412,7 @@ UWORD dskxfer(COUNT dsk, ULONG blkno, VOID FAR * buf, UWORD numblocks,
IoReqHdr.r_huge = blkno; IoReqHdr.r_huge = blkno;
} }
else else
IoReqHdr.r_start = blkno; IoReqHdr.r_start = (UWORD)blkno;
/* /*
* Some drivers normalise transfer address so HMA transfers are disastrous! * Some drivers normalise transfer address so HMA transfers are disastrous!
* Then transfer block through xferbuf (DiskTransferBuffer doesn't work!) * Then transfer block through xferbuf (DiskTransferBuffer doesn't work!)

View File

@ -60,7 +60,7 @@ VOID dir_init_fnode(f_node_ptr fnp, CLUSTER dirstart)
else else
#endif #endif
{ {
fnp->f_dirstart = 0l; fnp->f_dirstart = 0;
fnp->f_flags.f_droot = TRUE; fnp->f_flags.f_droot = TRUE;
} }
} }
@ -181,6 +181,18 @@ STATIC void swap_deleted(char *name)
name[0] = DELETED; name[0] = DELETED;
} }
STATIC struct buffer FAR *getblock_from_off(f_node_ptr fnp, unsigned secsize)
{
/* Compute the block within the cluster and the */
/* offset within the block. */
fnp->f_sector = (UBYTE)(fnp->f_offset / secsize) & fnp->f_dpb->dpb_clsmask;
fnp->f_boff = (UWORD)(fnp->f_offset % secsize);
/* Get the block we need from cache */
return getblock(clus2phys(fnp->f_cluster, fnp->f_dpb) + fnp->f_sector,
fnp->f_dpb->dpb_unit);
}
/* Description. /* Description.
* Read next consequitive directory entry, pointed by fnp. * Read next consequitive directory entry, pointed by fnp.
* If some error occures the other critical * If some error occures the other critical
@ -237,14 +249,7 @@ COUNT dir_read(REG f_node_ptr fnp)
if (map_cluster(fnp, XFR_READ) != SUCCESS) if (map_cluster(fnp, XFR_READ) != SUCCESS)
return DE_SEEK; return DE_SEEK;
/* Compute the block within the cluster and the */ bp = getblock_from_off(fnp, secsize);
/* offset within the block. */
fnp->f_sector = (fnp->f_offset / secsize) & fnp->f_dpb->dpb_clsmask;
fnp->f_boff = fnp->f_offset % secsize;
/* Get the block we need from cache */
bp = getblock(clus2phys(fnp->f_cluster, fnp->f_dpb) + fnp->f_sector,
fnp->f_dpb->dpb_unit);
#ifdef DISPLAY_GETBLOCK #ifdef DISPLAY_GETBLOCK
printf("DIR (dir_read)\n"); printf("DIR (dir_read)\n");
#endif #endif
@ -335,14 +340,7 @@ BOOL dir_write(REG f_node_ptr fnp)
return FALSE; return FALSE;
} }
/* Compute the block within the cluster and the */ bp = getblock_from_off(fnp, secsize);
/* offset within the block. */
fnp->f_sector = (fnp->f_offset / secsize) & fnp->f_dpb->dpb_clsmask;
fnp->f_boff = fnp->f_offset % secsize;
/* Get the block we need from cache */
bp = getblock(clus2phys(fnp->f_cluster, fnp->f_dpb) + fnp->f_sector,
fnp->f_dpb->dpb_unit);
bp->b_flag &= ~(BFR_DATA | BFR_FAT); bp->b_flag &= ~(BFR_DATA | BFR_FAT);
bp->b_flag |= BFR_DIR | BFR_VALID; bp->b_flag |= BFR_DIR | BFR_VALID;
#ifdef DISPLAY_GETBLOCK #ifdef DISPLAY_GETBLOCK

View File

@ -826,7 +826,7 @@ STATIC VOID wipe_out_clusters(struct dpb FAR * dpbp, CLUSTER st)
else else
#endif #endif
if ((dpbp->dpb_cluster == UNKNCLUSTER) || (dpbp->dpb_cluster > st)) if ((dpbp->dpb_cluster == UNKNCLUSTER) || (dpbp->dpb_cluster > st))
dpbp->dpb_cluster = st; dpbp->dpb_cluster = (UWORD)st;
/* and just follow the linked list */ /* and just follow the linked list */
st = next; st = next;
@ -1037,7 +1037,7 @@ STATIC CLUSTER find_fat_free(f_node_ptr fnp)
} }
#endif #endif
if (idx > dpbp->dpb_size) if ((UWORD)idx > dpbp->dpb_size)
{ {
dpbp->dpb_cluster = UNKNCLUSTER; dpbp->dpb_cluster = UNKNCLUSTER;
return LONG_LAST_CLUSTER; return LONG_LAST_CLUSTER;
@ -1047,7 +1047,7 @@ STATIC CLUSTER find_fat_free(f_node_ptr fnp)
dpbp->dpb_nfreeclst--; /* TE: moved from link_fat() */ dpbp->dpb_nfreeclst--; /* TE: moved from link_fat() */
/* return the free entry */ /* return the free entry */
dpbp->dpb_cluster = idx; dpbp->dpb_cluster = (UWORD)idx;
return idx; return idx;
} }
@ -1447,8 +1447,8 @@ STATIC COUNT dos_extend(f_node_ptr fnp)
#ifdef WRITEZEROS #ifdef WRITEZEROS
/* Compute the block within the cluster and the offset */ /* Compute the block within the cluster and the offset */
/* within the block. */ /* within the block. */
fnp->f_sector = (fnp->f_offset / secsize) & fnp->f_dpb->dpb_clsmask; fnp->f_sector = (UBYTE)(fnp->f_offset / secsize) & fnp->f_dpb->dpb_clsmask;
fnp->f_boff = fnp->f_offset % secsize; fnp->f_boff = (UWORD)(fnp->f_offset % secsize);
#ifdef DSK_DEBUG #ifdef DSK_DEBUG
printf("write %d links; dir offset %ld, cluster %d\n", printf("write %d links; dir offset %ld, cluster %d\n",
@ -1676,8 +1676,8 @@ long rwblock(COUNT fd, VOID FAR * buffer, UCOUNT count, int mode)
/* Compute the block within the cluster and the offset */ /* Compute the block within the cluster and the offset */
/* within the block. */ /* within the block. */
fnp->f_sector = (fnp->f_offset / secsize) & fnp->f_dpb->dpb_clsmask; fnp->f_sector = (UBYTE)(fnp->f_offset / secsize) & fnp->f_dpb->dpb_clsmask;
fnp->f_boff = fnp->f_offset % secsize; fnp->f_boff = (UWORD)(fnp->f_offset % secsize);
currentblock = clus2phys(fnp->f_cluster, fnp->f_dpb) + fnp->f_sector; currentblock = clus2phys(fnp->f_cluster, fnp->f_dpb) + fnp->f_sector;
@ -1890,7 +1890,7 @@ CLUSTER dos_free(struct dpb FAR * dpbp)
return cnt; return cnt;
} }
#endif #endif
dpbp->dpb_nfreeclst = cnt; dpbp->dpb_nfreeclst = (UWORD)cnt;
return cnt; return cnt;
} }
@ -1907,7 +1907,9 @@ int dos_cd(char * PathName)
if ((fnp = dir_open(PathName)) == NULL) if ((fnp = dir_open(PathName)) == NULL)
return DE_PATHNOTFND; return DE_PATHNOTFND;
cdsp->cdsStrtClst = fnp->f_dirstart; /* problem: RBIL table 01643 does not give a FAT32 field for the
CDS start cluster. But we are not using this field ourselves */
cdsp->cdsStrtClst = (UWORD)fnp->f_dirstart;
dir_close(fnp); dir_close(fnp);
return SUCCESS; return SUCCESS;
} }
@ -2028,7 +2030,7 @@ VOID bpb_to_dpb(bpb FAR * bpbp, REG struct dpb FAR * dpbp)
dpbp->dpb_data = dpbp->dpb_dirstrt dpbp->dpb_data = dpbp->dpb_dirstrt
+ (dpbp->dpb_dirents + dpbp->dpb_secsize/DIRENT_SIZE - 1) / + (dpbp->dpb_dirents + dpbp->dpb_secsize/DIRENT_SIZE - 1) /
(dpbp->dpb_secsize/DIRENT_SIZE); (dpbp->dpb_secsize/DIRENT_SIZE);
dpbp->dpb_size = ((size - dpbp->dpb_data) >> shftcnt) + 1; dpbp->dpb_size = (UWORD)((size - dpbp->dpb_data) >> shftcnt) + 1;
{ /* Make sure the number of FAT sectors is actually enough to hold that */ { /* Make sure the number of FAT sectors is actually enough to hold that */
/* many clusters. Otherwise back the number of clusters down (LG & AB) */ /* many clusters. Otherwise back the number of clusters down (LG & AB) */
unsigned fatsiz; unsigned fatsiz;

View File

@ -177,7 +177,8 @@ unsigned link_fat(struct dpb FAR * dpbp, CLUSTER Cluster1,
/* form an index so that we can read the block as a */ /* form an index so that we can read the block as a */
/* byte array */ /* byte array */
idx = (unsigned) (((Cluster1 << 1) + Cluster1) >> 1) % dpbp->dpb_secsize; idx = (unsigned) ((((unsigned)Cluster1 << 1) + (unsigned)Cluster1) >> 1)
% dpbp->dpb_secsize;
/* Test to see if the cluster straddles the block. If */ /* Test to see if the cluster straddles the block. If */
/* it does, get the next block and use both to form the */ /* it does, get the next block and use both to form the */
@ -188,7 +189,7 @@ unsigned link_fat(struct dpb FAR * dpbp, CLUSTER Cluster1,
if (idx >= (unsigned)dpbp->dpb_secsize - 1) if (idx >= (unsigned)dpbp->dpb_secsize - 1)
{ {
bp1 = getFATblock(Cluster1 + 1, dpbp); bp1 = getFATblock((unsigned)Cluster1 + 1, dpbp);
if (bp1 == 0) if (bp1 == 0)
return DE_BLKINVLD; return DE_BLKINVLD;
@ -198,15 +199,15 @@ unsigned link_fat(struct dpb FAR * dpbp, CLUSTER Cluster1,
} }
/* Now pack the value in */ /* Now pack the value in */
if (Cluster1 & 0x01) if ((unsigned)Cluster1 & 0x01)
{ {
*fbp0 = (*fbp0 & 0x0f) | ((Cluster2 & 0x0f) << 4); *fbp0 = (*fbp0 & 0x0f) | (((UBYTE)Cluster2 & 0x0f) << 4);
*fbp1 = (Cluster2 >> 4) & 0xff; *fbp1 = (UBYTE)((unsigned)Cluster2 >> 4);
} }
else else
{ {
*fbp0 = Cluster2 & 0xff; *fbp0 = (UBYTE)Cluster2;
*fbp1 = (*fbp1 & 0xf0) | ((Cluster2 >> 8) & 0x0f); *fbp1 = (*fbp1 & 0xf0) | ((UBYTE)((unsigned)Cluster2 >> 8) & 0x0f);
} }
} }
else if (ISFAT16(dpbp)) else if (ISFAT16(dpbp))

View File

@ -88,7 +88,6 @@ BYTE FAR *FatGetDrvData(UBYTE drive, UWORD * spc, UWORD * bps, UWORD * nc)
UWORD FcbParseFname(int *wTestMode, const BYTE FAR * lpFileName, fcb FAR * lpFcb) UWORD FcbParseFname(int *wTestMode, const BYTE FAR * lpFileName, fcb FAR * lpFcb)
{ {
WORD wRetCodeName = FALSE, wRetCodeExt = FALSE; WORD wRetCodeName = FALSE, wRetCodeExt = FALSE;
const BYTE FAR * lpFileName2 = lpFileName;
/* pjv -- ExtFcbToFcb? */ /* pjv -- ExtFcbToFcb? */
/* Start out with some simple stuff first. Check if we are */ /* Start out with some simple stuff first. Check if we are */
@ -109,57 +108,57 @@ UWORD FcbParseFname(int *wTestMode, const BYTE FAR * lpFileName, fcb FAR * lpFcb
if (!(*wTestMode & PARSE_SEP_STOP)) if (!(*wTestMode & PARSE_SEP_STOP))
{ {
lpFileName2 = ParseSkipWh(lpFileName2); lpFileName = ParseSkipWh(lpFileName);
if (TestCmnSeps(lpFileName2)) if (TestCmnSeps(lpFileName))
++lpFileName2; ++lpFileName;
} }
/* Undocumented "feature," we skip white space anyway */ /* Undocumented "feature," we skip white space anyway */
lpFileName2 = ParseSkipWh(lpFileName2); lpFileName = ParseSkipWh(lpFileName);
/* Now check for drive specification */ /* Now check for drive specification */
if (*(lpFileName2 + 1) == ':') if (*(lpFileName + 1) == ':')
{ {
/* non-portable construct to be changed */ /* non-portable construct to be changed */
REG UBYTE Drive = DosUpFChar(*lpFileName2) - 'A'; REG UBYTE Drive = DosUpFChar(*lpFileName) - 'A';
if (Drive >= lastdrive) if (Drive >= lastdrive)
{ {
*wTestMode = PARSE_RET_BADDRIVE; *wTestMode = PARSE_RET_BADDRIVE;
return lpFileName2 - lpFileName; return FP_OFF(lpFileName);
} }
lpFcb->fcb_drive = Drive + 1; lpFcb->fcb_drive = Drive + 1;
lpFileName2 += 2; lpFileName += 2;
} }
/* special cases: '.' and '..' */ /* special cases: '.' and '..' */
if (*lpFileName2 == '.') if (*lpFileName == '.')
{ {
lpFcb->fcb_fname[0] = '.'; lpFcb->fcb_fname[0] = '.';
++lpFileName2; ++lpFileName;
if (*lpFileName2 == '.') if (*lpFileName == '.')
{ {
lpFcb->fcb_fname[1] = '.'; lpFcb->fcb_fname[1] = '.';
++lpFileName2; ++lpFileName;
} }
*wTestMode = PARSE_RET_NOWILD; *wTestMode = PARSE_RET_NOWILD;
return lpFileName2 - lpFileName; return FP_OFF(lpFileName);
} }
/* Now to format the file name into the string */ /* Now to format the file name into the string */
lpFileName2 = lpFileName =
GetNameField(lpFileName2, (BYTE FAR *) lpFcb->fcb_fname, FNAME_SIZE, GetNameField(lpFileName, (BYTE FAR *) lpFcb->fcb_fname, FNAME_SIZE,
(BOOL *) & wRetCodeName); (BOOL *) & wRetCodeName);
/* Do we have an extension? If do, format it else return */ /* Do we have an extension? If do, format it else return */
if (*lpFileName2 == '.') if (*lpFileName == '.')
lpFileName2 = lpFileName =
GetNameField(++lpFileName2, (BYTE FAR *) lpFcb->fcb_fext, GetNameField(++lpFileName, (BYTE FAR *) lpFcb->fcb_fext,
FEXT_SIZE, (BOOL *) & wRetCodeExt); FEXT_SIZE, (BOOL *) & wRetCodeExt);
*wTestMode = (wRetCodeName | wRetCodeExt) ? PARSE_RET_WILD : PARSE_RET_NOWILD; *wTestMode = (wRetCodeName | wRetCodeExt) ? PARSE_RET_WILD : PARSE_RET_NOWILD;
return lpFileName2 - lpFileName; return FP_OFF(lpFileName);
} }
const BYTE FAR * ParseSkipWh(const BYTE FAR * lpFileName) const BYTE FAR * ParseSkipWh(const BYTE FAR * lpFileName)
@ -345,8 +344,8 @@ void FcbCalcRec(xfcb FAR * lpXfcb)
/* Now update the fcb and compute where we need to position */ /* Now update the fcb and compute where we need to position */
/* to. */ /* to. */
lpFcb->fcb_cublock = lpFcb->fcb_rndm / 128; lpFcb->fcb_cublock = (UWORD)(lpFcb->fcb_rndm / 128);
lpFcb->fcb_curec = lpFcb->fcb_rndm & 127; lpFcb->fcb_curec = (UBYTE)lpFcb->fcb_rndm & 127;
} }
UBYTE FcbRandomBlockIO(xfcb FAR * lpXfcb, UWORD *nRecords, int mode) UBYTE FcbRandomBlockIO(xfcb FAR * lpXfcb, UWORD *nRecords, int mode)
@ -362,7 +361,7 @@ UBYTE FcbRandomBlockIO(xfcb FAR * lpXfcb, UWORD *nRecords, int mode)
old = lpFcb->fcb_rndm; old = lpFcb->fcb_rndm;
nErrorCode = FcbReadWrite(lpXfcb, *nRecords, mode); nErrorCode = FcbReadWrite(lpXfcb, *nRecords, mode);
*nRecords = lpFcb->fcb_rndm - old; *nRecords = (UWORD)(lpFcb->fcb_rndm - old);
/* Now update the fcb */ /* Now update the fcb */
FcbCalcRec(lpXfcb); FcbCalcRec(lpXfcb);

View File

@ -229,8 +229,8 @@ int int21_fat32(lregs *r)
{ {
case 0x00: case 0x00:
{ {
DWORD nfreeclst = xdffp->xdff_f.setdpbcounts.nfreeclst; ULONG nfreeclst = xdffp->xdff_f.setdpbcounts.nfreeclst;
DWORD cluster = xdffp->xdff_f.setdpbcounts.cluster; ULONG cluster = xdffp->xdff_f.setdpbcounts.cluster;
if (ISFAT32(dpb)) if (ISFAT32(dpb))
{ {
if ((dpb->dpb_xfsinfosec == 0xffff if ((dpb->dpb_xfsinfosec == 0xffff
@ -246,13 +246,13 @@ int int21_fat32(lregs *r)
} }
else else
{ {
if (nfreeclst == 1 || nfreeclst > dpb->dpb_size || if ((unsigned)nfreeclst == 1 || (unsigned)nfreeclst > dpb->dpb_size ||
cluster == 1 || cluster > dpb->dpb_size) (unsigned)cluster == 1 || (unsigned)cluster > dpb->dpb_size)
{ {
return DE_INVLDPARM; return DE_INVLDPARM;
} }
dpb->dpb_nfreeclst = nfreeclst; dpb->dpb_nfreeclst = (UWORD)nfreeclst;
dpb->dpb_cluster = cluster; dpb->dpb_cluster = (UWORD)cluster;
} }
break; break;
} }
@ -294,7 +294,7 @@ int int21_fat32(lregs *r)
bp->b_flag &= ~(BFR_DATA | BFR_DIR | BFR_FAT); bp->b_flag &= ~(BFR_DATA | BFR_DIR | BFR_FAT);
bp->b_flag |= BFR_VALID | BFR_DIRTY; bp->b_flag |= BFR_VALID | BFR_DIRTY;
bpbp = (bpb FAR *) & bp->b_buffer[BT_BPB]; bpbp = (bpb FAR *) & bp->b_buffer[BT_BPB];
bpbp->bpb_xflags = newmirroring; bpbp->bpb_xflags = (UWORD)newmirroring;
} }
goto rebuild_dpb; goto rebuild_dpb;
} }
@ -306,7 +306,7 @@ int int21_fat32(lregs *r)
if (!ISFAT32(dpb) if (!ISFAT32(dpb)
|| (rootclst != -1 || (rootclst != -1
&& (rootclst == 1 && (rootclst == 1
|| rootclst > dpb->dpb_xsize))) || (ULONG)rootclst > dpb->dpb_xsize)))
{ {
return DE_INVLDPARM; return DE_INVLDPARM;
} }
@ -669,9 +669,8 @@ dispatch:
/* Parse File Name */ /* Parse File Name */
case 0x29: case 0x29:
{ {
UWORD offset = FcbParseFname(&rc, MK_FP(lr.DS, lr.SI), FP_ES_DI); lr.SI = FcbParseFname(&rc, MK_FP(lr.DS, lr.SI), FP_ES_DI);
lr.AL = rc; lr.AL = rc;
lr.SI += offset;
} }
break; break;
@ -963,7 +962,7 @@ dispatch:
} }
else else
{ {
lr.DX = (lrc >> 16); lr.DX = (UWORD)(lrc >> 16);
lr.AX = (UWORD) lrc; lr.AX = (UWORD) lrc;
} }
} }
@ -1575,7 +1574,7 @@ dispatch:
{ {
lr.AX = (UWORD)lrc; lr.AX = (UWORD)lrc;
/* action */ /* action */
lr.CX = lrc >> 16; lr.CX = (UWORD)(lrc >> 16);
} }
break; break;
} }

View File

@ -82,7 +82,7 @@ seg far2para(VOID FAR * p)
seg long2para(ULONG size) seg long2para(ULONG size)
{ {
UWORD high = size >> 16; UWORD high = (UWORD)(size >> 16);
if ((UWORD) size > 0xfff0) if ((UWORD) size > 0xfff0)
high++; high++;
return (((UWORD) size + 0x0f) >> 4) + (high << 12); return (((UWORD) size + 0x0f) >> 4) + (high << 12);
@ -104,7 +104,7 @@ VOID FAR * add_far(VOID FAR * fp, ULONG off)
#endif #endif
off += FP_OFF(fp); off += FP_OFF(fp);
off2 = ((off >> 16) << 12) + ((UWORD) off >> 4); off2 = ((UWORD)(off >> 16) << 12) + ((UWORD) off >> 4);
return MK_FP(FP_SEG(fp) + off2, (UWORD) off & 0xf); return MK_FP(FP_SEG(fp) + off2, (UWORD) off & 0xf);
} }

View File

@ -406,7 +406,7 @@ COUNT DosComLoader(BYTE FAR * namep, exec_blk * exp, COUNT mode, COUNT fd)
ULONG com_size_long = SftGetFsize(fd); ULONG com_size_long = SftGetFsize(fd);
/* maximally 64k - 256 bytes stack - /* maximally 64k - 256 bytes stack -
256 bytes psp */ 256 bytes psp */
com_size = (min(com_size_long, 0xfe00u) >> 4) + 0x10; com_size = ((UWORD)min(com_size_long, 0xfe00u) >> 4) + 0x10;
} }
if ((mode & 0x7f) != OVERLAY) if ((mode & 0x7f) != OVERLAY)
@ -668,7 +668,7 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk * exp, COUNT mode, COUNT fd)
mcb FAR *mp = MK_FP(mem - 1, 0); mcb FAR *mp = MK_FP(mem - 1, 0);
/* then the image should be placed as high as possible */ /* then the image should be placed as high as possible */
start_seg = start_seg + mp->m_size - (image_size + 15) / 16; start_seg = start_seg + mp->m_size - (UWORD)((image_size + 15) / 16);
} }
} }
} }

View File

@ -119,7 +119,7 @@ int main(int argc, char **argv)
exit(1); exit(1);
} }
silentSegments[silentcount++] = strtol(argptr + 1, NULL, 0); silentSegments[silentcount++] = (short)strtol(argptr + 1, NULL, 0);
break; break;
default: default:
@ -152,7 +152,7 @@ int main(int argc, char **argv)
printf("Destination file %s could not be created\n", argv[2]); printf("Destination file %s could not be created\n", argv[2]);
return 1; return 1;
} }
start_seg = strtol(argv[3], NULL, 0); start_seg = (UWORD)strtol(argv[3], NULL, 0);
if (header.exExtraBytes == 0) if (header.exExtraBytes == 0)
header.exExtraBytes = 0x200; header.exExtraBytes = 0x200;
printf("header len = %lu = 0x%lx\n", header.exHeaderSize * 16UL, printf("header len = %lu = 0x%lx\n", header.exHeaderSize * 16UL,