[haiku-commits] Re: r43033 - haiku/trunk/src/add-ons/kernel/file_systems/bfs

  • From: Axel Dörfler <axeld@xxxxxxxxxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Mon, 31 Oct 2011 18:39:38 +0100

On 10/31/2011 02:33 PM, revol@xxxxxxx wrote:
Log:
Add creation of a be:volume_id attribute on the root node as BeOS did, based on 
a patch by phcoder. Thanks!

Looks almost fine in general, but what happened to the coding style police?

@@ -10,6 +10,7 @@
  #include "Volume.h"
  #include "Journal.h"
  #include "Inode.h"
+#include "Attribute.h"
  #include "Query.h"

The headers are supposed to be ordered alphabetically (not that they were before, though).

@@ -412,19 +413,28 @@
                                // we don't use the vnode layer to access the 
indices node
                        }

-                       // all went fine

Extraneous blank line.

                } else
+                 {
                        FATAL(("could not create root node: publish_vnode() 
failed!\n"));
+                       delete fRootNode;
+                       return status;
+                 }

Arrrgg. The curly braces are all wrong.


-               delete fRootNode;

Extraneous blank line.

        } else {
                status = B_BAD_VALUE;
                FATAL(("could not create root node!\n"));
+               return status;
        }

-       return status;
+       if (!(fFlags&  VOLUME_READ_ONLY)) {
+               Attribute attr(fRootNode);
+               if (attr.Get ("be:volume_id") == B_ENTRY_NOT_FOUND)

No space before '(' here.

  status_t
+Volume::CreateVolumeID()
+{
+       Attribute attr(fRootNode);
+       status_t status;
+       attr_cookie* cookie;
+       status = attr.Create("be:volume_id", B_UINT64_TYPE, O_RDWR,&cookie);

Missing space after comma.

+       if (status == B_OK) {
+               static bool seeded = false;
+               if (!seeded) {
+                       // seed the random number generator for the 
be:volume_id attribute.
+                       srand(time(NULL));
+                       seeded = true;
+               }
+               uint64_t id;
+               size_t len = sizeof (id);

Please call 'len' length, and no space after sizeof.

+               id = ((uint64_t) rand ()<<  32) | rand ();

or rand. Or a cast.

+               Transaction transaction(this, fRootNode->BlockNumber());
+               fRootNode->WriteLockInTransaction(transaction);
+               attr.Write(transaction, cookie, 0, (uint8_t *)&id,&len, NULL);

No space after cast again, no space before the asterisk.
Besides, this is all wrong: it should get the transaction from its caller, or else this won't work right when called from the initializer.

Bye,
   Axel.

Other related posts: