[haiku-commits] r39118 - haiku/trunk/src/system/kernel/fs

  • From: clemens.zeidler@xxxxxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sun, 24 Oct 2010 10:54:21 +0200 (CEST)

Author: czeidler
Date: 2010-10-24 10:54:21 +0200 (Sun, 24 Oct 2010)
New Revision: 39118
Changeset: http://dev.haiku-os.org/changeset/39118

Modified:
   haiku/trunk/src/system/kernel/fs/node_monitor.cpp
Log:
Fix bug when comparing flags. Simplify hash map key. Thanks Ingo!



Modified: haiku/trunk/src/system/kernel/fs/node_monitor.cpp
===================================================================
--- haiku/trunk/src/system/kernel/fs/node_monitor.cpp   2010-10-24 08:15:27 UTC 
(rev 39117)
+++ haiku/trunk/src/system/kernel/fs/node_monitor.cpp   2010-10-24 08:54:21 UTC 
(rev 39118)
@@ -185,22 +185,18 @@
 
                typedef BOpenHashTable<HashDefinition> MonitorHash;
 
-               struct volume_hash_key {
-                       dev_t   device;
-               };
-
                struct VolumeHashDefinition {
-                       typedef volume_hash_key* KeyType;
+                       typedef dev_t KeyType;
                        typedef node_monitor ValueType;
 
-                       size_t HashKey(volume_hash_key* key) const
-                               { return _Hash(key->device); }
+                       size_t HashKey(dev_t key) const
+                               { return _Hash(key); }
                        size_t Hash(node_monitor *monitor) const
                                { return _Hash(monitor->device); }
 
-                       bool Compare(volume_hash_key* key, node_monitor 
*monitor) const
+                       bool Compare(dev_t key, node_monitor *monitor) const
                        {
-                               return key->device == monitor->device;
+                               return key == monitor->device;
                        }
 
                        node_monitor*& GetLink(node_monitor* monitor) const
@@ -290,7 +286,7 @@
 void
 NodeMonitorService::_RemoveMonitor(node_monitor *monitor, uint32 flags)
 {
-       if (flags | B_WATCH_VOLUME)
+       if ((flags & B_WATCH_VOLUME) != 0)
                fVolumeMonitors.Remove(monitor);
        else
                fMonitors.Remove(monitor);
@@ -298,6 +294,7 @@
 }
 
 
+//! Helper function for the RemoveListener function.
 status_t
 NodeMonitorService::_RemoveListener(io_context *context, dev_t device,
        ino_t node, NotificationListener& notificationListener,
@@ -359,13 +356,9 @@
 node_monitor *
 NodeMonitorService::_MonitorFor(dev_t device, ino_t node, bool 
isVolumeListener)
 {
-       if (isVolumeListener) {
-               struct volume_hash_key key;
-               key.device = device;
+       if (isVolumeListener)
+               return fVolumeMonitors.Lookup(device);
 
-               return fVolumeMonitors.Lookup(&key);
-       }
-
        struct monitor_hash_key key;
        key.device = device;
        key.node = node;
@@ -479,7 +472,7 @@
 
        node_monitor *monitor;
        status_t status = _GetMonitor(context, device, node, true, &monitor,
-               flags & B_WATCH_VOLUME);
+               (flags & B_WATCH_VOLUME) != 0);
        if (status < B_OK)
                return status;
 
@@ -501,7 +494,7 @@
 
        node_monitor *monitor;
        status_t status = _GetMonitor(context, device, node, false, &monitor,
-               flags | B_WATCH_VOLUME);
+               (flags & B_WATCH_VOLUME) != 0);
        if (status < B_OK)
                return status;
 
@@ -1006,7 +999,7 @@
 
        node_monitor *monitor;
        status_t status = _GetMonitor(context, device, node, true, &monitor,
-               flags | B_WATCH_VOLUME);
+               (flags & B_WATCH_VOLUME) != 0);
        if (status < B_OK)
                return status;
 


Other related posts:

  • » [haiku-commits] r39118 - haiku/trunk/src/system/kernel/fs - clemens . zeidler