Author: pschweitzer
Date: Fri Feb 17 11:08:38 2017
New Revision: 73807
URL:
http://svn.reactos.org/svn/reactos?rev=73807&view=rev
Log:
[FASTFAT]
Fix a few ugly things.
Both Thomas & cppcheck should be happier now!
Modified:
trunk/reactos/drivers/filesystems/fastfat/finfo.c
trunk/reactos/drivers/filesystems/fastfat/rw.c
trunk/reactos/drivers/filesystems/fastfat/vfat.h
Modified: trunk/reactos/drivers/filesystems/fastfat/finfo.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/fastfa…
==============================================================================
--- trunk/reactos/drivers/filesystems/fastfat/finfo.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/fastfat/finfo.c [iso-8859-1] Fri Feb 17 11:08:38
2017
@@ -97,7 +97,7 @@
StandardInfo->Directory = FALSE;
}
StandardInfo->NumberOfLinks = 1;
- StandardInfo->DeletePending = FCB->Flags & FCB_DELETE_PENDING ? TRUE :
FALSE;
+ StandardInfo->DeletePending = BooleanFlagOn(FCB->Flags, FCB_DELETE_PENDING) ?
TRUE : FALSE;
*BufferLength -= sizeof(FILE_STANDARD_INFORMATION);
return STATUS_SUCCESS;
Modified: trunk/reactos/drivers/filesystems/fastfat/rw.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/fastfa…
==============================================================================
--- trunk/reactos/drivers/filesystems/fastfat/rw.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/fastfat/rw.c [iso-8859-1] Fri Feb 17 11:08:38 2017
@@ -547,6 +547,7 @@
LARGE_INTEGER ByteOffset;
PVOID Buffer;
ULONG BytesPerSector;
+ BOOLEAN PagingIo, CanWait;
ASSERT(IrpContext);
@@ -583,9 +584,11 @@
ByteOffset = IrpContext->Stack->Parameters.Read.ByteOffset;
Length = IrpContext->Stack->Parameters.Read.Length;
BytesPerSector = IrpContext->DeviceExt->FatInfo.BytesPerSector;
+ PagingIo = BooleanFlagOn(IrpContext->Irp->Flags, IRP_PAGING_IO);
+ CanWait = BooleanFlagOn(IrpContext->Flags, IRPCONTEXT_CANWAIT);
/* fail if file is a directory and no paged read */
- if (*Fcb->Attributes & FILE_ATTRIBUTE_DIRECTORY &&
!(IrpContext->Irp->Flags & IRP_PAGING_IO))
+ if (*Fcb->Attributes & FILE_ATTRIBUTE_DIRECTORY && !PagingIo)
{
Status = STATUS_INVALID_PARAMETER;
goto ByeBye;
@@ -628,7 +631,7 @@
{
Resource = &IrpContext->DeviceExt->DirResource;
}
- else if (IrpContext->Irp->Flags & IRP_PAGING_IO)
+ else if (PagingIo)
{
Resource = &Fcb->PagingIoResource;
}
@@ -637,15 +640,14 @@
Resource = &Fcb->MainResource;
}
- if (!ExAcquireResourceSharedLite(Resource,
- IrpContext->Flags & IRPCONTEXT_CANWAIT ? TRUE
: FALSE))
+ if (!ExAcquireResourceSharedLite(Resource, CanWait))
{
Resource = NULL;
Status = STATUS_PENDING;
goto ByeBye;
}
- if (!(IrpContext->Irp->Flags & IRP_PAGING_IO) &&
+ if (!PagingIo &&
FsRtlAreThereCurrentFileLocks(&Fcb->FileLock))
{
if (!FsRtlCheckLockForReadAccess(&Fcb->FileLock, IrpContext->Irp))
@@ -655,7 +657,7 @@
}
}
- Buffer = VfatGetUserBuffer(IrpContext->Irp,
BooleanFlagOn(IrpContext->Irp->Flags, IRP_PAGING_IO));
+ Buffer = VfatGetUserBuffer(IrpContext->Irp, PagingIo);
if (!(IrpContext->Irp->Flags & (IRP_NOCACHE|IRP_PAGING_IO)) &&
!(Fcb->Flags & (FCB_IS_PAGE_FILE|FCB_IS_VOLUME)))
@@ -682,11 +684,11 @@
if (!CcCopyRead(IrpContext->FileObject,
&ByteOffset,
Length,
- (IrpContext->Flags & IRPCONTEXT_CANWAIT) != 0,
+ CanWait,
Buffer,
&IrpContext->Irp->IoStatus))
{
- ASSERT((IrpContext->Flags & IRPCONTEXT_CANWAIT) == 0);
+ ASSERT(!CanWait);
Status = STATUS_PENDING;
goto ByeBye;
}
@@ -742,7 +744,7 @@
{
IrpContext->Irp->IoStatus.Status = Status;
if (IrpContext->FileObject->Flags & FO_SYNCHRONOUS_IO &&
- !(IrpContext->Irp->Flags & IRP_PAGING_IO) &&
+ !PagingIo &&
(NT_SUCCESS(Status) || Status == STATUS_END_OF_FILE))
{
IrpContext->FileObject->CurrentByteOffset.QuadPart =
@@ -768,6 +770,7 @@
ULONG Length = 0;
PVOID Buffer;
ULONG BytesPerSector;
+ BOOLEAN PagingIo, CanWait;
ASSERT(IrpContext);
@@ -801,8 +804,11 @@
DPRINT("<%wZ>\n", &Fcb->PathNameU);
+ PagingIo = BooleanFlagOn(IrpContext->Irp->Flags, IRP_PAGING_IO);
+ CanWait = BooleanFlagOn(IrpContext->Flags, IRPCONTEXT_CANWAIT);
+
/* fail if file is a directory and no paged read */
- if (*Fcb->Attributes & FILE_ATTRIBUTE_DIRECTORY &&
!(IrpContext->Irp->Flags & IRP_PAGING_IO))
+ if (*Fcb->Attributes & FILE_ATTRIBUTE_DIRECTORY && !PagingIo)
{
Status = STATUS_INVALID_PARAMETER;
goto ByeBye;
@@ -854,7 +860,7 @@
goto Metadata;
}
- if (IrpContext->Irp->Flags & IRP_PAGING_IO)
+ if (PagingIo)
{
if (ByteOffset.u.LowPart + Length > Fcb->RFCB.AllocationSize.u.LowPart)
{
@@ -872,7 +878,7 @@
{
Resource = &IrpContext->DeviceExt->DirResource;
}
- else if (IrpContext->Irp->Flags & IRP_PAGING_IO)
+ else if (PagingIo)
{
Resource = &Fcb->PagingIoResource;
}
@@ -881,10 +887,9 @@
Resource = &Fcb->MainResource;
}
- if ((Fcb->Flags & FCB_IS_PAGE_FILE) || (IrpContext->Irp->Flags &
IRP_PAGING_IO))
- {
- if (!ExAcquireResourceSharedLite(Resource,
- BooleanFlagOn(IrpContext->Flags,
IRPCONTEXT_CANWAIT)))
+ if ((Fcb->Flags & FCB_IS_PAGE_FILE) || PagingIo)
+ {
+ if (!ExAcquireResourceSharedLite(Resource, CanWait))
{
Resource = NULL;
Status = STATUS_PENDING;
@@ -893,8 +898,7 @@
}
else
{
- if (!ExAcquireResourceExclusiveLite(Resource,
- BooleanFlagOn(IrpContext->Flags,
IRPCONTEXT_CANWAIT)))
+ if (!ExAcquireResourceExclusiveLite(Resource, CanWait))
{
Resource = NULL;
Status = STATUS_PENDING;
@@ -902,7 +906,7 @@
}
}
- if (!(IrpContext->Irp->Flags & IRP_PAGING_IO) &&
+ if (!PagingIo &&
FsRtlAreThereCurrentFileLocks(&Fcb->FileLock))
{
if (!FsRtlCheckLockForWriteAccess(&Fcb->FileLock, IrpContext->Irp))
@@ -912,7 +916,7 @@
}
}
- if (!(IrpContext->Flags & IRPCONTEXT_CANWAIT) && !(Fcb->Flags &
FCB_IS_VOLUME))
+ if (!CanWait && !(Fcb->Flags & FCB_IS_VOLUME))
{
if (ByteOffset.u.LowPart + Length > Fcb->RFCB.AllocationSize.u.LowPart)
{
@@ -921,10 +925,10 @@
}
}
- Buffer = VfatGetUserBuffer(IrpContext->Irp,
BooleanFlagOn(IrpContext->Irp->Flags, IRP_PAGING_IO));
+ Buffer = VfatGetUserBuffer(IrpContext->Irp, PagingIo);
if (!(Fcb->Flags & (FCB_IS_FAT|FCB_IS_VOLUME)) &&
- !(IrpContext->Irp->Flags & IRP_PAGING_IO) &&
+ !PagingIo &&
ByteOffset.u.LowPart + Length > Fcb->RFCB.FileSize.u.LowPart)
{
LARGE_INTEGER AllocationSize;
@@ -961,7 +965,7 @@
if (CcCopyWrite(IrpContext->FileObject,
&ByteOffset,
Length,
- TRUE /*(IrpContext->Flags & IRPCONTEXT_CANWAIT) !=
0*/,
+ TRUE /*CanWait*/,
Buffer))
{
IrpContext->Irp->IoStatus.Information = Length;
@@ -969,7 +973,7 @@
}
else
{
- ASSERT(FALSE /*(IrpContext->Flags & IRPCONTEXT_CANWAIT) == 0*/);
+ ASSERT(FALSE /*!CanWait*/);
Status = STATUS_UNSUCCESSFUL;
}
}
@@ -1002,7 +1006,7 @@
}
Metadata:
- if (!(IrpContext->Irp->Flags & IRP_PAGING_IO) &&
+ if (!PagingIo &&
!(Fcb->Flags & (FCB_IS_FAT|FCB_IS_VOLUME)))
{
if(!(*Fcb->Attributes & FILE_ATTRIBUTE_DIRECTORY))
@@ -1064,7 +1068,7 @@
{
IrpContext->Irp->IoStatus.Status = Status;
if (IrpContext->FileObject->Flags & FO_SYNCHRONOUS_IO &&
- !(IrpContext->Irp->Flags & IRP_PAGING_IO) &&
NT_SUCCESS(Status))
+ !PagingIo && NT_SUCCESS(Status))
{
IrpContext->FileObject->CurrentByteOffset.QuadPart =
ByteOffset.QuadPart + IrpContext->Irp->IoStatus.Information;
Modified: trunk/reactos/drivers/filesystems/fastfat/vfat.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/fastfa…
==============================================================================
--- trunk/reactos/drivers/filesystems/fastfat/vfat.h [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/fastfat/vfat.h [iso-8859-1] Fri Feb 17 11:08:38
2017
@@ -197,9 +197,9 @@
#define LONGNAME_MAX_LENGTH 256 // max length for a long filename
-#define ENTRY_DELETED(DeviceExt, DirEntry) ((DeviceExt)->Flags & VCB_IS_FATX ?
FATX_ENTRY_DELETED(&((DirEntry)->FatX)) :
FAT_ENTRY_DELETED(&((DirEntry)->Fat)))
-#define ENTRY_VOLUME(DeviceExt, DirEntry) ((DeviceExt)->Flags & VCB_IS_FATX ?
FATX_ENTRY_VOLUME(&((DirEntry)->FatX)) :
FAT_ENTRY_VOLUME(&((DirEntry)->Fat)))
-#define ENTRY_END(DeviceExt, DirEntry) ((DeviceExt)->Flags & VCB_IS_FATX ?
FATX_ENTRY_END(&((DirEntry)->FatX)) : FAT_ENTRY_END(&((DirEntry)->Fat)))
+#define ENTRY_DELETED(DeviceExt, DirEntry) (BooleanFlagOn(DeviceExt->Flags,
VCB_IS_FATX) ? FATX_ENTRY_DELETED(&((DirEntry)->FatX)) :
FAT_ENTRY_DELETED(&((DirEntry)->Fat)))
+#define ENTRY_VOLUME(DeviceExt, DirEntry) (BooleanFlagOn(DeviceExt->Flags,
VCB_IS_FATX) ? FATX_ENTRY_VOLUME(&((DirEntry)->FatX)) :
FAT_ENTRY_VOLUME(&((DirEntry)->Fat)))
+#define ENTRY_END(DeviceExt, DirEntry) (BooleanFlagOn(DeviceExt->Flags, VCB_IS_FATX) ?
FATX_ENTRY_END(&((DirEntry)->FatX)) : FAT_ENTRY_END(&((DirEntry)->Fat)))
#define FAT_ENTRY_DELETED(DirEntry) ((DirEntry)->Filename[0] == 0xe5)
#define FAT_ENTRY_END(DirEntry) ((DirEntry)->Filename[0] == 0)