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

[Xen-devel] xen source files and linux coding style

  • From: "Mike D. Day" <ncmike@xxxxxxxxxx>
  • Date: Tue, 24 Jan 2006 20:39:50 -0500
  • Delivery-date: Wed, 25 Jan 2006 10:08:25 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xensource.com>

Due to my recent experience submitting a linux patch to lkml, I have
become more knowledgeable wrt linux coding style :) I've noticed a
couple of things in Xen and Xen-linux that we should consider changing
during normal development in preparation for the upstream merge.

The most immediate problem is conforming to the linux indentation
format. In Documentation/CodingStyle there is an emacs C mode for
linux, defined as:

(defun linux-c-mode ()
  "C mode with adjusted defaults for use with the Linux kernel."
  (c-set-style "K&R")
  (setq tab-width 8)
  (setq indent-tabs-mode t)
  (setq c-basic-offset 8))

This is different from what we are using in Xen: 

 * Local variables:
 * mode: C
 * c-set-style: "BSD"
 * c-basic-offset: 4
 * tab-width: 4
 * indent-tabs-mode: nil
 * End:

The biggest problem here is turning tabs off. Tabs need to be used
instead of spaces. As well, the indentation needs to set to 8. 

The second thing I have come across recently are typedefs. Typedefs
are not mentioned in CodingStyle, but I know that they are frowned
upon. The only typedef's that might be "correct" are when using
function pointers, to make the code easier to read. 

I'm certainly not an expert on linux coding style (or CodingStyle) and
will gladly accept any advice or correction on these issues. I find
myself making these changes on files that I know may need to be
submitted to lkml. 

Mike Day

Xen-devel mailing list



Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.