Skip to content
  • Eric Blake's avatar
    checkpatch: Enforce proper do/while (0) style · f4bdc13e
    Eric Blake authored
    
    
    Use of a loop construct for code that is not intended to repeat
    does not make much idiomatic sense, except in one place: it is a
    common usage in macros in order to wrap arbitrary code with
    single-statement semantics.  But when used in a macro, it is more
    typical for the caller to supply the trailing ';' when calling
    the macro.
    
    Although qemu coding style frowns on bare:
      if (cond)
        statement1;
      else
        statement2;
    where extra semicolons actually cause syntax errors, we still
    want our macro styles to be easily copied to other projects.
    Thus, declare it an error if we encounter any form of 'while (0)'
    with a semicolon in the same line.
    
    Signed-off-by: default avatarEric Blake <eblake@redhat.com>
    Message-Id: <20171201232433.25193-8-eblake@redhat.com>
    Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
    f4bdc13e