[PATCH] Remove potential reference count races
max at mtew.isa-geek.net
max at mtew.isa-geek.net
Sat Oct 27 20:59:26 CDT 2012
From: Max TenEyck Woodbury <max at mtew.isa-geek.net>
---
dlls/mountmgr.sys/device.c | 16 ++++++++--------
1 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/dlls/mountmgr.sys/device.c b/dlls/mountmgr.sys/device.c
index 8367cba..1947d8d 100644
--- a/dlls/mountmgr.sys/device.c
+++ b/dlls/mountmgr.sys/device.c
@@ -233,7 +233,7 @@ static NTSTATUS create_disk_device( enum device_type type, struct disk_device **
name.MaximumLength = (strlenW(format) + 10) * sizeof(WCHAR);
name.Buffer = RtlAllocateHeap( GetProcessHeap(), 0, name.MaximumLength );
- for (i = first; i < 32; i++)
+ for (i = first; i < 32; ++i)
{
sprintfW( name.Buffer, format, i );
name.Length = strlenW(name.Buffer) * sizeof(WCHAR);
@@ -323,14 +323,14 @@ static void delete_disk_device( struct disk_device *device )
/* grab another reference to a volume */
static struct volume *grab_volume( struct volume *volume )
{
- volume->ref++;
+ InterlockedIncrement(&volume->ref);
return volume;
}
/* release a volume and delete the corresponding disk device when refcount is 0 */
static unsigned int release_volume( struct volume *volume )
{
- unsigned int ret = --volume->ref;
+ unsigned int ret = InterlockedDecrement(volume->ref);
if (!ret)
{
@@ -440,12 +440,12 @@ static struct volume *find_matching_volume( const char *udi, const char *device,
if (device && disk_device->unix_device)
{
if (strcmp( device, disk_device->unix_device )) continue;
- match++;
+ ++match;
}
if (mount_point && disk_device->unix_mount)
{
if (strcmp( mount_point, disk_device->unix_mount )) continue;
- match++;
+ ++match;
}
if (!match) continue;
TRACE( "found matching volume %s for device %s mount %s type %u\n",
@@ -577,7 +577,7 @@ static int add_drive( const char *device, enum device_type type )
while (avail != -1)
{
avail = -1;
- for (drive = first; drive < last; drive++)
+ for (drive = first; drive < last; ++drive)
{
if (in_use[drive]) continue; /* already checked */
*p = 'a' + drive;
@@ -632,7 +632,7 @@ static void create_drive_devices(void)
if (!(path = get_dosdevices_path( &p ))) return;
if (RegOpenKeyW( HKEY_LOCAL_MACHINE, drives_keyW, &drives_key )) drives_key = 0;
- for (i = 0; i < MAX_DOS_DRIVES; i++)
+ for (i = 0; i < MAX_DOS_DRIVES; ++i)
{
p[0] = 'a' + i;
p[2] = 0;
@@ -650,7 +650,7 @@ static void create_drive_devices(void)
if (!RegQueryValueExW( drives_key, driveW, NULL, &type, (BYTE *)buffer, &size ) &&
type == REG_SZ)
{
- for (j = 0; j < sizeof(drive_types)/sizeof(drive_types[0]); j++)
+ for (j = 0; j < sizeof(drive_types)/sizeof(drive_types[0]); ++j)
if (drive_types[j][0] && !strcmpiW( buffer, drive_types[j] ))
{
drive_type = j;
--
1.7.7.6
More information about the wine-patches
mailing list