]> eyrie.org Git - kerberos/krb5-strength.git/commitdiff
Reformat with clang-format
authorRuss Allbery <eagle@eyrie.org>
Sat, 16 May 2020 19:26:56 +0000 (12:26 -0700)
committerRuss Allbery <eagle@eyrie.org>
Sat, 16 May 2020 19:26:56 +0000 (12:26 -0700)
Import the clang-format rules and Makefile target from rra-c-util
8.2.  Exclude the cracklib directory.

Complete a mangled comment in the SQLite dictionary implementation.

42 files changed:
.clang-format [new file with mode: 0644]
Makefile.am
plugin/cdb.c
plugin/classes.c
plugin/config.c
plugin/cracklib.c
plugin/error.c
plugin/heimdal.c
plugin/internal.h
plugin/mit.c
plugin/sqlite.c
plugin/vector.c
portable/asprintf.c
portable/kadmin.h
portable/krb5-extra.c
portable/krb5.h
portable/macros.h
portable/mkstemp.c
portable/reallocarray.c
portable/stdbool.h
portable/strndup.c
portable/system.h
tests/plugin/heimdal-t.c
tests/plugin/mit-t.c
tests/portable/snprintf-t.c
tests/runtests.c
tests/tap/basic.c
tests/tap/basic.h
tests/tap/kerberos.c
tests/tap/kerberos.h
tests/tap/macros.h
tests/tap/process.c
tests/tap/process.h
tests/tap/string.h
tests/util/messages-krb5-t.c
tests/util/messages-t.c
tests/util/xmalloc.c
tools/heimdal-strength.c
util/messages-krb5.c
util/messages.c
util/xmalloc.c
util/xmalloc.h

diff --git a/.clang-format b/.clang-format
new file mode 100644 (file)
index 0000000..993594c
--- /dev/null
@@ -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
+---
index 1636bef1e2df39f60cb667bef8aeb129ec2995b3..454879fad227535b6db6445932a30239b3dfb706 100644 (file)
@@ -1,15 +1,15 @@
 # Automake makefile for krb5-strength.
 #
 # Written by Russ Allbery <eagle@eyrie.org>
-# Copyright 2016 Russ Allbery <eagle@eyrie.org>
-# Copyright 2007, 2009, 2010, 2012, 2013, 2014
+# Copyright 2016, 2020 Russ Allbery <eagle@eyrie.org>
+# Copyright 2007, 2009-2010, 2012-2014
 #     The Board of Trustees of the Leland Stanford Junior University
 #
 # See LICENSE for licensing terms.
 
 ACLOCAL_AMFLAGS = -I m4
-EXTRA_DIST = .gitignore .travis.yml README.md LICENSE bootstrap                    \
-       cracklib/HISTORY cracklib/LICENCE cracklib/README                   \
+EXTRA_DIST = .clang-format .gitignore .travis.yml README.md LICENSE        \
+       bootstrap cracklib/HISTORY cracklib/LICENCE cracklib/README         \
        cracklib/genrules.pl cracklib/mkdict docs/krb5-strength.5.in        \
        docs/krb5-strength.pod docs/metadata tests/README tests/TESTS       \
        tests/data/krb5.conf tests/data/make-krb5-conf tests/data/passwords \
@@ -208,3 +208,11 @@ check-valgrind: $(check_PROGRAMS) tests/data/dictionary.pwd
            --suppressions=$(abs_top_srcdir)/tests/data/valgrind.supp   \
            --trace-children-skip="/bin/sh,*/cat,*/diff,*/expr,*/grep,*/mkdir,*/rm,*/rmdir,*/sed,*/sleep,*/true,*/wc,*/docs/*-t,*/perl/*-t,*/data/make-krb5-conf,*/tools/heimdal-history-t,*/tools/wordlist*-t" \
            tests/runtests -l '$(abs_top_srcdir)/tests/TESTS'
+
+
+# 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 \
+           \! -path './cracklib/*' -print                                \
+           | xargs clang-format-10 -style=file -i
index 92e08eb13dfdd6e78d2b0d0d73ef1b58c670da1d..d4119177ed20a6b3ce63e7659e5b42562d89d398 100644 (file)
@@ -21,7 +21,7 @@
 #include <portable/system.h>
 
 #ifdef HAVE_CDB_H
-# include <cdb.h>
+#    include <cdb.h>
 #endif
 #include <errno.h>
 #include <fcntl.h>
@@ -47,8 +47,9 @@ strength_init_cdb(krb5_context ctx, krb5_pwqual_moddata data UNUSED)
     if (path == NULL)
         return 0;
     free(path);
-    krb5_set_error_message(ctx, KADM5_BAD_SERVER_PARAMS, "CDB dictionary"
-                           " requested but not built with CDB support");
+    krb5_set_error_message(ctx, KADM5_BAD_SERVER_PARAMS,
+                           "CDB dictionary requested but not built with CDB"
+                           " support");
     return KADM5_BAD_SERVER_PARAMS;
 }
 #endif
@@ -57,21 +58,6 @@ strength_init_cdb(krb5_context ctx, krb5_pwqual_moddata data UNUSED)
 /* Skip the rest of this file if CDB is not available. */
 #ifdef HAVE_CDB
 
-/*
- * Macro used to make password checks more readable.  Assumes that the found
- * and fail labels are available for the abort cases of finding a password or
- * failing to look it up.
- */
-# define CHECK_PASSWORD(ctx, data, password)                    \
-    do {                                                        \
-        code = in_cdb_dictionary(ctx, data, password, &found);  \
-        if (code != 0)                                          \
-            goto fail;                                          \
-        if (found)                                              \
-            goto found;                                         \
-    } while (0)
-
-
 /*
  * Look up a password in CDB and set the found parameter to true if it is
  * found, false otherwise.  Returns a Kerberos status code, which will be 0 on
@@ -130,6 +116,21 @@ strength_init_cdb(krb5_context ctx, krb5_pwqual_moddata data)
 }
 
 
+/*
+ * Macro used to make password checks more readable.  Assumes that the found
+ * and fail labels are available for the abort cases of finding a password or
+ * failing to look it up.
+ */
+#    define CHECK_PASSWORD(ctx, data, password)                    \
+        do {                                                       \
+            code = in_cdb_dictionary(ctx, data, password, &found); \
+            if (code != 0)                                         \
+                goto fail;                                         \
+            if (found)                                             \
+                goto found;                                        \
+        } while (0)
+
+
 /*
  * Given a password, try the various transformations that we want to apply and
  * check for each of them in the dictionary.  Returns a Kerberos status code,
index bf9ef019888820a2c6626621397cdc42575f827a..3bded464ac33d7390d1bd296108b459d36552666 100644 (file)
@@ -48,10 +48,14 @@ analyze_password(const char *password, struct password_classes *classes)
         else
             classes->symbol = true;
     }
-    if (classes->lower)  classes->num_classes++;
-    if (classes->upper)  classes->num_classes++;
-    if (classes->digit)  classes->num_classes++;
-    if (classes->symbol) classes->num_classes++;
+    if (classes->lower)
+        classes->num_classes++;
+    if (classes->upper)
+        classes->num_classes++;
+    if (classes->digit)
+        classes->num_classes++;
+    if (classes->symbol)
+        classes->num_classes++;
 }
 
 
index 0114740ad480f7bcaaa575d1614df2f927295f5a..147d3f6522b57ee4eee40178c4af1f8fc0f6f955 100644 (file)
@@ -187,8 +187,10 @@ parse_class(krb5_context ctx, const char *spec, struct class_rule **rule)
         if (okay)
             spec = end + 1;
         else {
-            code = strength_error_config(ctx, "bad character class requirement"
-                                         " in configuration: %s", spec);
+            code = strength_error_config(ctx,
+                                         "bad character class requirement in"
+                                         " configuration: %s",
+                                         spec);
             goto fail;
         }
     }
@@ -214,15 +216,16 @@ parse_class(krb5_context ctx, const char *spec, struct class_rule **rule)
             (*rule)->digit = true;
         else if (strcmp(class, "symbol") == 0)
             (*rule)->symbol = true;
-       else if (isdigit((unsigned char) *class)) {
-           okay = parse_number(class, &(*rule)->num_classes, &end);
-           if (!okay || *end != '\0' || (*rule)->num_classes > MAX_CLASSES) {
-                code = strength_error_config(ctx, "bad character class minimum"
-                                             " in configuration: %s", class);
-               goto fail;
-           }
-       }
-        else {
+        else if (isdigit((unsigned char) *class)) {
+            okay = parse_number(class, &(*rule)->num_classes, &end);
+            if (!okay || *end != '\0' || (*rule)->num_classes > MAX_CLASSES) {
+                code = strength_error_config(ctx,
+                                             "bad character class minimum in"
+                                             " configuration: %s",
+                                             class);
+                goto fail;
+            }
+        } else {
             code = strength_error_config(ctx, "unknown character class %s",
                                          class);
             goto fail;
@@ -302,8 +305,7 @@ fail:
  * allocation failed while parsing or while setting the default value.
  */
 krb5_error_code
