Skip to content

Commit

Permalink
Style: Reformat code with ClangFormat 6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
sanssecours committed Sep 7, 2018
1 parent 6f3269d commit d3616b7
Show file tree
Hide file tree
Showing 51 changed files with 227 additions and 86 deletions.
8 changes: 2 additions & 6 deletions .clang-format
Expand Up @@ -14,10 +14,7 @@ BraceWrapping:
BeforeCatch: true
AfterClass: true
AfterControlStatement: true
# We do not add a newline after `enum` since Clang-Format 5 **does not** add a
# newline after `typedef enum`, even if we set `AfterEnum` to true.
# TODO: Enable the option below after we switched to `clang-format-6` or newer.
# AfterEnum: true
AfterEnum: true
AfterFunction: true
AfterNamespace: true
AfterStruct: true
Expand All @@ -33,8 +30,7 @@ ContinuationIndentWidth: 8
Cpp11BracedListStyle: false
DerivePointerAlignment: false
DisableFormat: false
#TODO: Set `FixNamespaceComments` to `true` after we switched to `clang-format-6` or newer.
#FixNamespaceComments: true
FixNamespaceComments: true
FixNamespaceComments: false
IndentCaseLabels: false
IndentWidth: 8
Expand Down
2 changes: 1 addition & 1 deletion doc/news/_preparation_next_release.md
Expand Up @@ -152,7 +152,7 @@ you up to date with the multi-language support provided by Elektra.

## Scripts

