[haiku-commits] r37248 - haiku/trunk/src/system/boot/loader/file_systems/bfs

  • From: axeld@xxxxxxxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Fri, 25 Jun 2010 10:02:38 +0200 (CEST)

Author: axeld
Date: 2010-06-25 10:02:37 +0200 (Fri, 25 Jun 2010)
New Revision: 37248
Changeset: http://dev.haiku-os.org/changeset/37248/haiku

Modified:
   haiku/trunk/src/system/boot/loader/file_systems/bfs/BPlusTree.cpp
   haiku/trunk/src/system/boot/loader/file_systems/bfs/Directory.cpp
Log:
* Fixed warnings.
* Minor cleanup.


Modified: haiku/trunk/src/system/boot/loader/file_systems/bfs/BPlusTree.cpp
===================================================================
--- haiku/trunk/src/system/boot/loader/file_systems/bfs/BPlusTree.cpp   
2010-06-24 23:38:17 UTC (rev 37247)
+++ haiku/trunk/src/system/boot/loader/file_systems/bfs/BPlusTree.cpp   
2010-06-25 08:02:37 UTC (rev 37248)
@@ -1,10 +1,9 @@
-/* BPlusTree - BFS B+Tree implementation
+/*
+ * Copyright 2001-2010, Axel Dörfler, axeld@xxxxxxxxxxxxxxxxx
+ * This file may be used under the terms of the MIT License.
  *
  * Roughly based on 'btlib' written by Marcus J. Ranum - it shares
  * no code but achieves binary compatibility with the on disk format.
- *
- * Copyright 2001-2005, Axel Dörfler, axeld@xxxxxxxxxxxxxxxxx
- * This file may be used under the terms of the MIT License.
  */
 
 
@@ -23,6 +22,7 @@
 
 using namespace BFS;
 
+
 // Node Caching for the BPlusTree class
 //
 // With write support, there is the need for a function that allocates new
@@ -35,6 +35,7 @@
 // Since BFS supports block sizes of 1024 bytes or greater, and the node size
 // is hard-coded to 1024 bytes, that's not an issue now.
 
+
 void 
 CachedNode::Unset()
 {
@@ -68,13 +69,14 @@
                if (!header->IsValidLink(fNode->LeftLink())
                        || !header->IsValidLink(fNode->RightLink())
                        || !header->IsValidLink(fNode->OverflowLink())
-                       || (int8 *)fNode->Values() + fNode->NumKeys() * 
sizeof(off_t) >
-                                       (int8 *)fNode + fTree->fNodeSize) {
+                       || (int8 *)fNode->Values() + fNode->NumKeys() * 
sizeof(off_t)
+                                       > (int8 *)fNode + fTree->fNodeSize) {
                        dprintf("invalid node read from offset %Ld, inode at 
%Ld\n",
                                        offset, fTree->fStream->ID());
                        return NULL;
                }
        }
+
        return fNode;
 }
 
@@ -111,7 +113,8 @@
                        if (fBlock == NULL)
                                return NULL;
                }
-               if (read_pos(volume.Device(), fBlockNumber << 
volume.BlockShift(), fBlock, volume.BlockSize()) < (ssize_t)volume.BlockSize())
+               if (read_pos(volume.Device(), fBlockNumber << 
volume.BlockShift(),
+                               fBlock, volume.BlockSize()) < 
(ssize_t)volume.BlockSize())
                        return NULL;
 
                // the node is somewhere in that block... (confusing offset 
calculation)
@@ -166,13 +169,16 @@
        fNodeSize = fHeader->NodeSize();
 
        {
-               uint32 toMode[] = {S_STR_INDEX, S_INT_INDEX, S_UINT_INDEX, 
S_LONG_LONG_INDEX,
-                                                  S_ULONG_LONG_INDEX, 
S_FLOAT_INDEX, S_DOUBLE_INDEX};
-               uint32 mode = stream->Mode() & (S_STR_INDEX | S_INT_INDEX | 
S_UINT_INDEX | S_LONG_LONG_INDEX
-                                                  | S_ULONG_LONG_INDEX | 
S_FLOAT_INDEX | S_DOUBLE_INDEX);
+               uint32 toMode[] = {S_STR_INDEX, S_INT_INDEX, S_UINT_INDEX,
+                       S_LONG_LONG_INDEX, S_ULONG_LONG_INDEX, S_FLOAT_INDEX,
+                       S_DOUBLE_INDEX};
+               uint32 mode = stream->Mode() & (S_STR_INDEX | S_INT_INDEX
+                       | S_UINT_INDEX | S_LONG_LONG_INDEX | S_ULONG_LONG_INDEX
+                       | S_FLOAT_INDEX | S_DOUBLE_INDEX);
 
                if (fHeader->DataType() > BPLUSTREE_DOUBLE_TYPE
-                       || (stream->Mode() & S_INDEX_DIR) && 
toMode[fHeader->DataType()] != mode
+                       || ((stream->Mode() & S_INDEX_DIR) != 0
+                               && toMode[fHeader->DataType()] != mode)
                        || !stream->IsContainer()) {
                        return fStatus = B_BAD_TYPE;
                }
@@ -181,8 +187,8 @@
                 // although it's in stat.h, the S_ALLOW_DUPS flag is obviously 
unused
                 // in the original BFS code - we will honour it nevertheless
                fAllowDuplicates = ((stream->Mode() & S_INDEX_DIR) == 
S_INDEX_DIR
-                                                       && stream->BlockRun() 
!= stream->Parent())
-                                                       || (stream->Mode() & 
S_ALLOW_DUPS) != 0;
+                               && stream->BlockRun() != stream->Parent())
+                       || (stream->Mode() & S_ALLOW_DUPS) != 0;
 #endif
        }
 