-strength_config_list(krb5_context ctx, const char *opt,
-                     struct vector **result)
+strength_config_list(krb5_context ctx, const char *opt, struct vector **result)
 {
     realm_type realm;
     char *value = NULL;
index 8efa27913475eac34723f667dc5848fe36aeb3ef..76d02617cfae94d3fef70d4b506bb8b218cff887 100644 (file)
 
 /* When using the embedded CrackLib, we need to provide our own prototype. */
 #ifdef HAVE_CRACKLIB
-# ifdef HAVE_CRACK_H
-#  include <crack.h>
-# else
+#    ifdef HAVE_CRACK_H
+#        include <crack.h>
+#    else
 extern const char *FascistCheck(const char *password, const char *dict);
-# endif
+#    endif
 #endif
 
 
@@ -49,8 +49,9 @@ strength_init_cracklib(krb5_context ctx, krb5_pwqual_moddata data UNUSED,
     if (path == NULL)
         return 0;
     free(path);
-    krb5_set_error_message(ctx, KADM5_BAD_SERVER_PARAMS, "CrackLib dictionary"
-                           " requested but not built with CrackLib support");
+    krb5_set_error_message(ctx, KADM5_BAD_SERVER_PARAMS,
+                           "CrackLib dictionary requested but not built with"
+                           " CrackLib support");
     return KADM5_BAD_SERVER_PARAMS;
 }
 #endif
index ba51366736bc16adc0f8f56418a09895ef74e4ce..d509c052d6b3ed60d350af3d6827ae3966946ed1 100644 (file)
@@ -50,20 +50,20 @@ set_error(krb5_context ctx, krb5_error_code code, const char *format,
  * and variable arguments and set the Kerberos error code and message,
  * returning the appropriate code.
  */
-#define ERROR_FUNC(name, code)                                          \
-    krb5_error_code                                                     \
-    strength_error_ ## name(krb5_context ctx, const char *format, ...)  \
-    {                                                                   \
-        va_list args;                                                   \
-        va_start(args, format);                                         \
-        set_error(ctx, code, format, args);                             \
-        va_end(args);                                                   \
-        return code;                                                    \
+#define ERROR_FUNC(name, code)                                     \
+    krb5_error_code strength_error_##name(krb5_context ctx,        \
+                                          const char *format, ...) \
+    {                                                              \
+        va_list args;                                              \
+        va_start(args, format);                                    \
+        set_error(ctx, code, format, args);                        \
+        va_end(args);                                              \
+        return code;                                               \
     }
-ERROR_FUNC(class,    KADM5_PASS_Q_CLASS)
-ERROR_FUNC(config,   KADM5_MISSING_KRB5_CONF_PARAMS)
-ERROR_FUNC(dict,     KADM5_PASS_Q_DICT)
-ERROR_FUNC(generic,  KADM5_PASS_Q_GENERIC)
+ERROR_FUNC(class, KADM5_PASS_Q_CLASS)
+ERROR_FUNC(config, KADM5_MISSING_KRB5_CONF_PARAMS)
+ERROR_FUNC(dict, KADM5_PASS_Q_DICT)
+ERROR_FUNC(generic, KADM5_PASS_Q_GENERIC)
 ERROR_FUNC(tooshort, KADM5_PASS_Q_TOOSHORT)
 
 
index 52c81975d808495cc663f5ea1fe114b6d55282b2..aa0d29b92b629b06461c1ea4b6333b48abaa8469 100644 (file)
@@ -12,6 +12,7 @@
  * instead.
  *
  * Written by Russ Allbery <eagle@eyrie.org>
+ * Copyright 2020 Russ Allbery <eagle@eyrie.org>
  * Copyright 2009, 2013
  *     The Board of Trustees of the Leland Stanford Junior University
  *
@@ -24,7 +25,7 @@
 
 #include <errno.h>
 #ifdef HAVE_KADM5_KADM5_PWCHECK_H
-# include <kadm5/kadm5-pwcheck.h>
+#    include <kadm5/kadm5-pwcheck.h>
 #endif
 
 #include <plugin/internal.h>
@@ -60,8 +61,8 @@ convert_error(krb5_context ctx, krb5_error_code code, const char *prefix,
  */
 static int
 heimdal_pwcheck(krb5_context ctx, krb5_principal principal,
-                krb5_data *password, const char *tuning UNUSED,
-                char *message, size_t length)
+                krb5_data *password, const char *tuning UNUSED, char *message,
+                size_t length)
 {
     krb5_pwqual_moddata data = NULL;
     char *pastring = NULL;
@@ -107,9 +108,10 @@ done:
 }
 
 /* The public symbol that Heimdal looks for. */
+/* clang-format off */
 static struct kadm5_pw_policy_check_func functions[] = {
-    { "krb5-strength", heimdal_pwcheck },
-    { NULL, NULL }
+    {"krb5-strength", heimdal_pwcheck},
+    {NULL, NULL}
 };
 struct kadm5_pw_policy_verifier kadm5_password_verifier = {
     "krb5-strength",
@@ -117,5 +119,6 @@ struct kadm5_pw_policy_verifier kadm5_password_verifier = {
     "Russ Allbery",
     functions
 };
+/* clang-format on */
 
 #endif /* HAVE_KRB5_REALM */
index eb58c6530b2d89d377619ad80e3b3309a1fdafce..1d3d4f4c6fd7b815b2e15c2966e5cbb412991d85 100644 (file)
 #include <portable/macros.h>
 
 #ifdef HAVE_CDB_H
-# include <cdb.h>
+#    include <cdb.h>
 #endif
 #ifdef HAVE_SQLITE3_H
-# include <sqlite3.h>
+#    include <sqlite3.h>
 #endif
 #include <stddef.h>
 
 #ifdef HAVE_KRB5_PWQUAL_PLUGIN_H
-# include <krb5/pwqual_plugin.h>
+#    include <krb5/pwqual_plugin.h>
 #else
 typedef struct krb5_pwqual_moddata_st *krb5_pwqual_moddata;
 #endif
 
 /* Error strings returned (and displayed to the user) for various failures. */
-#define ERROR_ASCII        "Password contains non-ASCII or control characters"
-#define ERROR_CLASS_LOWER  "Password must contain a lowercase letter"
-#define ERROR_CLASS_UPPER  "Password must contain an uppercase letter"
-#define ERROR_CLASS_DIGIT  "Password must contain a number"
+#define ERROR_ASCII       "Password contains non-ASCII or control characters"
+#define ERROR_CLASS_LOWER "Password must contain a lowercase letter"
+#define ERROR_CLASS_UPPER "Password must contain an uppercase letter"
+#define ERROR_CLASS_DIGIT "Password must contain a number"
 #define ERROR_CLASS_SYMBOL \
     "Password must contain a space or punctuation character"
-#define ERROR_CLASS_MIN \
+#define ERROR_CLASS_MIN                                                    \
     "Password must contain %lu types of characters (lowercase, uppercase," \
     " numbers, symbols)"
-#define ERROR_DICT         "Password found in list of common passwords"
-#define ERROR_LETTER       "Password is only letters and spaces"
-#define ERROR_MINDIFF      "Password does not contain enough unique characters"
-#define ERROR_SHORT        "Password is too short"
-#define ERROR_USERNAME     "Password based on username or principal"
+#define ERROR_DICT     "Password found in list of common passwords"
+#define ERROR_LETTER   "Password is only letters and spaces"
+#define ERROR_MINDIFF  "Password does not contain enough unique characters"
+#define ERROR_SHORT    "Password is too short"
+#define ERROR_USERNAME "Password based on username or principal"
 
 /*
  * A character class rule, which consists of a minimum length to which the
@@ -78,17 +78,17 @@ struct vector {
  * checking for at least the MIT plugin.
  */
 struct krb5_pwqual_moddata_st {
-    long minimum_different;     /* Minimum number of different characters */
-    long minimum_length;        /* Minimum password length */
-    bool ascii;                 /* Whether to require printable ASCII */
-    bool nonletter;             /* Whether to require a non-letter */
-    struct class_rule *rules;   /* Linked list of character class rules */
-    char *dictionary;           /* Base path to CrackLib dictionary */
-    long cracklib_maxlen;       /* Longer passwords skip CrackLib checks */
-    bool have_cdb;              /* Whether we have a CDB dictionary */
-    int cdb_fd;                 /* File descriptor of CDB dictionary */
+    long minimum_different;   /* Minimum number of different characters */
+    long minimum_length;      /* Minimum password length */
+    bool ascii;               /* Whether to require printable ASCII */
+    bool nonletter;           /* Whether to require a non-letter */
+    struct class_rule *rules; /* Linked list of character class rules */
+    char *dictionary;         /* Base path to CrackLib dictionary */
+    long cracklib_maxlen;     /* Longer passwords skip CrackLib checks */
+    bool have_cdb;            /* Whether we have a CDB dictionary */
+    int cdb_fd;               /* File descriptor of CDB dictionary */
 #ifdef HAVE_CDB_H
-    struct cdb cdb;             /* Open CDB dictionary data */
+    struct cdb cdb; /* Open CDB dictionary data */
 #endif
 #ifdef HAVE_SQLITE3_H
     sqlite3 *sqlite;            /* Open SQLite database handle */
@@ -131,8 +131,8 @@ krb5_error_code strength_check_cdb(krb5_context, krb5_pwqual_moddata,
                                    const char *password);
 void strength_close_cdb(krb5_context, krb5_pwqual_moddata);
 #else
-# define strength_check_cdb(c, d, p) 0
-# define strength_close_cdb(c, d)    /* empty */
+#    define strength_check_cdb(c, d, p) 0
+#    define strength_close_cdb(c, d)    /* empty */
 #endif
 
 /*
@@ -150,7 +150,7 @@ krb5_error_code strength_init_cracklib(krb5_context, krb5_pwqual_moddata,
 krb5_error_code strength_check_cracklib(krb5_context, krb5_pwqual_moddata,
                                         const char *password);
 #else
-# define strength_check_cracklib(c, d, p) 0
+#    define strength_check_cracklib(c, d, p) 0
 #endif
 
 /*
@@ -168,8 +168,8 @@ krb5_error_code strength_check_sqlite(krb5_context, krb5_pwqual_moddata,
                                       const char *password);
 void strength_close_sqlite(krb5_context, krb5_pwqual_moddata);
 #else
-# define strength_check_sqlite(c, d, p) 0
-# define strength_close_sqlite(c, d)    /* empty */
+#    define strength_check_sqlite(c, d, p) 0
+#    define strength_close_sqlite(c, d)    /* empty */
 #endif
 
 /* Check whether the password statisfies character class requirements. */
@@ -185,8 +185,7 @@ krb5_error_code strength_check_principal(krb5_context, krb5_pwqual_moddata,
  * Manage vectors, which are counted lists of strings.  The functions that
  * return a boolean return false if memory allocation fails.
  */
-struct vector *strength_vector_new(void)
-    __attribute__((__malloc__));
+struct vector *strength_vector_new(void) __attribute__((__malloc__));
 bool strength_vector_add(struct vector *, const char *string)
     __attribute__((__nonnull__));
 void strength_vector_free(struct vector *);
index d68ad574f6708cefbdde7099b1cc064cfc96f574..0bacfb05482a4ae9319782a72f0696513c9405d6 100644 (file)
@@ -19,7 +19,7 @@
 
 #include <errno.h>
 #ifdef HAVE_KRB5_PWQUAL_PLUGIN_H
-# include <krb5/pwqual_plugin.h>
+#    include <krb5/pwqual_plugin.h>
 #endif
 
 #include <plugin/internal.h>
index 92ceb5f82ac688dcb913a515eb15bb0540b12c7a..cb821ab1f924374fededb40fc8c5aec81d272152 100644 (file)
@@ -29,7 +29,7 @@
  *
  * Written by Russ Allbery <eagle@eyrie.org>
  * Based on work by David Mazières
- * Copyright 2016 Russ Allbery <eagle@eyrie.org>
+ * Copyright 2016, 2020 Russ Allbery <eagle@eyrie.org>
  * Copyright 2014
  *     The Board of Trustees of the Leland Stanford Junior University
  *
@@ -42,7 +42,7 @@
 #include <portable/system.h>
 
 #ifdef HAVE_SQLITE3_H
-# include <sqlite3.h>
+#    include <sqlite3.h>
 #endif
 
 #include <plugin/internal.h>
  * prefix and the prefix with the last character incremented; the suffix query
  * gets the same, but the suffix should be reversed.
  */
+/* clang-format off */
 #define PREFIX_QUERY \
     "SELECT password, drowssap FROM passwords WHERE password BETWEEN ? AND ?;"
 #define SUFFIX_QUERY \
     "SELECT password, drowssap FROM passwords WHERE drowssap BETWEEN ? AND ?;"
+/* clang-format on */
 
 
 /*
@@ -76,8 +78,9 @@ strength_init_sqlite(krb5_context ctx, krb5_pwqual_moddata data UNUSED)
     if (path == NULL)
         return 0;
     free(path);
-    krb5_set_error_message(ctx, KADM5_BAD_SERVER_PARAMS, "SQLite dictionary"
-                           " requested but not built with SQLite support");
+    krb5_set_error_message(ctx, KADM5_BAD_SERVER_PARAMS,
+                           "SQLite dictionary requested but not built with"
+                           " SQLite support");
     return KADM5_BAD_SERVER_PARAMS;
 }
 #endif
@@ -100,7 +103,7 @@ error_sqlite(krb5_context ctx, krb5_pwqual_moddata data, const char *format,
     ssize_t length;
     char *message;
     const char *errmsg;
-    
+
     errmsg = sqlite3_errmsg(data->sqlite);
     va_start(args, format);
     length = vasprintf(&message, format, args);
@@ -163,10 +166,10 @@ common_prefix_length(const char *a, const char *b)
  *
  * To see why the sum of the prefix and suffix length can be longer than the
  * length of the password when the password doesn't match the word, consider
- * the password "aaaa" and the word "aaaaaaaaa"
- * (The prefix length plus the
+ * the password "aaaa" and the word "aaaaaaaaa".  The prefix length plus the
  * suffix length may be greater than the length of the password if the
- * password is an exact match for the word or 
+ * password is an exact match for the word or an initial or final substring of
+ * the word.
  */
 static bool
 match(size_t length, const char *password, const char *drowssap,
@@ -295,8 +298,8 @@ strength_check_sqlite(krb5_context ctx, krb5_pwqual_moddata data,
         goto fail;
     }
     prefix[prefix_length - 1]++;
-    status = sqlite3_bind_text(data->prefix_query, 2, prefix, prefix_length,
-                               NULL);
+    status =
+        sqlite3_bind_text(data->prefix_query, 2, prefix, prefix_length, NULL);
     if (status != SQLITE_OK) {
         code = error_sqlite(ctx, data, "cannot bind prefix end");
         goto fail;
index b7895beb02315318f812670932ccc1e449af7503..d85518cba027673b881fca6e9bb4dbb5cdbe8da4 100644 (file)
@@ -181,7 +181,7 @@ split_multi_count(const char *string, const char *seps)
  */
 struct vector *
 strength_vector_split_multi(const char *string, const char *seps,
-                        struct vector *vector)
+                            struct vector *vector)
 {
     const char *p, *start;
     size_t i, count;
@@ -206,7 +206,7 @@ strength_vector_split_multi(const char *string, const char *seps,
     for (start = string, p = string, i = 0; *p != '\0'; p++)
         if (strchr(seps, *p) != NULL) {
             if (start != p) {
-                vector->strings[i] = strndup(start, (size_t) (p - start));
+                vector->strings[i] = strndup(start, (size_t)(p - start));
                 if (vector->strings[i] == NULL)
                     goto fail;
                 i++;
@@ -217,7 +217,7 @@ strength_vector_split_multi(const char *string, const char *seps,
 
     /* If there is anything left in the string, we have one more component. */
     if (start != p) {
-        vector->strings[i] = strndup(start, (size_t) (p - start));
+        vector->strings[i] = strndup(start, (size_t)(p - start));
         if (vector->strings[i] == NULL)
             goto fail;
         vector->count++;
index 83fdaa78c33e36aeb9ebcc876baa2e3f1782a321..10641c61ceb7864bea3e337a1f536aa3b3287a79 100644 (file)
  * with the system versions.
  */
 #if TESTING
-# undef asprintf
-# undef vasprintf
-# define asprintf test_asprintf
-# define vasprintf test_vasprintf
+#    undef asprintf
+#    undef vasprintf
+#    define asprintf  test_asprintf
+#    define vasprintf test_vasprintf
 int test_asprintf(char **, const char *, ...)
     __attribute__((__format__(printf, 2, 3)));
 int test_vasprintf(char **, const char *, va_list)
index 6acb3a8e3add68a749d441f98e07ee6044612e76..e3753d582597ab8ca3414c4304190c40ed4fb2d1 100644 (file)
@@ -26,9 +26,9 @@
 
 #include <kadm5/admin.h>
 #ifdef HAVE_KADM5_KADM5_ERR_H
-# include <kadm5/kadm5_err.h>
+#    include <kadm5/kadm5_err.h>
 #else
-# include <kadm5/kadm_err.h>
+#    include <kadm5/kadm_err.h>
 #endif
 
 /*
  * general just in case.)
  */
 #ifndef KADM5_API_VERSION
-# ifdef KADM5_API_VERSION_3
-#  define KADM5_API_VERSION KADM5_API_VERSION_3
-# else
-#  define KADM5_API_VERSION KADM5_API_VERSION_2
-# endif
+#    ifdef KADM5_API_VERSION_3
+#        define KADM5_API_VERSION KADM5_API_VERSION_3
+#    else
+#        define KADM5_API_VERSION KADM5_API_VERSION_2
+#    endif
 #endif
 
 /* Heimdal doesn't define KADM5_PASS_Q_GENERIC. */
 #ifndef KADM5_PASS_Q_GENERIC
-# define KADM5_PASS_Q_GENERIC KADM5_PASS_Q_DICT
+#    define KADM5_PASS_Q_GENERIC KADM5_PASS_Q_DICT
 #endif
 
 /* Heimdal doesn't define KADM5_MISSING_KRB5_CONF_PARAMS. */
 #ifndef KADM5_MISSING_KRB5_CONF_PARAMS
-# define KADM5_MISSING_KRB5_CONF_PARAMS KADM5_MISSING_CONF_PARAMS
+#    define KADM5_MISSING_KRB5_CONF_PARAMS KADM5_MISSING_CONF_PARAMS
 #endif
 
 #endif /* !PORTABLE_KADMIN_H */
index 01993711e142033a1c67b21378dca0a335bb50b6..c36f288efee15c77b8837a98a6e080452a258b3a 100644 (file)
 
 /* Figure out what header files to include for error reporting. */
 #if !defined(HAVE_KRB5_GET_ERROR_MESSAGE) && !defined(HAVE_KRB5_GET_ERR_TEXT)
-# if !defined(HAVE_KRB5_GET_ERROR_STRING)
-#  if defined(HAVE_IBM_SVC_KRB5_SVC_H)
-#   include <ibm_svc/krb5_svc.h>
-#  elif defined(HAVE_ET_COM_ERR_H)
-#   include <et/com_err.h>
-#  elif defined(HAVE_KERBEROSV5_COM_ERR_H)
-#   include <kerberosv5/com_err.h>
-#  else
-#   include <com_err.h>
-#  endif
-# endif
+#    if !defined(HAVE_KRB5_GET_ERROR_STRING)
+#        if defined(HAVE_IBM_SVC_KRB5_SVC_H)
+#            include <ibm_svc/krb5_svc.h>
+#        elif defined(HAVE_ET_COM_ERR_H)
+#            include <et/com_err.h>
+#        elif defined(HAVE_KERBEROSV5_COM_ERR_H)
+#            include <kerberosv5/com_err.h>
+#        else
+#            include <com_err.h>
+#        endif
+#    endif
 #endif
 
 /* Used for unused parameters to silence gcc warnings. */
@@ -67,15 +67,15 @@ krb5_get_error_message(krb5_context ctx UNUSED, krb5_error_code code UNUSED)
 {
     const char *msg = NULL;
 
-# if defined(HAVE_KRB5_GET_ERROR_STRING)
+#    if defined(HAVE_KRB5_GET_ERROR_STRING)
     msg = krb5_get_error_string(ctx);
-# elif defined(HAVE_KRB5_GET_ERR_TEXT)
+#    elif defined(HAVE_KRB5_GET_ERR_TEXT)
     msg = krb5_get_err_text(ctx, code);
-# elif defined(HAVE_KRB5_SVC_GET_MSG)
+#    elif defined(HAVE_KRB5_SVC_GET_MSG)
     krb5_svc_get_msg(code, (char **) &msg);
-# else
+#    else
     msg = error_message(code);
-# endif
+#    endif
     if (msg == NULL)
         return error_unknown;
     else
@@ -98,11 +98,11 @@ krb5_free_error_message(krb5_context ctx UNUSED, const char *msg)
 {
     if (msg == error_unknown)
         return;
-# if defined(HAVE_KRB5_GET_ERROR_STRING)
+#    if defined(HAVE_KRB5_GET_ERROR_STRING)
     krb5_free_error_string(ctx, (char *) msg);
-# elif defined(HAVE_KRB5_SVC_GET_MSG)
+#    elif defined(HAVE_KRB5_SVC_GET_MSG)
     krb5_free_string(ctx, (char *) msg);
-# endif
+#    endif
 }
 #endif /* !HAVE_KRB5_FREE_ERROR_MESSAGE */
 
index 59562721651cbab78315665540f4edb14485d69e..2b82f0e2c539b5d6976de49749dc8612648a0539 100644 (file)
  * stripped-down version of config.h with a different name.
  */
 #ifndef CONFIG_H_INCLUDED
-# include <config.h>
+#    include <config.h>
 #endif
 #include <portable/macros.h>
 
 #if defined(HAVE_KRB5_H)
-# include <krb5.h>
+#    include <krb5.h>
 #elif defined(HAVE_KERBEROSV5_KRB5_H)
-# include <kerberosv5/krb5.h>
+#    include <kerberosv5/krb5.h>
 #else
-# include <krb5/krb5.h>
+#    include <krb5/krb5.h>
 #endif
 #include <stdlib.h>
 
@@ -62,7 +62,7 @@ BEGIN_DECLS
  * Kerberos library.  Use krb5_xfree instead.
  */
 #ifndef HAVE_KRB5_FREE_DEFAULT_REALM
-# define krb5_free_default_realm(c, r) krb5_xfree(r)
+#    define krb5_free_default_realm(c, r) krb5_xfree(r)
 #endif
 
 /*
@@ -73,16 +73,16 @@ BEGIN_DECLS
  * really do about it.
  */
 #ifndef HAVE_KRB5_FREE_STRING
-# ifdef HAVE_KRB5_XFREE
-#  define krb5_free_string(c, s) krb5_xfree(s)
-# else
-#  define krb5_free_string(c, s) free(s)
-# endif
+#    ifdef HAVE_KRB5_XFREE
+#        define krb5_free_string(c, s) krb5_xfree(s)
+#    else
+#        define krb5_free_string(c, s) free(s)
+#    endif
 #endif
 
 /* Heimdal: krb5_xfree, MIT: krb5_free_unparsed_name. */
 #ifdef HAVE_KRB5_XFREE
-# define krb5_free_unparsed_name(c, p) krb5_xfree(p)
+#    define krb5_free_unparsed_name(c, p) krb5_xfree(p)
 #endif
 
 /*
@@ -111,16 +111,17 @@ krb5_error_code krb5_get_init_creds_opt_alloc(krb5_context,
                                               krb5_get_init_creds_opt **);
 #endif
 #ifdef HAVE_KRB5_GET_INIT_CREDS_OPT_FREE
-# ifndef HAVE_KRB5_GET_INIT_CREDS_OPT_FREE_2_ARGS
-#  define krb5_get_init_creds_opt_free(c, o) krb5_get_init_creds_opt_free(o)
-# endif
+#    ifndef HAVE_KRB5_GET_INIT_CREDS_OPT_FREE_2_ARGS
+#        define krb5_get_init_creds_opt_free(c, o) \
+            krb5_get_init_creds_opt_free(o)
+#    endif
 #else
-# define krb5_get_init_creds_opt_free(c, o) free(o)
+#    define krb5_get_init_creds_opt_free(c, o) free(o)
 #endif
 
 /* Heimdal-specific. */
 #ifndef HAVE_KRB5_GET_INIT_CREDS_OPT_SET_DEFAULT_FLAGS
-# define krb5_get_init_creds_opt_set_default_flags(c, p, r, o) /* empty */
+#    define krb5_get_init_creds_opt_set_default_flags(c, p, r, o) /* empty */
 #endif
 
 /*
@@ -129,7 +130,7 @@ krb5_error_code krb5_get_init_creds_opt_alloc(krb5_context,
  * present in older MIT Kerberos libraries but not prototyped.
  */
 #if !HAVE_DECL_KRB5_KT_FREE_ENTRY
-# define krb5_kt_free_entry(c, e) krb5_free_keytab_entry_contents((c), (e))
+#    define krb5_kt_free_entry(c, e) krb5_free_keytab_entry_contents((c), (e))
 #endif
 
 /*
index 810a1f8b10fe961b456d0df2f65a50f3713e2a48..487ab5bf7413eed540c68d6bd94d46a8b292cc82 100644 (file)
@@ -24,9 +24,9 @@
  * (to avoid confusion with other macros).
  */
 #ifndef __attribute__
-# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
-#  define __attribute__(spec)   /* empty */
-# endif
+#    if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
+#        define __attribute__(spec) /* empty */
+#    endif
 #endif
 
 /*
  * variadic macro support.
  */
 #if !defined(__attribute__) && !defined(__alloc_size__)
-# if (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 3)) \
-    && !defined(__clang__)
-#  define __alloc_size__(spec, args...) /* empty */
-# endif
+#    if (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 3)) \
+        && !defined(__clang__)
+#        define __alloc_size__(spec, args...) /* empty */
+#    endif
 #endif
 
 /*
@@ -50,7 +50,7 @@
  * compilation context, but there's no push and pop available.
  */
 #if !defined(__attribute__) && (defined(__llvm__) || defined(__clang__))
-# pragma GCC diagnostic ignored "-Wattributes"
+#    pragma GCC diagnostic ignored "-Wattributes"
 #endif
 
 /*
 #undef BEGIN_DECLS
 #undef END_DECLS
 #ifdef __cplusplus
-# define BEGIN_DECLS    extern "C" {
-# define END_DECLS      }
+#    define BEGIN_DECLS extern "C" {
+#    define END_DECLS   }
 #else
-# define BEGIN_DECLS    /* empty */
-# define END_DECLS      /* empty */
+#    define BEGIN_DECLS /* empty */
+#    define END_DECLS   /* empty */
 #endif
 
 #endif /* !PORTABLE_MACROS_H */
index 2d4268180815a5d144a31d1f2320ba37fc40980b..71bddad2f0206a76899e7b7d4c736f69684f4966 100644 (file)
@@ -24,7 +24,7 @@
 #include <errno.h>
 #include <fcntl.h>
 #ifdef HAVE_SYS_TIME_H
-# include <sys/time.h>
+#    include <sys/time.h>
 #endif
 #include <time.h>
 
@@ -34,8 +34,8 @@
  * another name.
  */
 #if TESTING
-# undef mkstemp
-# define mkstemp test_mkstemp
+#    undef mkstemp
+#    define mkstemp test_mkstemp
 int test_mkstemp(char *);
 #endif
 
index bfa85e79ec350f5716afb2da40092a5d653ea063..a8be45f02ab765fa36c06cd48c0a5036741d892f 100644 (file)
@@ -31,8 +31,8 @@
  * it to another name.
  */
 #if TESTING
-# undef reallocarray
-# define reallocarray test_reallocarray
+#    undef reallocarray
+#    define reallocarray test_reallocarray
 void *test_reallocarray(void *, size_t, size_t);
 #endif
 
index fb317a90d8c8c9752b25b963e50bb3e7bf734ed8..278288cef018815d5c9478ba9f7e440ba2181486 100644 (file)
  * stripped-down version of config.h with a different name.
  */
 #ifndef CONFIG_H_INCLUDED
-# include <config.h>
+#    include <config.h>
 #endif
 
 #if HAVE_STDBOOL_H
-# include <stdbool.h>
+#    include <stdbool.h>
 #else
-# if HAVE__BOOL
-#  define bool _Bool
-# else
-#  ifdef __cplusplus
+#    if HAVE__BOOL
+#        define bool _Bool
+#    else
+#        ifdef __cplusplus
 typedef bool _Bool;
-#  elif _WIN32
-#   include <windef.h>
-#   define bool BOOL
-#  else
+#        elif _WIN32
+#            include <windef.h>
+#            define bool BOOL
+#        else
 typedef unsigned char _Bool;
-#   define bool _Bool
-#  endif
-# endif
-# define false 0
-# define true  1
-# define __bool_true_false_are_defined 1
+#            define bool _Bool
+#        endif
+#    endif
+#    define false 0
+#    define true 1
+#    define __bool_true_false_are_defined 1
 #endif
 
 /*
@@ -56,7 +56,7 @@ typedef unsigned char _Bool;
  * fail.  Only of interest for programs that also include Perl headers.
  */
 #ifndef HAS_BOOL
-# define HAS_BOOL 1
+#    define HAS_BOOL 1
 #endif
 
 #endif /* !PORTABLE_STDBOOL_H */
index 1a0c8166130b614e1ccd5cff7f26ed3f88e0e7a0..982e69188c97925e0fcbc500f49f936c02f0ce67 100644 (file)
@@ -25,8 +25,8 @@
  * with the system versions.
  */
 #if TESTING
-# undef strndup
-# define strndup test_strndup
+#    undef strndup
+#    define strndup test_strndup
 char *test_strndup(const char *, size_t);
 #endif
 
@@ -43,7 +43,7 @@ strndup(const char *s, size_t n)
     }
 
     /* Don't assume that the source string is nul-terminated. */
-    for (p = s; (size_t) (p - s) < n && *p != '\0'; p++)
+    for (p = s; (size_t)(p - s) < n && *p != '\0'; p++)
         ;
     length = p - s;
     copy = malloc(length + 1);
index a35df767d26381e21cfbb89c28488a946130726c..6912adeffb15c48eebe729e4abb45073e47505a8 100644 (file)
 
 /* A set of standard ANSI C headers.  We don't care about pre-ANSI systems. */
 #if HAVE_INTTYPES_H
-# include <inttypes.h>
+#    include <inttypes.h>
 #endif
 #include <limits.h>
 #include <stdarg.h>
 #include <stddef.h>
 #if HAVE_STDINT_H
-# include <stdint.h>
+#    include <stdint.h>
 #endif
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #if HAVE_STRINGS_H
-# include <strings.h>
+#    include <strings.h>
 #endif
 #include <sys/types.h>
 #if HAVE_UNISTD_H
-# include <unistd.h>
+#    include <unistd.h>
 #endif
 
 /* SCO OpenServer gets int32_t from here. */
 #if HAVE_SYS_BITYPES_H
-# include <sys/bitypes.h>
+#    include <sys/bitypes.h>
 #endif
 
 /* Get the bool type. */
@@ -75,7 +75,7 @@
 
 /* Windows provides snprintf under a different name. */
 #ifdef _WIN32
-# define snprintf _snprintf
+#    define snprintf _snprintf
 #endif
 
 /* Windows does not define ssize_t. */
@@ -88,9 +88,9 @@ typedef ptrdiff_t ssize_t;
  * been defined, all the rest almost certainly have.
  */
 #ifndef STDIN_FILENO
-# define STDIN_FILENO  0
-# define STDOUT_FILENO 1
-# define STDERR_FILENO 2
+#    define STDIN_FILENO  0
+#    define STDOUT_FILENO 1
+#    define STDERR_FILENO 2
 #endif
 
 /*
@@ -98,11 +98,11 @@ typedef ptrdiff_t ssize_t;
  * Autoconf manual, memcpy is a generally portable fallback.
  */
 #ifndef va_copy
-# ifdef __va_copy
-#  define va_copy(d, s) __va_copy((d), (s))
-# else
-#  define va_copy(d, s) memcpy(&(d), &(s), sizeof(va_list))
-# endif
+#    ifdef __va_copy
+#        define va_copy(d, s) __va_copy((d), (s))
+#    else
+#        define va_copy(d, s) memcpy(&(d), &(s), sizeof(va_list))
+#    endif
 #endif
 
 BEGIN_DECLS
index d5ef80a82f0bcd1139e4e2c2eb47971afe790a44..4146c2622ffa2b63f2d2075446608d13f9c656ec 100644 (file)
@@ -15,7 +15,7 @@
 #include <dlfcn.h>
 #include <errno.h>
 #ifdef HAVE_KADM5_KADM5_PWCHECK_H
-# include <kadm5/kadm5-pwcheck.h>
+#    include <kadm5/kadm5-pwcheck.h>
 #endif
 
 #include <tests/tap/basic.h>
@@ -187,7 +187,7 @@ main(void)
     for (i = 0; i < ARRAY_SIZE(principal_tests); i++)
         is_password_test(verifier, &principal_tests[i]);
 
-#ifdef HAVE_CRACKLIB
+#    ifdef HAVE_CRACKLIB
 
     /* Add CrackLib tests. */
     setup_argv[3] = (char *) "password_dictionary";
@@ -218,13 +218,13 @@ main(void)
     /* Free the memory allocated for the CrackLib test. */
     free(setup_argv[4]);
 
-#else
+#    else
 
     /* Otherwise, mark the CrackLib tests as skipped. */
     count = ARRAY_SIZE(cracklib_tests) + ARRAY_SIZE(length_tests);
     skip_block(count * 2, "not built with CDB support");
 
-#endif /* !HAVE_CRACKLIB */
+#    endif /* !HAVE_CRACKLIB */
 
     /* Add simple character class restrictions. */
     setup_argv[3] = (char *) "minimum_different";
@@ -260,7 +260,7 @@ main(void)
     for (i = 0; i < ARRAY_SIZE(length_tests); i++)
         is_password_test(verifier, &length_tests[i]);
 
-#ifdef HAVE_CDB
+#    ifdef HAVE_CDB
 
     /* If built with CDB, set up krb5.conf to use a CDB dictionary instead. */
     setup_argv[3] = (char *) "password_dictionary_cdb";
@@ -277,15 +277,15 @@ main(void)
     for (i = 0; i < ARRAY_SIZE(principal_tests); i++)
         is_password_test(verifier, &principal_tests[i]);
 
-#else /* !HAVE_CDB */
+#    else /* !HAVE_CDB */
 
     /* Otherwise, mark the CDB tests as skipped. */
     count = ARRAY_SIZE(cdb_tests) + ARRAY_SIZE(principal_tests);
     skip_block(count * 2, "not built with CDB support");
 
-#endif /* !HAVE_CDB */
+#    endif /* !HAVE_CDB */
 
-#ifdef HAVE_SQLITE
+#    ifdef HAVE_SQLITE
 
     /*
      * If built with SQLite, set up krb5.conf to use a SQLite dictionary
@@ -307,13 +307,13 @@ main(void)
     for (i = 0; i < ARRAY_SIZE(principal_tests); i++)
         is_password_test(verifier, &principal_tests[i]);
 
-#else /* !HAVE_SQLITE */
+#    else /* !HAVE_SQLITE */
 
     /* Otherwise, mark the SQLite tests as skipped. */
     count = ARRAY_SIZE(sqlite_tests) + ARRAY_SIZE(principal_tests);
     skip_block(count * 2, "not built with SQLite support");
 
-#endif /* !HAVE_SQLITE */
+#    endif /* !HAVE_SQLITE */
 
     /* Manually clean up after the results of make-krb5-conf. */
     basprintf(&path, "%s/krb5.conf", tmpdir);
index e192e23232aef3ce7d13fe653ca0bfe16a650f86..9857bb9e5bac050d19fe7ca9118fcbe203a67210 100644 (file)
@@ -2,7 +2,7 @@
  * Test for the MIT Kerberos shared module API.
  *
  * Written by Russ Allbery <eagle@eyrie.org>
- * Copyright 2017 Russ Allbery <eagle@eyrie.org>
+ * Copyright 2017, 2020 Russ Allbery <eagle@eyrie.org>
  * Copyright 2010, 2013, 2014
  *     The Board of Trustees of the Leland Stanford Junior University
  *
@@ -17,7 +17,7 @@
 #include <dlfcn.h>
 #include <errno.h>
 #ifdef HAVE_KRB5_PWQUAL_PLUGIN_H
-# include <krb5/pwqual_plugin.h>
+#    include <krb5/pwqual_plugin.h>
 #endif
 
 #include <tests/tap/basic.h>
@@ -151,7 +151,7 @@ main(void)
 {
     char *path, *dictionary, *krb5_config, *krb5_config_empty, *tmpdir;
     char *setup_argv[12];
-    const char*build;
+    const char *build;
     size_t i, count;
     krb5_context ctx;
     krb5_pwqual_vtable vtable;
@@ -206,14 +206,14 @@ main(void)
     for (i = 0; i < ARRAY_SIZE(principal_tests); i++)
         is_password_test(ctx, vtable, data, &principal_tests[i]);
 
+#    ifdef HAVE_CRACKLIB
     /* Run the CrackLib tests if CrackLib is available, otherwise skip them. */
-#ifdef HAVE_CRACKLIB
     for (i = 0; i < ARRAY_SIZE(cracklib_tests); i++)
         is_password_test(ctx, vtable, data, &cracklib_tests[i]);
-#else
+#    else
     count = ARRAY_SIZE(cracklib_tests);
     skip_block(count * 2, "not built with CrackLib support");
-#endif
+#    endif
 
     /* Close that initialization of the plugin and destroy that context. */
     vtable->close(ctx, data);
@@ -234,7 +234,7 @@ main(void)
     putenv(krb5_config);
     free(krb5_config_empty);
 
-#ifdef HAVE_CRACKLIB
+#    ifdef HAVE_CRACKLIB
 
     /* Add CrackLib configuration. */
     setup_argv[3] = (char *) "password_dictionary";
@@ -284,13 +284,13 @@ main(void)
         is_password_test(ctx, vtable, data, &length_tests[i]);
     vtable->close(ctx, data);
 
-#else
+#    else
 
     /* Otherwise mark the CrackLib tests as skipped. */
     count = ARRAY_SIZE(cracklib_tests) + ARRAY_SIZE(length_tests);
     skip_block(count * 2 + 1, "not built with CrackLib support");
 
-#endif /* !HAVE_CRACKLIB */
+#    endif /* !HAVE_CRACKLIB */
 
     /* Switch to simple character class configuration in krb5.conf. */
     setup_argv[3] = (char *) "minimum_different";
@@ -359,7 +359,7 @@ main(void)
         is_password_test(ctx, vtable, data, &length_tests[i]);
     vtable->close(ctx, data);
 
-#ifdef HAVE_CDB
+#    ifdef HAVE_CDB
 
     /* If built with CDB, set up krb5.conf to use a CDB dictionary instead. */
     test_file_path_free(dictionary);
@@ -388,15 +388,15 @@ main(void)
         is_password_test(ctx, vtable, data, &principal_tests[i]);
     vtable->close(ctx, data);
 
-#else /* !HAVE_CDB */
+#    else /* !HAVE_CDB */
 
     /* Otherwise, mark the CDB tests as skipped. */
     count = ARRAY_SIZE(cdb_tests) + ARRAY_SIZE(principal_tests);
     skip_block(count * 2 + 1, "not built with CDB support");
 
-#endif /* !HAVE_CDB */
+#    endif /* !HAVE_CDB */
 
-#ifdef HAVE_SQLITE
+#    ifdef HAVE_SQLITE
 
     /*
      * If built with SQLite, set up krb5.conf to use a SQLite dictionary
@@ -430,13 +430,13 @@ main(void)
         is_password_test(ctx, vtable, data, &principal_tests[i]);
     vtable->close(ctx, data);
 
-#else /* !HAVE_SQLITE */
+#    else /* !HAVE_SQLITE */
 
     /* Otherwise, mark the SQLite tests as skipped. */
     count = ARRAY_SIZE(sqlite_tests) + ARRAY_SIZE(principal_tests);
     skip_block(count * 2 + 1, "not built with SQLite support");
 
-#endif /* !HAVE_SQLITE */
+#    endif /* !HAVE_SQLITE */
 
     /* Manually clean up after the results of make-krb5-conf. */
     basprintf(&path, "%s/krb5.conf", tmpdir);
index 601579bc3d4cc768eed7ceb4afc27d87f7e9576b..6efaf53ec3195d3ee90ed929f32d46d43b2bf023 100644 (file)
@@ -27,7 +27,7 @@
  * formats for easy testing.
  */
 #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 2) || defined(__clang__)
-# pragma GCC diagnostic ignored "-Wformat-nonliteral"
+#    pragma GCC diagnostic ignored "-Wformat-nonliteral"
 #endif
 
 /*
@@ -40,11 +40,10 @@ int test_vsnprintf(char *str, size_t count, const char *fmt, va_list args);
 static const char string[] = "abcdefghijklmnopqrstuvwxyz0123456789";
 
 static const char *const fp_formats[] = {
-    "%-1.5f",   "%1.5f",    "%31.9f",   "%10.5f",   "% 10.5f",  "%+22.9f",
-    "%+4.9f",   "%01.3f",   "%3.1f",    "%3.2f",    "%.0f",     "%.1f",
-    "%f",
+    "%-1.5f", "%1.5f", "%31.9f", "%10.5f", "% 10.5f", "%+22.9f", "%+4.9f",
+    "%01.3f", "%3.1f", "%3.2f",  "%.0f",   "%.1f",    "%f",
 
-    /* %e and %g formats aren't really implemented yet. */
+/* %e and %g formats aren't really implemented yet. */
 #if 0
     "%-1.5e",   "%1.5e",    "%31.9e",   "%10.5e",   "% 10.5e",  "%+22.9e",
     "%+4.9e",   "%01.3e",   "%3.1e",    "%3.2e",    "%.0e",     "%.1e",
@@ -53,55 +52,48 @@ static const char *const fp_formats[] = {
     "%+4.9g",   "%01.3g",   "%3.1g",    "%3.2g",    "%.0g",     "%.1g",
     "%g",
 #endif
-    NULL
-};
+    NULL};
 static const char *const int_formats[] = {
-    "%-1.5d",   "%1.5d",    "%31.9d",   "%5.5d",    "%10.5d",   "% 10.5d",
-    "%+22.30d", "%01.3d",   "%4d",      "%d",       "%ld",      NULL
-};
+    "%-1.5d",   "%1.5d",  "%31.9d", "%5.5d", "%10.5d", "% 10.5d",
+    "%+22.30d", "%01.3d", "%4d",    "%d",    "%ld",    NULL};
 static const char *const uint_formats[] = {
-    "%-1.5lu",  "%1.5lu",   "%31.9lu",  "%5.5lu",   "%10.5lu",  "% 10.5lu",
-    "%+6.30lu", "%01.3lu",  "%4lu",     "%lu",      "%4lx",     "%4lX",
-    "%01.3lx",  "%1lo",     NULL
-};
+    "%-1.5lu",  "%1.5lu",   "%31.9lu", "%5.5lu", "%10.5lu",
+    "% 10.5lu", "%+6.30lu", "%01.3lu", "%4lu",   "%lu",
+    "%4lx",     "%4lX",     "%01.3lx", "%1lo",   NULL};
 static const char *const llong_formats[] = {
-    "%lld",     "%-1.5lld",  "%1.5lld",    "%123.9lld",  "%5.5lld",
-    "%10.5lld", "% 10.5lld", "%+22.33lld", "%01.3lld",   "%4lld",
-    NULL
-};
+    "%lld",      "%-1.5lld",   "%1.5lld",  "%123.9lld", "%5.5lld", "%10.5lld",
+    "% 10.5lld", "%+22.33lld", "%01.3lld", "%4lld",     NULL};
 static const char *const ullong_formats[] = {
-    "%llu",     "%-1.5llu",  "%1.5llu",    "%123.9llu",  "%5.5llu",
-    "%10.5llu", "% 10.5llu", "%+22.33llu", "%01.3llu",   "%4llu",
-    "%llx",     "%llo",      NULL
-};
-
-static const double fp_nums[] = {
-    -1.5, 134.21, 91340.2, 341.1234, 0203.9, 0.96, 0.996, 0.9996, 1.996,
-    4.136, 0.1, 0.01, 0.001, 10.1, 0
-};
-static long int_nums[] = {
-    -1, 134, 91340, 341, 0203, 0
-};
+    "%llu",     "%-1.5llu",  "%1.5llu",    "%123.9llu", "%5.5llu",
+    "%10.5llu", "% 10.5llu", "%+22.33llu", "%01.3llu",  "%4llu",
+    "%llx",     "%llo",      NULL};
+
+static const double fp_nums[] = {-1.5, 134.21, 91340.2, 341.1234, 0203.9,
+                                 0.96, 0.996,  0.9996,  1.996,    4.136,
+                                 0.1,  0.01,   0.001,   10.1,     0};
+static long int_nums[] = {-1, 134, 91340, 341, 0203, 0};
 static unsigned long uint_nums[] = {
-    (unsigned long) -1, 134, 91340, 341, 0203, 0
-};
-static long long llong_nums[] = {
-    ~(long long) 0,                     /* All-1 bit pattern. */
-    (~(unsigned long long) 0) >> 1,     /* Largest signed long long. */
-    -150, 134, 91340, 341,
-    0
-};
+    (unsigned long) -1, 134, 91340, 341, 0203, 0};
+static long long llong_nums[] = {~(long long) 0, /* All-1 bit pattern. */
+                                 (~(unsigned long long) 0)
+                                     >> 1, /* Largest signed long long. */
+                                 -150,
+                                 134,
+                                 91340,
+                                 341,
+                                 0};
 static unsigned long long ullong_nums[] = {
-    ~(unsigned long long) 0,            /* All-1 bit pattern. */
-    (~(unsigned long long) 0) >> 1,     /* Largest signed long long. */
-    134, 91340, 341,
-    0
-};
+    ~(unsigned long long) 0,        /* All-1 bit pattern. */
+    (~(unsigned long long) 0) >> 1, /* Largest signed long long. */
+    134,
+    91340,
+    341,
+    0};
 
 
 static void
-test_format(bool trunc, const char *expected, int count,
-            const char *format, ...)
+test_format(bool trunc, const char *expected, int count, const char *format,
+            ...)
 {
     char buf[128];
     int result;
@@ -123,12 +115,13 @@ main(void)
     long lcount;
     char lgbuf[128];
 
-    plan(8 +
-         (18 + (ARRAY_SIZE(fp_formats) - 1) * ARRAY_SIZE(fp_nums)
-          + (ARRAY_SIZE(int_formats) - 1) * ARRAY_SIZE(int_nums)
-          + (ARRAY_SIZE(uint_formats) - 1) * ARRAY_SIZE(uint_nums)
-          + (ARRAY_SIZE(llong_formats) - 1) * ARRAY_SIZE(llong_nums)
-          + (ARRAY_SIZE(ullong_formats) - 1) * ARRAY_SIZE(ullong_nums)) * 2);
+    plan(8
+         + (18 + (ARRAY_SIZE(fp_formats) - 1) * ARRAY_SIZE(fp_nums)
+            + (ARRAY_SIZE(int_formats) - 1) * ARRAY_SIZE(int_nums)
+            + (ARRAY_SIZE(uint_formats) - 1) * ARRAY_SIZE(uint_nums)
+            + (ARRAY_SIZE(llong_formats) - 1) * ARRAY_SIZE(llong_nums)
+            + (ARRAY_SIZE(ullong_formats) - 1) * ARRAY_SIZE(ullong_nums))
+               * 2);
 
     is_int(4, test_snprintf(NULL, 0, "%s", "abcd"), "simple string length");
     is_int(2, test_snprintf(NULL, 0, "%d", 20), "number length");
@@ -155,8 +148,8 @@ main(void)
                 string, -2.5);
     test_format(true, "abcdefghij4444", 14, "%.10s%n%d", string, &count, 4444);
     is_int(10, count, "correct output from %%n");
-    test_format(true, "abcdefghijklmnopqrstuvwxyz01234", 36, "%n%s%ln",
-                &count, string, &lcount);
+    test_format(true, "abcdefghijklmnopqrstuvwxyz01234", 36, "%n%s%ln", &count,
+                string, &lcount);
     is_int(0, count, "correct output from two %%n");
     is_int(31, lcount, "correct output from long %%ln");
     test_format(true, "(null)", 6, "%s", NULL);
index ab9a4cb6bfa2ee0c9d9426bbcad70d8565a5ad71..ef78733ad8d846c4b9e857e466f6f97f99bbe83a 100644 (file)
  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  * DEALINGS IN THE SOFTWARE.
-*/
+ */
 
 /* Required for fdopen(), getopt(), and putenv(). */
 #if defined(__STRICT_ANSI__) || defined(PEDANTIC)
-# ifndef _XOPEN_SOURCE
-#  define _XOPEN_SOURCE 500
-# endif
+#    ifndef _XOPEN_SOURCE
+#        define _XOPEN_SOURCE 500
+#    endif
 #endif
 
 #include <ctype.h>
 
 /* AIX 6.1 (and possibly later) doesn't have WCOREDUMP. */
 #ifndef WCOREDUMP
-# define WCOREDUMP(status) ((unsigned)(status) & 0x80)
+#    define WCOREDUMP(status) ((unsigned) (status) &0x80)
 #endif
 
 /*
  * have.
  */
 #ifndef STDIN_FILENO
-# define STDIN_FILENO  0
-# define STDOUT_FILENO 1
-# define STDERR_FILENO 2
+#    define STDIN_FILENO  0
+#    define STDOUT_FILENO 1
+#    define STDERR_FILENO 2
 #endif
 
 /*
  * $(abs_top_builddir) respectively.
  */
 #ifndef C_TAP_SOURCE
-# define C_TAP_SOURCE NULL
+#    define C_TAP_SOURCE NULL
 #endif
 #ifndef C_TAP_BUILD
-# define C_TAP_BUILD NULL
+#    define C_TAP_BUILD NULL
 #endif
 
 /* Test status codes. */
-enum test_status {
-    TEST_FAIL,
-    TEST_PASS,
-    TEST_SKIP,
-    TEST_INVALID
-};
+enum test_status { TEST_FAIL, TEST_PASS, TEST_SKIP, TEST_INVALID };
 
 /* Really, just a boolean, but this is more self-documenting. */
-enum test_verbose {
-    CONCISE = 0,
-    VERBOSE = 1
-};
+enum test_verbose { CONCISE = 0, VERBOSE = 1 };
 
 /* Indicates the state of our plan. */
 enum plan_status {
-    PLAN_INIT,                  /* Nothing seen yet. */
-    PLAN_FIRST,                 /* Plan seen before any tests. */
-    PLAN_PENDING,               /* Test seen and no plan yet. */
-    PLAN_FINAL                  /* Plan seen after some tests. */
+    PLAN_INIT,    /* Nothing seen yet. */
+    PLAN_FIRST,   /* Plan seen before any tests. */
+    PLAN_PENDING, /* Test seen and no plan yet. */
+    PLAN_FINAL    /* Plan seen after some tests. */
 };
 
 /* Error exit statuses for test processes. */
-#define CHILDERR_DUP    100     /* Couldn't redirect stderr or stdout. */
-#define CHILDERR_EXEC   101     /* Couldn't exec child process. */
-#define CHILDERR_STDIN  102     /* Couldn't open stdin file. */
-#define CHILDERR_STDERR 103     /* Couldn't open stderr file. */
+#define CHILDERR_DUP    100 /* Couldn't redirect stderr or stdout. */
+#define CHILDERR_EXEC   101 /* Couldn't exec child process. */
+#define CHILDERR_STDIN  102 /* Couldn't open stdin file. */
+#define CHILDERR_STDERR 103 /* Couldn't open stderr file. */
 
 /* Structure to hold data for a set of tests. */
 struct testset {
-    char *file;                 /* The file name of the test. */
-    char *path;                 /* The path to the test program. */
-    enum plan_status plan;      /* The status of our plan. */
-    unsigned long count;        /* Expected count of tests. */
-    unsigned long current;      /* The last seen test number. */
-    unsigned int length;        /* The length of the last status message. */
-    unsigned long passed;       /* Count of passing tests. */
-    unsigned long failed;       /* Count of failing lists. */
-    unsigned long skipped;      /* Count of skipped tests (passed). */
-    unsigned long allocated;    /* The size of the results table. */
-    enum test_status *results;  /* Table of results by test number. */
-    unsigned int aborted;       /* Whether the set was aborted. */
-    int reported;               /* Whether the results were reported. */
-    int status;                 /* The exit status of the test. */
-    unsigned int all_skipped;   /* Whether all tests were skipped. */
-    char *reason;               /* Why all tests were skipped. */
+    char *file;                /* The file name of the test. */
+    char *path;                /* The path to the test program. */
+    enum plan_status plan;     /* The status of our plan. */
+    unsigned long count;       /* Expected count of tests. */
+    unsigned long current;     /* The last seen test number. */
+    unsigned int length;       /* The length of the last status message. */
+    unsigned long passed;      /* Count of passing tests. */
+    unsigned long failed;      /* Count of failing lists. */
+    unsigned long skipped;     /* Count of skipped tests (passed). */
+    unsigned long allocated;   /* The size of the results table. */
+    enum test_status *results; /* Table of results by test number. */
+    unsigned int aborted;      /* Whether the set was aborted. */
+    int reported;              /* Whether the results were reported. */
+    int status;                /* The exit status of the test. */
+    unsigned int all_skipped;  /* Whether all tests were skipped. */
+    char *reason;              /* Why all tests were skipped. */
 };
 
 /* Structure to hold a linked list of test sets. */
@@ -239,9 +231,9 @@ Failed Set                 Fail/Total (%) Skip Stat  Failing Tests\n\
 -------------------------- -------------- ---- ----  ------------------------";
 
 /* Include the file name and line number in malloc failures. */
-#define xcalloc(n, size)      x_calloc((n), (size), __FILE__, __LINE__)
-#define xmalloc(size)         x_malloc((size), __FILE__, __LINE__)
-#define xstrdup(p)            x_strdup((p), __FILE__, __LINE__)
+#define xcalloc(n, size) x_calloc((n), (size), __FILE__, __LINE__)
+#define xmalloc(size)    x_malloc((size), __FILE__, __LINE__)
+#define xstrdup(p)       x_strdup((p), __FILE__, __LINE__)
 #define xreallocarray(p, n, size) \
     x_reallocarray((p), (n), (size), __FILE__, __LINE__)
 
@@ -251,9 +243,9 @@ Failed Set                 Fail/Total (%) Skip Stat  Failing Tests\n\
  * (to avoid confusion with other macros).
  */
 #ifndef __attribute__
-# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
-#  define __attribute__(spec)   /* empty */
-# endif
+#    if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
+#        define __attribute__(spec) /* empty */
+#    endif
 #endif
 
 /*
@@ -264,11 +256,11 @@ Failed Set                 Fail/Total (%) Skip Stat  Failing Tests\n\
  * variadic macro support.
  */
 #if !defined(__attribute__) && !defined(__alloc_size__)
-# if defined(__GNUC__) && !defined(__clang__)
-#  if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 3)
-#   define __alloc_size__(spec, args...) /* empty */
-#  endif
-# endif
+#    if defined(__GNUC__) && !defined(__clang__)
+#        if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 3)
+#            define __alloc_size__(spec, args...) /* empty */
+#        endif
+#    endif
 #endif
 
 /*
@@ -278,7 +270,7 @@ Failed Set                 Fail/Total (%) Skip Stat  Failing Tests\n\
  * compilation context, but there's no push and pop available.
  */
 #if !defined(__attribute__) && (defined(__llvm__) || defined(__clang__))
-# pragma GCC diagnostic ignored "-Wattributes"
+#    pragma GCC diagnostic ignored "-Wattributes"
 #endif
 
 /* Declare internal functions that benefit from compiler attributes. */
@@ -386,8 +378,8 @@ x_strdup(const char *s, const char *file, int line)
     len = strlen(s) + 1;
     p = malloc(len);
     if (p == NULL)
-        sysdie("failed to strdup %lu bytes at %s line %d",
-               (unsigned long) len, file, line);
+        sysdie("failed to strdup %lu bytes at %s line %d", (unsigned long) len,
+               file, line);
     memcpy(p, s, len);
     return p;
 }
@@ -480,7 +472,7 @@ tv_sum(const struct timeval *tv1, const struct timeval *tv2)
 static const char *
 skip_whitespace(const char *p)
 {
-    while (isspace((unsigned char)(*p)))
+    while (isspace((unsigned char) (*p)))
         p++;
     return p;
 }
@@ -714,8 +706,7 @@ test_plan(const char *line, struct testset *ts, enum test_verbose verbose)
  * reported status.
  */
 static void
-test_checkline(const char *line, struct testset *ts,
-               enum test_verbose verbose)
+test_checkline(const char *line, struct testset *ts, enum test_verbose verbose)
 {
     enum test_status status = TEST_PASS;
     const char *bail;
@@ -755,7 +746,7 @@ test_checkline(const char *line, struct testset *ts,
         return;
 
     /* If we haven't yet seen a plan, look for one. */
-    if (ts->plan == PLAN_INIT && isdigit((unsigned char)(*line))) {
+    if (ts->plan == PLAN_INIT && isdigit((unsigned char) (*line))) {
         if (!test_plan(line, ts, verbose))
             return;
     } else if (strncmp(line, "1..", 3) == 0) {
@@ -806,7 +797,7 @@ test_checkline(const char *line, struct testset *ts,
      * Handle directives.  We should probably do something more interesting
      * with unexpected passes of todo tests.
      */
-    while (isdigit((unsigned char)(*line)))
+    while (isdigit((unsigned char) (*line)))
         line++;
     line = skip_whitespace(line);
     if (*line == '#') {
@@ -829,10 +820,17 @@ test_checkline(const char *line, struct testset *ts,
 
     /* Good results.  Increment our various counters. */
     switch (status) {
-        case TEST_PASS: ts->passed++;   break;
-        case TEST_FAIL: ts->failed++;   break;
-        case TEST_SKIP: ts->skipped++;  break;
-        case TEST_INVALID:              break;
+    case TEST_PASS:
+        ts->passed++;
+        break;
+    case TEST_FAIL:
+        ts->failed++;
+        break;
+    case TEST_SKIP:
+        ts->skipped++;
+        break;
+    case TEST_INVALID:
+        break;
     }
     ts->current = current;
     ts->results[current - 1] = status;
@@ -1108,8 +1106,7 @@ test_fail_summary(const struct testlist *fails)
         ts = fails->ts;
         total = ts->count - ts->skipped;
         printf("%-26.26s %4lu/%-4lu %3.0f%% %4lu ", ts->file, ts->failed,
-               total, total ? (ts->failed * 100.0) / total : 0,
-               ts->skipped);
+               total, total ? (ts->failed * 100.0) / total : 0, ts->skipped);
         if (WIFEXITED(ts->status))
             printf("%4d  ", WEXITSTATUS(ts->status));
         else
@@ -1177,7 +1174,7 @@ find_test(const char *name, const char *source, const char *build)
     char *path = NULL;
     const char *bases[3], *suffix, *base;
     unsigned int i, j;
-    const char *suffixes[3] = { "-t", ".t", "" };
+    const char *suffixes[3] = {"-t", ".t", ""};
 
     /* Possible base directories. */
     bases[0] = ".";
@@ -1443,8 +1440,7 @@ test_batch(struct testlist *tests, const char *source, const char *build,
         else
             printf("Aborted %lu test sets", aborted);
         printf(", passed %lu/%lu tests", passed, total);
-    }
-    else if (failed == 0)
+    } else if (failed == 0)
         fputs("All tests successful", stdout);
     else
         printf("Failed %lu/%lu tests, %.2f%% okay", failed, total,
@@ -1458,8 +1454,8 @@ test_batch(struct testlist *tests, const char *source, const char *build,
     puts(".");
     printf("Files=%u,  Tests=%lu", count, total);
     printf(",  %.2f seconds", tv_diff(&end, &start));
-    printf(" (%.2f usr + %.2f sys = %.2f CPU)\n",
-           tv_seconds(&stats.ru_utime), tv_seconds(&stats.ru_stime),
+    printf(" (%.2f usr + %.2f sys = %.2f CPU)\n", tv_seconds(&stats.ru_utime),
+           tv_seconds(&stats.ru_stime),
            tv_sum(&stats.ru_utime, &stats.ru_stime));
     return (failed == 0 && aborted == 0);
 }
index c244e05b197751024e0ef2f56419a1e3753e79f3..0c96fce2a8b98c83a923e4058eb1012b70a7e2d5 100644 (file)
@@ -43,9 +43,9 @@
 #include <stdlib.h>
 #include <string.h>
 #ifdef _WIN32
-# include <direct.h>
+#    include <direct.h>
 #else
-# include <sys/stat.h>
+#    include <sys/stat.h>
 #endif
 #include <sys/types.h>
 #include <unistd.h>
@@ -54,8 +54,8 @@
 
 /* Windows provides mkdir and rmdir under different names. */
 #ifdef _WIN32
-# define mkdir(p, m) _mkdir(p)
-# define rmdir(p)    _rmdir(p)
+#    define mkdir(p, m) _mkdir(p)
+#    define rmdir(p)    _rmdir(p)
 #endif
 
 /*
@@ -70,7 +70,7 @@ unsigned long testnum = 1;
  * We can get the highest test count from testnum.
  */
 static unsigned long _planned = 0;
-static unsigned long _failed  = 0;
+static unsigned long _failed = 0;
 
 /*
  * Store the PID of the process that called plan() and only summarize
@@ -124,16 +124,16 @@ static struct diag_file *diag_files = NULL;
  * print_desc, which has to be done in a macro.  Assumes that format is the
  * argument immediately before the variadic arguments.
  */
-#define PRINT_DESC(prefix, format)              \
-    do {                                        \
-        if (format != NULL) {                   \
-            va_list args;                       \
-            if (prefix != NULL)                 \
-                printf("%s", prefix);           \
-            va_start(args, format);             \
-            vprintf(format, args);              \
-            va_end(args);                       \
-        }                                       \
+#define PRINT_DESC(prefix, format)    \
+    do {                              \
+        if (format != NULL) {         \
+            va_list args;             \
+            if (prefix != NULL)       \
+                printf("%s", prefix); \
+            va_start(args, format);   \
+            vprintf(format, args);    \
+            va_end(args);             \
+        }                             \
     } while (0)
 
 
@@ -717,7 +717,7 @@ bcalloc(size_t n, size_t size)
 
     p = calloc(n, size);
     if (p == NULL)
-        sysbail("failed to calloc %lu", (unsigned long)(n * size));
+        sysbail("failed to calloc %lu", (unsigned long) (n * size));
     return p;
 }
 
@@ -807,9 +807,9 @@ bstrndup(const char *s, size_t n)
     size_t length;
 
     /* Don't assume that the source string is nul-terminated. */
-    for (p = s; (size_t) (p - s) < n && *p != '\0'; p++)
+    for (p = s; (size_t)(p - s) < n && *p != '\0'; p++)
         ;
-    length = (size_t) (p - s);
+    length = (size_t)(p - s);
     copy = malloc(length + 1);
     if (p == NULL)
         sysbail("failed to strndup %lu bytes", (unsigned long) length);
@@ -830,7 +830,7 @@ test_file_path(const char *file)
 {
     char *base;
     char *path = NULL;
-    const char *envs[] = { "C_TAP_BUILD", "C_TAP_SOURCE", NULL };
+    const char *envs[] = {"C_TAP_BUILD", "C_TAP_SOURCE", NULL};
     int i;
 
     for (i = 0; envs[i] != NULL; i++) {
index a4b1a61dd88a1880e950a42e9b2db4f747ca61be..78c04d05424203ae7e297314059cac1549ee72e1 100644 (file)
@@ -31,9 +31,9 @@
 #ifndef TAP_BASIC_H
 #define TAP_BASIC_H 1
 
+#include <stdarg.h> /* va_list */
+#include <stddef.h> /* size_t */
 #include <tests/tap/macros.h>
-#include <stdarg.h>             /* va_list */
-#include <stddef.h>             /* size_t */
 
 /*
  * Used for iterating through arrays.  ARRAY_SIZE returns the number of
@@ -41,8 +41,8 @@
  * ARRAY_END returns a pointer to the element past the end (ISO C99 makes it
  * legal to refer to such a pointer as long as it's never dereferenced).
  */
-#define ARRAY_SIZE(array)       (sizeof(array) / sizeof((array)[0]))
-#define ARRAY_END(array)        (&(array)[ARRAY_SIZE(array)])
+#define ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0]))
+#define ARRAY_END(array)  (&(array)[ARRAY_SIZE(array)])
 
 BEGIN_DECLS
 
@@ -75,8 +75,7 @@ int ok(int success, const char *format, ...)
     __attribute__((__format__(printf, 2, 3)));
 int okv(int success, const char *format, va_list args)
     __attribute__((__format__(printf, 2, 0)));
-void skip(const char *reason, ...)
-    __attribute__((__format__(printf, 1, 2)));
+void skip(const char *reason, ...) __attribute__((__format__(printf, 1, 2)));
 
 /*
  * Report the same status on, or skip, the next count tests.  ok_block()
@@ -117,10 +116,8 @@ int sysdiag(const char *format, ...)
  * diag().  Nul characters are not supported in these files and will result in
  * truncated output.
  */
-void diag_file_add(const char *file)
-    __attribute__((__nonnull__));
-void diag_file_remove(const char *file)
-    __attribute__((__nonnull__));
+void diag_file_add(const char *file) __attribute__((__nonnull__));
+void diag_file_remove(const char *file) __attribute__((__nonnull__));
 
 /* Allocate memory, reporting a fatal error with bail on failure. */
 void *bcalloc(size_t, size_t)
@@ -148,8 +145,7 @@ void test_file_path_free(char *path);
  * Create a temporary directory relative to C_TAP_BUILD and return the path.
  * The returned path should be freed with test_tmpdir_free().
  */
-char *test_tmpdir(void)
-    __attribute__((__malloc__, __warn_unused_result__));
+char *test_tmpdir(void) __attribute__((__malloc__, __warn_unused_result__));
 void test_tmpdir_free(char *path);
 
 /*
@@ -163,8 +159,7 @@ void test_tmpdir_free(char *path);
  * (the one that called plan or plan_lazy) and false otherwise.
  */
 typedef void (*test_cleanup_func)(int, int);
-void test_cleanup_register(test_cleanup_func)
-    __attribute__((__nonnull__));
+void test_cleanup_register(test_cleanup_func) __attribute__((__nonnull__));
 
 END_DECLS
 
index 5551fbc8d35776e1b640440054e8adeadff438e6..898561359732a9b8b34a5c73801767962d7115bb 100644 (file)
@@ -39,7 +39,7 @@
 
 #include <config.h>
 #ifdef HAVE_KRB5
-# include <portable/krb5.h>
+#    include <portable/krb5.h>
 #endif
 #include <portable/system.h>
 
@@ -56,7 +56,7 @@
  * to handle the possible patterns for kinit commands as an array.
  */
 #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 2) || defined(__clang__)
-# pragma GCC diagnostic ignored "-Wformat-nonliteral"
+#    pragma GCC diagnostic ignored "-Wformat-nonliteral"
 #endif
 
 
@@ -155,12 +155,11 @@ kerberos_kinit(void)
 static void
 kerberos_kinit(void)
 {
-    static const char * const format[] = {
+    static const char *const format[] = {
         "kinit --no-afslog -k -t %s %s >/dev/null 2>&1 </dev/null",
         "kinit -k -t %s %s >/dev/null 2>&1 </dev/null",
         "kinit -t %s %s >/dev/null 2>&1 </dev/null",
-        "kinit -k -K %s %s >/dev/null 2>&1 </dev/null"
-    };
+        "kinit -k -K %s %s >/dev/null 2>&1 </dev/null"};
     FILE *file;
     char *path;
     char principal[BUFSIZ], *command;
index c0e7a1bd363edf41b9052bb385145a4482965cc1..dac4ff9669abd37e73aa2592f770da5aca2caabf 100644 (file)
 #include <tests/tap/macros.h>
 
 #ifdef HAVE_KRB5
-# include <portable/krb5.h>
+#    include <portable/krb5.h>
 #endif
 
 /* Holds the information parsed from the Kerberos test configuration. */
 struct kerberos_config {
-    char *keytab;               /* Path to the keytab. */
-    char *principal;            /* Principal whose keys are in the keytab. */
-    char *cache;                /* Path to the Kerberos ticket cache. */
-    char *userprinc;            /* The fully-qualified principal. */
-    char *username;             /* The local (non-realm) part of principal. */
-    char *realm;                /* The realm part of the principal. */
-    char *password;             /* The password. */
-    char *pkinit_principal;     /* Principal for PKINIT authentication. */
-    char *pkinit_cert;          /* Path to certificates for PKINIT. */
+    char *keytab;           /* Path to the keytab. */
+    char *principal;        /* Principal whose keys are in the keytab. */
+    char *cache;            /* Path to the Kerberos ticket cache. */
+    char *userprinc;        /* The fully-qualified principal. */
+    char *username;         /* The local (non-realm) part of principal. */
+    char *realm;            /* The realm part of the principal. */
+    char *password;         /* The password. */
+    char *pkinit_principal; /* Principal for PKINIT authentication. */
+    char *pkinit_cert;      /* Path to certificates for PKINIT. */
 };
 
 /*
@@ -56,11 +56,11 @@ struct kerberos_config {
  * tests require both keytab and password, but PKINIT is not required.
  */
 enum kerberos_needs {
-    TAP_KRB_NEEDS_NONE     = 0x00,
-    TAP_KRB_NEEDS_KEYTAB   = 0x01,
+    TAP_KRB_NEEDS_NONE = 0x00,
+    TAP_KRB_NEEDS_KEYTAB = 0x01,
     TAP_KRB_NEEDS_PASSWORD = 0x02,
-    TAP_KRB_NEEDS_BOTH     = 0x01 | 0x02,
-    TAP_KRB_NEEDS_PKINIT   = 0x04
+    TAP_KRB_NEEDS_BOTH = 0x01 | 0x02,
+    TAP_KRB_NEEDS_PKINIT = 0x04
 };
 
 BEGIN_DECLS
index 2cd1e87a127edd4cc30bcb61dc69cbeab79b33cf..faf57a193f6885254056aa18b0341e7172fcdfc1 100644 (file)
@@ -40,9 +40,9 @@
  * the other attributes to work with GCC versions between 2.7 and 2.96.
  */
 #ifndef __attribute__
-# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 96)
-#  define __attribute__(spec)   /* empty */
-# endif
+#    if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 96)
+#        define __attribute__(spec) /* empty */
+#    endif
 #endif
 
 /*
  * variadic macro support.
  */
 #if !defined(__attribute__) && !defined(__alloc_size__)
-# if defined(__GNUC__) && !defined(__clang__)
-#  if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 3)
-#   define __alloc_size__(spec, args...) /* empty */
-#  endif
-# endif
+#    if defined(__GNUC__) && !defined(__clang__)
+#        if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 3)
+#            define __alloc_size__(spec, args...) /* empty */
+#        endif
+#    endif
 #endif
 
 /* Suppress __warn_unused_result__ if gcc is too old. */
 #if !defined(__attribute__) && !defined(__warn_unused_result__)
-# if __GNUC__ < 3 || (__GNUC__ == 3 && __GNUC_MINOR__ < 4)
-#  define __warn_unused_result__ /* empty */
-# endif
+#    if __GNUC__ < 3 || (__GNUC__ == 3 && __GNUC_MINOR__ < 4)
+#        define __warn_unused_result__ /* empty */
+#    endif
 #endif
 
 /*
@@ -74,7 +74,7 @@
  * compilation context, but there's no push and pop available.
  */
 #if !defined(__attribute__) && (defined(__llvm__) || defined(__clang__))
-# pragma GCC diagnostic ignored "-Wattributes"
+#    pragma GCC diagnostic ignored "-Wattributes"
 #endif
 
 /* Used for unused parameters to silence gcc warnings. */
 #undef BEGIN_DECLS
 #undef END_DECLS
 #ifdef __cplusplus
-# define BEGIN_DECLS    extern "C" {
-# define END_DECLS      }
+#    define BEGIN_DECLS extern "C" {
+#    define END_DECLS   }
 #else
-# define BEGIN_DECLS    /* empty */
-# define END_DECLS      /* empty */
+#    define BEGIN_DECLS /* empty */
+#    define END_DECLS   /* empty */
 #endif
 
 #endif /* TAP_MACROS_H */
index 45bbe468e1d391c879ff58b6e8e95e48064f7f09..4211042758c1328dcc6e2ad1be2f00e9925d6fde 100644 (file)
 #include <fcntl.h>
 #include <signal.h>
 #ifdef HAVE_SYS_SELECT_H
-# include <sys/select.h>
+#    include <sys/select.h>
 #endif
 #include <sys/stat.h>
 #ifdef HAVE_SYS_TIME_H
-# include <sys/time.h>
+#    include <sys/time.h>
 #endif
 #include <sys/wait.h>
 #include <time.h>
@@ -59,7 +59,7 @@
 
 /* May be defined by the build system. */
 #ifndef PATH_FAKEROOT
-# define PATH_FAKEROOT ""
+#    define PATH_FAKEROOT ""
 #endif
 
 /* How long to wait for the process to start in seconds. */
  * everything required to stop the process and clean up after it.
  */
 struct process {
-    pid_t pid;                  /* PID of child process */
-    char *pidfile;              /* PID file to delete on process stop */
-    char *tmpdir;               /* Temporary directory for log file */
-    char *logfile;              /* Log file of process output */
-    bool is_child;              /* Whether we can waitpid for process */
-    struct process *next;       /* Next process in global list */
+    pid_t pid;            /* PID of child process */
+    char *pidfile;        /* PID file to delete on process stop */
+    char *tmpdir;         /* Temporary directory for log file */
+    char *logfile;        /* Log file of process output */
+    bool is_child;        /* Whether we can waitpid for process */
+    struct process *next; /* Next process in global list */
 };
 
 /*
index 7e008bece9299f4c9144823b0e537e89fa558d0a..b2637a039abc8871d2ece989685bf2e4b2b6363c 100644 (file)
@@ -60,8 +60,7 @@ void is_function_output(test_function_type, void *data, int status,
  * successfully, call bail, with the error message being the output from the
  * program.
  */
-void run_setup(const char *const argv[])
-    __attribute__((__nonnull__));
+void run_setup(const char *const argv[]) __attribute__((__nonnull__));
 
 /*
  * process_start starts a process in the background, returning an opaque data
index 73e34eef7c92778ebc28d540522793998b13ba2e..cb4c7911dc2a1d10481e6a00ce5f76681a167e3a 100644 (file)
@@ -34,7 +34,7 @@
 #include <config.h>
 #include <tests/tap/macros.h>
 
-#include <stdarg.h>             /* va_list */
+#include <stdarg.h> /* va_list */
 
 BEGIN_DECLS
 
index 8113198473d38d27536a019578bf24b1b9815e5a..2fc1acb51cec95cdf1538db11543c0c919218f7b 100644 (file)
@@ -29,7 +29,7 @@
 
 #include <config.h>
 #ifdef HAVE_KRB5
-# include <portable/krb5.h>
+#    include <portable/krb5.h>
 #endif
 #include <portable/system.h>
 
@@ -37,7 +37,7 @@
 #include <tests/tap/process.h>
 #include <util/macros.h>
 #ifdef HAVE_KRB5
-# include <util/messages-krb5.h>
+#    include <util/messages-krb5.h>
 #endif
 #include <util/messages.h>
 #include <util/xmalloc.h>
index eb4ef5f155c2d034f3c542ffae1e6618205ea091..d27d24e5648aee81a48ccfe526fc47877488d1cc 100644 (file)
 /*
  * Test functions.
  */
-static void test1(void *data UNUSED) { warn("warning"); }
-static void test2(void *data UNUSED) { die("fatal"); }
-static void test3(void *data UNUSED) { errno = EPERM; syswarn("permissions"); }
-static void test4(void *data UNUSED) {
+static void
+test1(void *data UNUSED)
+{
+    warn("warning");
+}
+static void
+test2(void *data UNUSED)
+{
+    die("fatal");
+}
+static void
+test3(void *data UNUSED)
+{
+    errno = EPERM;
+    syswarn("permissions");
+}
+static void
+test4(void *data UNUSED)
+{
     errno = EACCES;
     sysdie("fatal access");
 }
-static void test5(void *data UNUSED) {
+static void
+test5(void *data UNUSED)
+{
     message_program_name = "test5";
     warn("warning");
 }
-static void test6(void *data UNUSED) {
+static void
+test6(void *data UNUSED)
+{
     message_program_name = "test6";
     die("fatal");
 }
-static void test7(void *data UNUSED) {
+static void
+test7(void *data UNUSED)
+{
     message_program_name = "test7";
     errno = EPERM;
     syswarn("perms %d", 7);
 }
-static void test8(void *data UNUSED) {
+static void
+test8(void *data UNUSED)
+{
     message_program_name = "test8";
     errno = EACCES;
     sysdie("%st%s", "fa", "al");
 }
 
-static int return10(void) { return 10; }
+static int
+return10(void)
+{
+    return 10;
+}
 
-static void test9(void *data UNUSED) {
+static void
+test9(void *data UNUSED)
+{
     message_fatal_cleanup = return10;
     die("fatal");
 }
-static void test10(void *data UNUSED) {
+static void
+test10(void *data UNUSED)
+{
     message_program_name = 0;
     message_fatal_cleanup = return10;
     errno = EPERM;
     sysdie("fatal perm");
 }
-static void test11(void *data UNUSED) {
+static void
+test11(void *data UNUSED)
+{
     message_program_name = "test11";
     message_fatal_cleanup = return10;
     errno = EPERM;
@@ -93,61 +126,92 @@ static void test11(void *data UNUSED) {
 }
 
 static void __attribute__((__format__(printf, 2, 0)))
-log_msg(size_t len, const char *format, va_list args, int error) {
+log_msg(size_t len, const char *format, va_list args, int error)
+{
     fprintf(stderr, "%lu %d ", (unsigned long) len, error);
     vfprintf(stderr, format, args);
     fprintf(stderr, "\n");
 }
 
-static void test12(void *data UNUSED) {
+static void
+test12(void *data UNUSED)
+{
     message_handlers_warn(1, log_msg);
     warn("warning");
 }
-static void test13(void *data UNUSED) {
+static void
+test13(void *data UNUSED)
+{
     message_handlers_die(1, log_msg);
     die("fatal");
 }
-static void test14(void *data UNUSED) {
+static void
+test14(void *data UNUSED)
+{
     message_handlers_warn(2, log_msg, log_msg);
     errno = EPERM;
     syswarn("warning");
 }
-static void test15(void *data UNUSED) {
+static void
+test15(void *data UNUSED)
+{
     message_handlers_die(2, log_msg, log_msg);
     message_fatal_cleanup = return10;
     errno = EPERM;
     sysdie("fatal");
 }
-static void test16(void *data UNUSED) {
+static void
+test16(void *data UNUSED)
+{
     message_handlers_warn(2, message_log_stderr, log_msg);
     message_program_name = "test16";
     errno = EPERM;
     syswarn("warning");
 }
-static void test17(void *data UNUSED) { notice("notice"); }
-static void test18(void *data UNUSED) {
+static void
+test17(void *data UNUSED)
+{
+    notice("notice");
+}
+static void
+test18(void *data UNUSED)
+{
     message_program_name = "test18";
     notice("notice");
 }
-static void test19(void *data UNUSED) { debug("debug"); }
-static void test20(void *data UNUSED) {
+static void
+test19(void *data UNUSED)
+{
+    debug("debug");
+}
+static void
+test20(void *data UNUSED)
+{
     message_handlers_notice(1, log_msg);
     notice("foo");
 }
-static void test21(void *data UNUSED) {
+static void
+test21(void *data UNUSED)
+{
     message_handlers_debug(1, message_log_stdout);
     message_program_name = "test23";
     debug("baz");
 }
-static void test22(void *data UNUSED) {
+static void
+test22(void *data UNUSED)
+{
     message_handlers_die(0);
     die("hi mom!");
 }
-static void test23(void *data UNUSED) {
+static void
+test23(void *data UNUSED)
+{
     message_handlers_warn(0);
     warn("this is a test");
 }
-static void test24(void *data UNUSED) {
+static void
+test24(void *data UNUSED)
+{
     notice("first");
     message_handlers_notice(0);
     notice("second");
@@ -218,7 +282,7 @@ main(void)
     is_function_output(test20, NULL, 0, "3 0 foo\n", "test20");
     is_function_output(test21, NULL, 0, "test23: baz\n", "test21");
 
-    /* Make sure that it's possible to turn off a message type entirely. */ 
+    /* Make sure that it's possible to turn off a message type entirely. */
     is_function_output(test22, NULL, 1, "", "test22");
     is_function_output(test23, NULL, 0, "", "test23");
     is_function_output(test24, NULL, 0, "first\nthird\n", "test24");
index a5c0b944179fa352787e087e9d49301df8948c67..8ff1a2360ac6fb8e165d8345b7457c36da1fed8c 100644 (file)
@@ -35,7 +35,7 @@
 #include <ctype.h>
 #include <errno.h>
 #ifdef HAVE_SYS_TIME_H
-# include <sys/time.h>
+#    include <sys/time.h>
 #endif
 #include <time.h>
 
@@ -382,14 +382,22 @@ main(int argc, char *argv[])
     }
 
     switch (code) {
-    case 'c': exit(test_calloc(size) ? willfail : 1);
-    case 'm': exit(test_malloc(size) ? willfail : 1);
-    case 'r': exit(test_realloc(size) ? willfail : 1);
-    case 'y': exit(test_reallocarray(4, size / 4) ? willfail : 1);
-    case 's': exit(test_strdup(size) ? willfail : 1);
-    case 'n': exit(test_strndup(size) ? willfail : 1);
-    case 'a': exit(test_asprintf(size) ? willfail : 1);
-    case 'v': exit(test_vasprintf(size) ? willfail : 1);
+    case 'c':
+        exit(test_calloc(size) ? willfail : 1);
+    case 'm':
+        exit(test_malloc(size) ? willfail : 1);
+    case 'r':
+        exit(test_realloc(size) ? willfail : 1);
+    case 'y':
+        exit(test_reallocarray(4, size / 4) ? willfail : 1);
+    case 's':
+        exit(test_strdup(size) ? willfail : 1);
+    case 'n':
+        exit(test_strndup(size) ? willfail : 1);
+    case 'a':
+        exit(test_asprintf(size) ? willfail : 1);
+    case 'v':
+        exit(test_vasprintf(size) ? willfail : 1);
     default:
         die("Unknown mode %c", argv[1][0]);
         break;
index 775d3afd965b7108ef5c5e95b327be9fe38d84ec..d6f292f1b7db425469073c9e9465540ae5c28c0a 100644 (file)
@@ -21,8 +21,8 @@
 
 #include <plugin/internal.h>
 #include <util/macros.h>
-#include <util/messages.h>
 #include <util/messages-krb5.h>
+#include <util/messages.h>
 #include <util/xmalloc.h>
 
 
index 341ac1a4eb714fb6277573cfb34b04e2c8e7e818..f00289af2ae794af8bcc90500fb13c8d89006688 100644 (file)
@@ -35,8 +35,8 @@
 #include <portable/krb5.h>
 #include <portable/system.h>
 
-#include <util/messages.h>
 #include <util/messages-krb5.h>
+#include <util/messages.h>
 #include <util/xmalloc.h>
 
 
index 836c4b151435b9cc9f003b19668c90ac8c730766..cf6f8378a4fe12916c0870bb5b9a6a13baf106e7 100644 (file)
 
 #include <errno.h>
 #ifdef HAVE_SYSLOG_H
-# include <syslog.h>
+#    include <syslog.h>
 #endif
 
 #ifdef _WIN32
-# include <windows.h>
-# define LOG_DEBUG      EVENTLOG_SUCCESS
-# define LOG_INFO       EVENTLOG_INFORMATION_TYPE
-# define LOG_NOTICE     EVENTLOG_INFORMATION_TYPE
-# define LOG_WARNING    EVENTLOG_WARNING_TYPE
-# define LOG_ERR        EVENTLOG_ERROR_TYPE
-# define LOG_CRIT       EVENTLOG_ERROR_TYPE
+#    include <windows.h>
+#    define LOG_DEBUG   EVENTLOG_SUCCESS
+#    define LOG_INFO    EVENTLOG_INFORMATION_TYPE
+#    define LOG_NOTICE  EVENTLOG_INFORMATION_TYPE
+#    define LOG_WARNING EVENTLOG_WARNING_TYPE
+#    define LOG_ERR     EVENTLOG_ERROR_TYPE
+#    define LOG_CRIT    EVENTLOG_ERROR_TYPE
 #endif
 
 #include <util/macros.h>
 #include <util/xmalloc.h>
 
 /* The default handler lists. */
-static message_handler_func stdout_handlers[2] = {
-    message_log_stdout, NULL
-};
-static message_handler_func stderr_handlers[2] = {
-    message_log_stderr, NULL
-};
+static message_handler_func stdout_handlers[2] = {message_log_stdout, NULL};
+static message_handler_func stderr_handlers[2] = {message_log_stderr, NULL};
 
 /* The list of logging functions currently in effect. */
-static message_handler_func *debug_handlers  = NULL;
+static message_handler_func *debug_handlers = NULL;
 static message_handler_func *notice_handlers = stdout_handlers;
-static message_handler_func *warn_handlers   = stderr_handlers;
-static message_handler_func *die_handlers    = stderr_handlers;
+static message_handler_func *warn_handlers = stderr_handlers;
+static message_handler_func *die_handlers = stderr_handlers;
 
 /* If non-NULL, called before exit and its return value passed to exit. */
 int (*message_fatal_cleanup)(void) = NULL;
@@ -144,15 +140,14 @@ message_handlers(message_handler_func **list, unsigned int count, va_list args)
  * duplication since we can't assume variadic macros, but I can at least make
  * it easier to write and keep them consistent.
  */
-#define HANDLER_FUNCTION(type)                                  \
-    void                                                        \
-    message_handlers_ ## type(unsigned int count, ...)          \
-    {                                                           \
-        va_list args;                                           \
-                                                                \
-        va_start(args, count);                                  \
-        message_handlers(& type ## _handlers, count, args);     \
-        va_end(args);                                           \
+#define HANDLER_FUNCTION(type)                            \
+    void message_handlers_##type(unsigned int count, ...) \
+    {                                                     \
+        va_list args;                                     \
+                                                          \
+        va_start(args, count);                            \
+        message_handlers(&type##_handlers, count, args);  \
+        va_end(args);                                     \
     }
 HANDLER_FUNCTION(debug)
 HANDLER_FUNCTION(notice)
@@ -254,7 +249,7 @@ message_log_syslog(int pri, size_t len, const char *fmt, va_list args, int err)
             CloseEventLog(eventlog);
         }
     }
-#else /* !_WIN32 */
+#else  /* !_WIN32 */
     if (err == 0)
         syslog(pri, "%s", buffer);
     else
@@ -268,18 +263,17 @@ message_log_syslog(int pri, size_t len, const char *fmt, va_list args, int err)
  * Do the same sort of wrapper to generate all of the separate syslog logging
  * functions.
  */
-#define SYSLOG_FUNCTION(name, type)                                        \
-    void                                                                   \
-    message_log_syslog_ ## name(size_t l, const char *f, va_list a, int e) \
-    {                                                                      \
-        message_log_syslog(LOG_ ## type, l, f, a, e);                      \
+#define SYSLOG_FUNCTION(name, type)                                           \
+    void message_log_syslog_##name(size_t l, const char *f, va_list a, int e) \
+    {                                                                         \
+        message_log_syslog(LOG_##type, l, f, a, e);                           \
     }
-SYSLOG_FUNCTION(debug,   DEBUG)
-SYSLOG_FUNCTION(info,    INFO)
-SYSLOG_FUNCTION(notice,  NOTICE)
+SYSLOG_FUNCTION(debug, DEBUG)
+SYSLOG_FUNCTION(info, INFO)
+SYSLOG_FUNCTION(notice, NOTICE)
 SYSLOG_FUNCTION(warning, WARNING)
-SYSLOG_FUNCTION(err,     ERR)
-SYSLOG_FUNCTION(crit,    CRIT)
+SYSLOG_FUNCTION(err, ERR)
+SYSLOG_FUNCTION(crit, CRIT)
 
 
 /*
index 889bd1ee6e29656ea9ed0fc2dc04b14af34a08bb..fc6839eef939eb5f1e1ffe41b48f916a8af8a989 100644 (file)
@@ -100,8 +100,8 @@ void
 xmalloc_fail(const char *function, size_t size, const char *file, int line)
 {
     if (size == 0)
-        sysdie("failed to format output with %s at %s line %d", function,
-               file, line);
+        sysdie("failed to format output with %s at %s line %d", function, file,
+               line);
     else
         sysdie("failed to %s %lu bytes at %s line %d", function,
                (unsigned long) size, file, line);
@@ -201,7 +201,7 @@ x_strndup(const char *s, size_t size, const char *file, int line)
     char *copy;
 
     /* Don't assume that the source string is nul-terminated. */
-    for (p = s; (size_t) (p - s) < size && *p != '\0'; p++)
+    for (p = s; (size_t)(p - s) < size && *p != '\0'; p++)
         ;
     length = p - s;
     copy = malloc(length + 1);
@@ -261,7 +261,7 @@ x_asprintf(char **strp, const char *file, int line, const char *fmt, ...)
     }
     va_end(args);
 }
-#else /* !(HAVE_C99_VAMACROS || HAVE_GNU_VAMACROS) */
+#else  /* !(HAVE_C99_VAMACROS || HAVE_GNU_VAMACROS) */
 void
 x_asprintf(char **strp, const char *fmt, ...)
 {
index fc159b405f53976d1c2fc6bf26a2ffd7df811ab8..bdb76d95c093afcd80128a0003b5ee322a48b731 100644 (file)
  * number information for debugging error messages without the user having to
  * pass those in every time.
  */
-#define xcalloc(n, size)        x_calloc((n), (size), __FILE__, __LINE__)
-#define xmalloc(size)           x_malloc((size), __FILE__, __LINE__)
-#define xrealloc(p, size)       x_realloc((p), (size), __FILE__, __LINE__)
-#define xstrdup(p)              x_strdup((p), __FILE__, __LINE__)
-#define xstrndup(p, size)       x_strndup((p), (size), __FILE__, __LINE__)
-#define xvasprintf(p, f, a)     x_vasprintf((p), (f), (a), __FILE__, __LINE__)
+#define xcalloc(n, size)    x_calloc((n), (size), __FILE__, __LINE__)
+#define xmalloc(size)       x_malloc((size), __FILE__, __LINE__)
+#define xrealloc(p, size)   x_realloc((p), (size), __FILE__, __LINE__)
+#define xstrdup(p)          x_strdup((p), __FILE__, __LINE__)
+#define xstrndup(p, size)   x_strndup((p), (size), __FILE__, __LINE__)
+#define xvasprintf(p, f, a) x_vasprintf((p), (f), (a), __FILE__, __LINE__)
 #define xreallocarray(p, n, size) \
     x_reallocarray((p), (n), (size), __FILE__, __LINE__)
 
  * are supported.
  */
 #ifdef HAVE_C99_VAMACROS
-# define xasprintf(p, f, ...) \
-    x_asprintf((p), __FILE__, __LINE__, (f), __VA_ARGS__)
+#    define xasprintf(p, f, ...) \
+        x_asprintf((p), __FILE__, __LINE__, (f), __VA_ARGS__)
 #elif HAVE_GNU_VAMACROS
-# define xasprintf(p, f, args...) \
-    x_asprintf((p), __FILE__, __LINE__, (f), args)
+#    define xasprintf(p, f, args...) \
+        x_asprintf((p), __FILE__, __LINE__, (f), args)
 #else
-# define xasprintf x_asprintf
+#    define xasprintf x_asprintf
 #endif
 
 BEGIN_DECLS