aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuss Allbery <eagle@eyrie.org>2020-05-17 20:21:59 -0700
committerRuss Allbery <eagle@eyrie.org>2020-05-17 20:21:59 -0700
commit108233784827d54361c99c67eaee9e668010b3c3 (patch)
tree329ad2e791fb27ecc037259c16b922be03e977d0
parent201ac5003d4fba8b15dbb64628782970bd3422fd (diff)
Reformat all C code with clang-format-10
-rw-r--r--.clang-format29
-rw-r--r--Makefile.am8
-rw-r--r--client/internal.h6
-rw-r--r--client/keytab.c3
-rw-r--r--client/krb5.c4
-rw-r--r--client/options.c2
-rw-r--r--client/srvtab.c8
-rw-r--r--client/wallet-rekey.c8
-rw-r--r--client/wallet.c2
9 files changed, 52 insertions, 18 deletions
diff --git a/.clang-format b/.clang-format
new file mode 100644
index 0000000..993594c
--- /dev/null
+++ b/.clang-format
@@ -0,0 +1,29 @@
+# Configuration for clang-format automated reformatting. -*- yaml -*-
+#
+# The canonical version of this file is maintained in the rra-c-util package,
+# which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
+#
+# Copyright 2020 Russ Allbery <eagle@eyrie.org>
+#
+# Copying and distribution of this file, with or without modification, are
+# permitted in any medium without royalty provided the copyright notice
+# and this notice are preserved. This file is offered as-is, without any
+# warranty.
+#
+# SPDX-License-Identifier: FSFAP
+
+---
+Language: Cpp
+BasedOnStyle: LLVM
+AlignConsecutiveMacros: true
+AlignEscapedNewlines: Left
+AlwaysBreakAfterReturnType: AllDefinitions
+BreakBeforeBinaryOperators: NonAssignment
+BreakBeforeBraces: WebKit
+ColumnLimit: 79
+IndentPPDirectives: AfterHash
+IndentWidth: 4
+IndentWrappedFunctionNames: false
+MaxEmptyLinesToKeep: 2
+SpaceAfterCStyleCast: true
+---
diff --git a/Makefile.am b/Makefile.am
index ba7b1be..d5e46a8 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,7 +1,7 @@
# Automake makefile for wallet.
#
# Written by Russ Allbery <eagle@eyrie.org>
-# Copyright 2016, 2018 Russ Allbery <eagle@eyrie.org>
+# Copyright 2016, 2018, 2020 Russ Allbery <eagle@eyrie.org>
# Copyright 2006-2008, 2010, 2013-2014
# The Board of Trustees of the Leland Stanford Junior University
#
@@ -320,3 +320,9 @@ check-cppcheck:
# uninstall from Perl.
distuninstallcheck:
@:
+
+# Used by maintainers to reformat all source code using clang-format and
+# excluding some files.
+reformat:
+ find . -name '*.[ch]' \! -name snprintf.c \! -name krb5-profile.c \
+ -print | xargs clang-format-10 -style=file -i
diff --git a/client/internal.h b/client/internal.h
index 1aed874..2a97ded 100644
--- a/client/internal.h
+++ b/client/internal.h
@@ -12,8 +12,8 @@
#ifndef CLIENT_INTERNAL_H
#define CLIENT_INTERNAL_H 1
-#include <portable/macros.h>
#include <portable/krb5.h>
+#include <portable/macros.h>
#include <sys/types.h>
@@ -22,10 +22,10 @@
* people don't want to use krb5.conf for some reason.
*/
#ifndef WALLET_SERVER
-# define WALLET_SERVER NULL
+# define WALLET_SERVER NULL
#endif
#ifndef WALLET_PORT
-# define WALLET_PORT 0
+# define WALLET_PORT 0
#endif
/* Forward declarations to avoid unnecessary includes. */
diff --git a/client/keytab.c b/client/keytab.c
index ed1bdb9..5bceec5 100644
--- a/client/keytab.c
+++ b/client/keytab.c
@@ -248,8 +248,7 @@ rekey_keytab(struct remctl *r, krb5_context ctx, const char *type,
} else {
merge_keytab(ctx, tempfile, file);
if (unlink(tempfile) < 0)
- syswarn("unlink of temporary keytab file %s failed",
- tempfile);
+ syswarn("unlink of temporary keytab file %s failed", tempfile);
}
}
diff --git a/client/krb5.c b/client/krb5.c
index f0c0ff1..42e20ea 100644
--- a/client/krb5.c
+++ b/client/krb5.c
@@ -47,8 +47,8 @@ kinit(krb5_context ctx, const char *principal)
krb5_get_init_creds_opt_set_default_flags(ctx, "wallet", princ->realm,
opts);
memset(&creds, 0, sizeof(creds));
- status = krb5_get_init_creds_password(ctx, &creds, princ, NULL,
- krb5_prompter_posix, NULL, 0, NULL, opts);
+ status = krb5_get_init_creds_password(
+ ctx, &creds, princ, NULL, krb5_prompter_posix, NULL, 0, NULL, opts);
if (status != 0)
die_krb5(ctx, status, "authentication failed");
diff --git a/client/options.c b/client/options.c
index 7b1f04e..1a85196 100644
--- a/client/options.c
+++ b/client/options.c
@@ -124,7 +124,7 @@ default_options(krb5_context ctx, struct options *options)
/* Having no local realm may be intentional, so don't report an error. */
krb5_get_default_realm(ctx, &realm);
-
+
/* Load the options. */
default_string(ctx, realm, "wallet_type", "wallet", &options->type);
default_string(ctx, realm, "wallet_server", WALLET_SERVER,
diff --git a/client/srvtab.c b/client/srvtab.c
index 5fd39dc..30fb69b 100644
--- a/client/srvtab.c
+++ b/client/srvtab.c
@@ -18,9 +18,9 @@
#include <util/messages.h>
#ifndef KRB5_KRB4_COMPAT
-# define ANAME_SZ 40
-# define INST_SZ 40
-# define REALM_SZ 40
+# define ANAME_SZ 40
+# define INST_SZ 40
+# define REALM_SZ 40
#endif
/*
@@ -51,7 +51,7 @@ write_srvtab(krb5_context ctx, const char *srvtab, const char *principal,
krb5_error_code ret;
size_t length;
char aname[ANAME_SZ + 1] = "";
- char inst[INST_SZ + 1] = "";
+ char inst[INST_SZ + 1] = "";
char realm[REALM_SZ + 1] = "";
char data[ANAME_SZ + 1 + INST_SZ + 1 + REALM_SZ + 1 + 1 + 8];
diff --git a/client/wallet-rekey.c b/client/wallet-rekey.c
index 2aedf57..13e25a8 100644
--- a/client/wallet-rekey.c
+++ b/client/wallet-rekey.c
@@ -3,7 +3,7 @@
*
* Written by Russ Allbery <eagle@eyrie.org>
* and Jon Robertson <jonrober@stanford.edu>
- * Copyright 2018 Russ Allbery <eagle@eyrie.org>
+ * Copyright 2018, 2020 Russ Allbery <eagle@eyrie.org>
* Copyright 2010
* The Board of Trustees of the Leland Stanford Junior University
*
@@ -14,12 +14,12 @@
#include <portable/krb5.h>
#include <portable/system.h>
-#include <remctl.h>
#include <errno.h>
+#include <remctl.h>
#include <client/internal.h>
-#include <util/messages.h>
#include <util/messages-krb5.h>
+#include <util/messages.h>
/*
* Usage message. Use as a format and pass the port number and default server
@@ -41,7 +41,7 @@ Options:\n\
/*
* Display the usage message for wallet-rekey.
*/
-static void __attribute__((__noreturn__))
+__attribute__((__noreturn__)) static void
usage(int status)
{
fprintf((status == 0) ? stdout : stderr, usage_message, WALLET_PORT,
diff --git a/client/wallet.c b/client/wallet.c
index 435f000..cb4ba3d 100644
--- a/client/wallet.c
+++ b/client/wallet.c
@@ -46,7 +46,7 @@ Options:\n\
/*
* Display the usage message for wallet.
*/
-static void __attribute__((__noreturn__))
+__attribute__((__noreturn__)) static void
usage(int status)
{
fprintf((status == 0) ? stdout : stderr, usage_message, WALLET_PORT,