@@ -546,33 +552,32 @@
        bplustree_node *node;
 
 #ifdef BPLUSTREE_SUPPORTS_DUPLICATES
-       if (fDuplicateNode != BPLUSTREE_NULL)
-       {
-               // regardless of traverse direction the duplicates are always 
presented in
-               // the same order; since they are all considered as equal, this 
shouldn't
-               // cause any problems
+       if (fDuplicateNode != BPLUSTREE_NULL) {
+               // regardless of traverse direction the duplicates are always 
presented
+               // in the same order; since they are all considered as equal, 
this
+               // shouldn't cause any problems
 
-               if (!fIsFragment || fDuplicate < fNumDuplicates)
-                       node = 
cached.SetTo(bplustree_node::FragmentOffset(fDuplicateNode), false);
-               else
+               if (!fIsFragment || fDuplicate < fNumDuplicates) {
+                       node = 
cached.SetTo(bplustree_node::FragmentOffset(fDuplicateNode),
+                               false);
+               } else
                        node = NULL;
 
-               if (node != NULL)
-               {
-                       if (!fIsFragment && fDuplicate >= fNumDuplicates)
-                       {
-                               // if the node is out of duplicates, we go 
directly to the next one
+               if (node != NULL) {
+                       if (!fIsFragment && fDuplicate >= fNumDuplicates) {
+                               // if the node is out of duplicates, we go 
directly to the next
+                               // one
                                fDuplicateNode = node->right_link;
                                if (fDuplicateNode != BPLUSTREE_NULL
-                                       && (node = cached.SetTo(fDuplicateNode, 
false)) != NULL)
-                               {
-                                       fNumDuplicates = 
node->CountDuplicates(fDuplicateNode, false);
+                                       && (node = cached.SetTo(fDuplicateNode, 
false)) != NULL) {
+                                       fNumDuplicates
+                                               = 
node->CountDuplicates(fDuplicateNode, false);
                                        fDuplicate = 0;
                                }
                        }
-                       if (fDuplicate < fNumDuplicates)
-                       {
-                               *value = node->DuplicateAt(fDuplicateNode, 
fIsFragment, fDuplicate++);
+                       if (fDuplicate < fNumDuplicates) {
+                               *value = node->DuplicateAt(fDuplicateNode, 
fIsFragment,
+                                       fDuplicate++);
                                if (duplicate)
                                        *duplicate = 2;
                                return B_OK;

Modified: haiku/trunk/src/system/boot/loader/file_systems/bfs/Directory.cpp
===================================================================
--- haiku/trunk/src/system/boot/loader/file_systems/bfs/Directory.cpp   
2010-06-24 23:38:17 UTC (rev 37247)
+++ haiku/trunk/src/system/boot/loader/file_systems/bfs/Directory.cpp   
2010-06-25 08:02:37 UTC (rev 37248)
@@ -1,7 +1,7 @@
 /*
-** Copyright 2003-2004, Axel Dörfler, axeld@xxxxxxxxxxxxxxxxx All rights 
reserved.
-** Distributed under the terms of the OpenBeOS License.
-*/
+ * Copyright 2003-2010, Axel Dörfler, axeld@xxxxxxxxxxxxxxxxx
+ * Distributed under the terms of the MIT License.
+ */
 
 
 #include "Directory.h"
@@ -22,6 +22,7 @@
 
 namespace BFS {
 
+
 Directory::Directory(Volume &volume, block_run run)
        :
        fStream(volume, run),
@@ -170,11 +171,12 @@
        char name[BPLUSTREE_MAX_KEY_LENGTH];
        uint16 length;
        off_t id;
-       while (iterator.GetNextEntry(name, &length, B_FILE_NAME_LENGTH, &id) == 
B_OK) {
+       while (iterator.GetNextEntry(name, &length, B_FILE_NAME_LENGTH, &id)
+                       == B_OK) {
                if (fStream.Mode() & (S_ATTR_DIR | S_INDEX_DIR))
                        return false;
 
-               if (++count > 2 || strcmp(".", name) && strcmp("..", name))
+               if (++count > 2 || (strcmp(".", name) && strcmp("..", name)))
                        return false;
        }
        return true;
@@ -199,4 +201,5 @@
        return fStream.ID();
 }
 
+
 }      // namespace BFS


Other related posts:

  • » [haiku-commits] r37248 - haiku/trunk/src/system/boot/loader/file_systems/bfs - axeld