Re: coding style document

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



We just talked about this and the decisions seem to be:

- for naked classes/structs (simple data containers), use a _d suffix 
instead of _t.  e.g.,

struct my_thing_d {
  uint64_t foo;
  uint32_t bar;
  string name;

  my_thing_d() : foo(0), bar(0) {}

  void encode(bufferlist& bl) const {
    ::encode(foo, bl);
    ::encode(bar, bl);
    ::encode(name, bl);
  }
  void decode(bufferlist::iterator& bl) {
    ::decode(foo, bl);
    ::decode(bar, bl);
    ::decode(name, bl);
  }
};
WRITE_CLASS_ENCODER(my_thing_d)

- for full-blown classes with private members, use m_ prefix.  e.g.

+        class Foo {
+	 public:
+          int get_foo() const { return m_foo; }
+          void set_foo(int foo) { m_foo = foo; }
+
+         private:
+          int m_foo;
+   	};

- for simple ifs,

if (foo) bar;    // bad

if (foo)
  bar;           // better

if (foo) {
  bar;           // best
}

The docuemnt is in wip-codingstyle, see

    http://ceph.newdream.net/git/?p=ceph.git;a=blob;f=CodingStyle;h=fee53b8c5565f570da9298172c770a33138757d1;hb=refs/heads/wip-codingstyle

Earth shattering, I know.  Any final comments/objections before we move 
on?  I'm planning a big cleanup of the userspace Client code next week and 
will be apply the style there.

sage
--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [CEPH Users]     [Ceph Large]     [Information on CEPH]     [Linux BTRFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux