I find it useful to configure emacs cc-mode to follow the Qemu coding style. The relevant bits for your .emacs are:

(defconst qemu-c-style
  '((indent-tabs-mode . nil)
    (c-basic-offset . 4)
    (tab-width . 8)
    (c-comment-only-line-offset . 0)
    (c-hanging-braces-alist . ((substatement-open before after)))
    (c-offsets-alist . ((statement-block-intro . +)
                        (substatement-open . 0)
                        (label . 0)
                        (statement-cont . +)
                        (innamespace . 0)
                        (inline-open . 0)
                        ))
    (c-hanging-braces-alist .
                            ((brace-list-open)
                             (brace-list-intro)
                             (brace-list-entry)
                             (brace-list-close)
                             (brace-entry-open)
                             (block-close . c-snug-do-while)
                             ;; structs have hanging braces on open
                             (class-open . (after))
                             ;; ditto if statements
                             (substatement-open . (after))
                             ;; and no auto newline at the end
                             (class-close)
                             ))
    )
  "QEMU C Programming Style")

and then in a mode hook function you can enable it:

   (c-add-style "qemu" qemu-c-style)

whitespace-mode (in emacs23) is also useful for highlighting stray hardcoded tabs, spaces at end of line and lines longer than 80 columns. This is the line from my custom-set-variables invocation:

 '(whitespace-style (quote (tabs trailing lines space-before-tab newline indentation empty space-after-tab tab-mark newline-mark)))

PeterMaydell/QemuEmacsStyle (last modified 2011-09-19 08:38:00)