- <<TODO>>
- We reformatted the codebase using [`clang-format`](https://clang.llvm.org/docs/ClangFormat.html) 6.0. *(René Schwaiger)*
- <<TODO>>
- <<TODO>>

Expand Down
7 changes: 6 additions & 1 deletion examples/kdbset.c
Expand Up @@ -10,7 +10,12 @@

#include <stdio.h>

typedef enum { INPUT_USE_OURS, INPUT_DO_MERGE, INPUT_USE_THEIRS } input;
typedef enum
{
INPUT_USE_OURS,
INPUT_DO_MERGE,
INPUT_USE_THEIRS
} input;

int showElektraErrorDialog (Key * parentKey, Key * problemKey)
{
Expand Down
4 changes: 2 additions & 2 deletions scripts/docker/debian/sid/Dockerfile
Expand Up @@ -7,8 +7,8 @@ ENV LC_ALL C.UTF-8
RUN apt-get update && apt-get -y install \
curl \
build-essential \
clang-5.0 \
clang-format-5.0 \
clang-6.0 \
clang-format-6.0 \
autotools-dev \
automake \
cmake \
Expand Down
10 changes: 5 additions & 5 deletions scripts/jenkins/Jenkinsfile
Expand Up @@ -68,8 +68,8 @@ CMAKE_FLAGS_BUILD_ALL = [
CMAKE_FLAGS_COVERAGE = ['ENABLE_COVERAGE': 'ON']

CMAKE_FLAGS_CLANG = [
'CMAKE_C_COMPILER': 'clang-5.0',
'CMAKE_CXX_COMPILER': 'clang++-5.0'
'CMAKE_C_COMPILER': 'clang-6.0',
'CMAKE_CXX_COMPILER': 'clang++-6.0'
]

CMAKE_FLAGS_INI = [
Expand Down Expand Up @@ -216,8 +216,8 @@ def dockerInit() {

/* We use the sid image for testing if we are compatible with Debian
* unstable.
* Additionally we use it for tests with Clang-5.0 and for source
* formatting checks (as they depend on Clang-5.0).
* Additionally we use it for tests with Clang-6.0 and for source
* formatting checks (as they depend on Clang-6.0).
*/
DOCKER_IMAGES.sid = createDockerImageDesc(
"debian-sid", this.&idTesting,
Expand Down Expand Up @@ -491,7 +491,7 @@ def generateFullBuildStages() {
[TEST.ALL, TEST.MEM, TEST.INSTALL]
)

// Build Elektra with clang. We use unstable for easy access to clang-5.0
// Build Elektra with clang. We use unstable for easy access to clang-6.0
// Detects problems when using an alternative compiler (clang)
tasks << buildAndTest(
"debian-stable-full-i386",
Expand Down
4 changes: 2 additions & 2 deletions scripts/reformat-source
Expand Up @@ -8,14 +8,14 @@
SCRIPTS_DIR=$(dirname "$0")
. "${SCRIPTS_DIR}/include-common"

CLANG_FORMAT=$(which clang-format-5.0 2> /dev/null)
CLANG_FORMAT=$(which clang-format-6.0 2> /dev/null)

if [ -z "${CLANG_FORMAT}" ]; then
CLANG_FORMAT=$(which clang-format)
fi

if [ -z "${CLANG_FORMAT}" ]; then
echo "Please install clang-format 5, 6, or 7"
echo "Please install clang-format 6, or 7"
exit 0
fi

Expand Down
3 changes: 2 additions & 1 deletion src/bindings/cpp/include/kdbtimer.hpp
Expand Up @@ -23,7 +23,8 @@ class Timer
{
public:
// options what to do at cleanup
enum option_t {
enum option_t
{
raw_data_cerr, ///< print name,data\n (default!)
median_cerr, ///< print name,median\n
quiet, ///< print nothing
Expand Down
13 changes: 8 additions & 5 deletions src/bindings/glib/gelektra-key.c
Expand Up @@ -2,11 +2,14 @@
#include <kdbprivate.h>
#include <string.h>

enum { PROP_0,
PROP_KEY_NAME, ///< property to get the name of the key
PROP_KEY_BASENAME,
PROP_KEY_FULLNAME,
N_PROPERTIES };
enum
{
PROP_0,
PROP_KEY_NAME, ///< property to get the name of the key
PROP_KEY_BASENAME,
PROP_KEY_FULLNAME,
N_PROPERTIES
};

G_DEFINE_TYPE (GElektraKey, gelektra_key, G_TYPE_OBJECT)
static Key * gelektra_key_swap (GElektraKey * key, Key * newkey);
Expand Down
3 changes: 2 additions & 1 deletion src/bindings/io/doc/io_doc.c
Expand Up @@ -236,7 +236,8 @@ typedef struct SomeIoLibHandle
/**
* Example I/O mangement library bitmask flags
*/
typedef enum {
typedef enum
{

/** indicates that the file descriptor is readable */
SOME_IOLIB_READABLE = 1 << 0,
Expand Down
10 changes: 8 additions & 2 deletions src/include/kdbglobal.h
Expand Up @@ -52,9 +52,15 @@
#define GENERATE_STRING(STRING) #STRING,
// clang-format on

typedef enum { FOREACH_POSITION (GENERATE_ENUM) } GlobalpluginPositions;
typedef enum
{
FOREACH_POSITION (GENERATE_ENUM)
} GlobalpluginPositions;

typedef enum { FOREACH_SUBPOSITION (GENERATE_ENUM) } GlobalpluginSubPositions;
typedef enum
{
FOREACH_SUBPOSITION (GENERATE_ENUM)
} GlobalpluginSubPositions;

static const char * GlobalpluginPositionsStr[] ELEKTRA_UNUSED = { FOREACH_POSITION (GENERATE_STRING) };

Expand Down
3 changes: 2 additions & 1 deletion src/include/kdbio.h
Expand Up @@ -62,7 +62,8 @@ typedef void (*ElektraIoTimerCallback) (ElektraIoTimerOperation * timerOp);
/**
* Available flags for file descriptors operation bitmask
*/
typedef enum {
typedef enum
{

/** file descriptor is readable */
ELEKTRA_IO_READABLE = 1 << 0,
Expand Down
3 changes: 2 additions & 1 deletion src/include/kdbio/adapters/zeromq.h
Expand Up @@ -16,7 +16,8 @@


/** callback types */
typedef enum {
typedef enum
{

/** callback is called when socket is readable */
ELEKTRA_IO_ADAPTER_ZEROMQCB_READ = 1 << 0,
Expand Down
3 changes: 2 additions & 1 deletion src/include/kdblogger.h
Expand Up @@ -11,7 +11,8 @@

#include "kdbconfig.h"

enum ElektraLogLevel {
enum ElektraLogLevel
{
/**
* @brief assertion failed, will abort
*
Expand Down
3 changes: 2 additions & 1 deletion src/include/kdbplugin.h
Expand Up @@ -72,7 +72,8 @@
*
* @ingroup backend
*/
typedef enum {
typedef enum
{
// clang-format off
ELEKTRA_PLUGIN_OPEN=1, /*!< Next arg is backend for kdbOpen() */
ELEKTRA_PLUGIN_CLOSE=1<<1, /*!< Next arg is backend for kdbClose() */
Expand Down
3 changes: 2 additions & 1 deletion src/include/kdbpluginprocess.h
Expand Up @@ -17,7 +17,8 @@ extern "C" {
* allow this library to possibly be extended to further commands in
* the future
*/
typedef enum {
typedef enum
{
// clang-format off
ELEKTRA_PLUGINPROCESS_OPEN=1, /*!< Call the plugin's open function */
ELEKTRA_PLUGINPROCESS_CLOSE=1<<1, /*!< Call the plugin's close function */
Expand Down
5 changes: 4 additions & 1 deletion src/include/kdbprivate.h
Expand Up @@ -84,7 +84,10 @@ typedef int (*CloseMapper) (Backend *);
* Key Flags
*****************/

enum { KEY_EMPTY_NAME = 1 << 22 };
enum
{
KEY_EMPTY_NAME = 1 << 22
};

// clang-format off

Expand Down
9 changes: 6 additions & 3 deletions src/include/kdbproposal.h
Expand Up @@ -33,7 +33,8 @@ KeySet * ksRenameKeys (KeySet * config, const Key * name);
*
* @ingroup proposal
*/
enum elektraLockOptions {
enum elektraLockOptions
{
KEY_LOCK_NAME = 1 << 17, ///< lock the name of a key
KEY_LOCK_VALUE = 1 << 18,
KEY_LOCK_META = 1 << 19
Expand All @@ -44,7 +45,8 @@ enum elektraLockOptions {
*
* @ingroup proposal
*/
enum elektraLookupOptions {
enum elektraLookupOptions
{
KDB_O_SPEC = 1 << 15, ///< Use the passed key as specification, instead of looking up the specification first
KDB_O_CREATE = 1 << 16, ///< Create the key if it was not found
KDB_O_NOCASCADING = 1 << 17, ///< Disable cascading search for keys starting with /
Expand All @@ -66,7 +68,8 @@ Key * ksPrev (KeySet * ks);
Key * ksPopAtCursor (KeySet * ks, cursor_t c);


typedef enum {
typedef enum
{
ELEKTRA_REL_BELOW_SAME_NS = 1 << 0, // Below Same Namespace, cascading namespace matches only cascading namespace
ELEKTRA_REL_BELOW_IGNORE_NS = 1 << 1, // Below Ignore Namespace, namespaces are ignored
ELEKTRA_REL_BELOW_CASCADING_NS = 1 << 2, // Below (allow) Cascading Namespace, cascading namespace matches all namespaces
Expand Down
6 changes: 5 additions & 1 deletion src/libs/elektra/kdb.c
Expand Up @@ -536,7 +536,11 @@ static int elektraGetDoUpdate (Split * split, Key * parentKey)
return 0;
}

typedef enum { FIRST, LAST } UpdatePass;
typedef enum
{
FIRST,
LAST
} UpdatePass;

static KeySet * prepareGlobalKS (KeySet * ks, Key * parentKey)
{
Expand Down
3 changes: 2 additions & 1 deletion src/libs/tools/benchmarks/benchmark_crypto_comparison.cpp
Expand Up @@ -21,7 +21,8 @@ extern "C" char ** environ;
// test key is located at src/plugins/crypto/test_key.asc
#define GPG_TEST_KEY_ID "DDEBEF9EE2DC931701338212DAF635B17F230E8D"

enum PluginVariant {
enum PluginVariant
{
NO_CRYPTO = 0, ///< use no crypto variant
CRYPTO_OPENSSL = 1,
CRYPTO_GCRYPT = 2,
Expand Down
3 changes: 2 additions & 1 deletion src/libs/tools/include/merging/mergeconflict.hpp
Expand Up @@ -28,7 +28,8 @@ class InvalidConflictOperation : public ToolException
explicit InvalidConflictOperation (std::string message) : ToolException (message){};
};

enum ConflictOperation {
enum ConflictOperation
{
CONFLICT_ADD, ///< Conflict because of adding key
CONFLICT_DELETE,
CONFLICT_MODIFY,
Expand Down
7 changes: 6 additions & 1 deletion src/libs/tools/include/merging/mergeconflictstrategy.hpp
Expand Up @@ -22,7 +22,12 @@ namespace tools
namespace merging
{

enum ConflictResolutionSide { BASE, OURS, THEIRS };
enum ConflictResolutionSide
{
BASE,
OURS,
THEIRS
};

class MergeConflictStrategy
{
Expand Down
3 changes: 2 additions & 1 deletion src/libs/tools/include/plugindatabase.hpp
Expand Up @@ -55,7 +55,8 @@ class PluginDatabase
// virtual void registerPlugin(PluginSpec) = 0;
// virtual std::vector<PluginSpec> listAllPlugins() const = 0;

enum Status {
enum Status
{
/// does not directly, but can be loaded via provides
provides,
/// exists and working as given
Expand Down
3 changes: 2 additions & 1 deletion src/plugins/boolean/boolean.c
Expand Up @@ -21,7 +21,8 @@
#define DEFAULT_TRUE_VALUE "1"
#define DEFAULT_FALSE_VALUE "0"

typedef enum {
typedef enum
{
TRUE = 1 << 0,
FALSE = 1 << 1,
WARNING = 1 << 2,
Expand Down
3 changes: 2 additions & 1 deletion src/plugins/camel/camel.c
Expand Up @@ -30,7 +30,8 @@
/* -- Data Structures ------------------------------------------------------------------------------------------------------------------- */

/** This enum specifies the possible states of the recursive descent parser. */
typedef enum {
typedef enum
{
/** Unable to open file */
ERROR_FILE_OPEN,
/** Unable to close file */
Expand Down
12 changes: 9 additions & 3 deletions src/plugins/conditionals/conditionals.c
Expand Up @@ -31,7 +31,8 @@

#define REGEX_FLAGS_CONDITION (REG_EXTENDED)

typedef enum {
typedef enum
{
EQU,
NOT,
LT,
Expand All @@ -44,9 +45,14 @@ typedef enum {
OR,
} Comparator;

typedef enum { CONDITION, ASSIGN } Operation;
typedef enum
{
CONDITION,
ASSIGN
} Operation;

typedef enum {
typedef enum
{
TRUE = 1,
FALSE = 0,
ERROR = -1,
Expand Down
6 changes: 4 additions & 2 deletions src/plugins/crypto/crypto.h
Expand Up @@ -17,7 +17,8 @@
* List of flags that are put into the crypto payload header.
* Used to identify the data type of the encrypted content.
*/
enum ElektraCryptoHeaderFlags {
enum ElektraCryptoHeaderFlags
{

/** Regular binary data */
ELEKTRA_CRYPTO_FLAG_NONE = 0,
Expand All @@ -32,7 +33,8 @@ enum ElektraCryptoHeaderFlags {
/**
* Defines the modes of operation of the crypto plugin.
*/
enum ElektraCryptoOperation {
enum ElektraCryptoOperation
{

/** Encryption mode */
ELEKTRA_CRYPTO_ENCRYPT = 0,
Expand Down
6 changes: 4 additions & 2 deletions src/plugins/crypto/gpg.c
Expand Up @@ -30,7 +30,8 @@
/**
* List of states for the state machine that parses the gpg key list output.
*/
enum gpgKeyListState {
enum gpgKeyListState
{
GPG_KEYLIST_STATE_START,
GPG_KEYLIST_STATE_FPR2,
GPG_KEYLIST_STATE_FPR3,
Expand All @@ -42,7 +43,8 @@ enum gpgKeyListState {
* Return codes for the forked child process that starts the gpg binary.
* List of possible errors.
*/
enum gpgCallErrorCode {
enum gpgCallErrorCode
{

/** Failed to duplicate the stdin pipe */
GPG_CALL_DUP_STDIN = 0x4200,
Expand Down

0 comments on commit d3616b7

Please sign in to comment.