[PATCH 5/8] util: run uncrustify
David Bremner
david at tethera.net
Thu Jun 13 04:08:34 PDT 2019
From: uncrustify <david at tethera.net>
This is the result of running
$ uncrustify --replace --config ../devel/uncrustify.cfg *.c *.h
in the util directory
---
util/crypto.c | 21 +++++++++++---------
util/crypto.h | 4 ++--
util/error_util.h | 4 ++--
util/gmime-extra.c | 48 ++++++++++++++++++++++++++++-----------------
util/gmime-extra.h | 14 ++++++-------
util/hex-escape.c | 14 ++++++-------
util/hex-escape.h | 4 ++--
util/string-util.c | 20 ++++++++++---------
util/string-util.h | 2 +-
util/unicode-util.c | 4 ++--
util/util.c | 2 +-
util/xutil.c | 2 +-
util/zlib-extra.c | 5 +++--
13 files changed, 81 insertions(+), 63 deletions(-)
diff --git a/util/crypto.c b/util/crypto.c
index 9e185e03..225f537a 100644
--- a/util/crypto.c
+++ b/util/crypto.c
@@ -24,7 +24,8 @@
#define ARRAY_SIZE(arr) (sizeof (arr) / sizeof (arr[0]))
-void _notmuch_crypto_cleanup (unused(_notmuch_crypto_t *crypto))
+void
+_notmuch_crypto_cleanup (unused(_notmuch_crypto_t *crypto))
{
}
@@ -37,6 +38,7 @@ _notmuch_crypto_decrypt (bool *attempted,
GError **err)
{
GMimeObject *ret = NULL;
+
if (decrypt == NOTMUCH_DECRYPT_FALSE)
return NULL;
@@ -78,15 +80,15 @@ _notmuch_crypto_decrypt (bool *attempted,
GMimeDecryptFlags flags = GMIME_DECRYPT_NONE;
if (decrypt == NOTMUCH_DECRYPT_TRUE && decrypt_result)
flags |= GMIME_DECRYPT_EXPORT_SESSION_KEY;
- ret = g_mime_multipart_encrypted_decrypt(part, flags, NULL,
- decrypt_result, err);
+ ret = g_mime_multipart_encrypted_decrypt (part, flags, NULL,
+ decrypt_result, err);
return ret;
}
static int
_notmuch_message_crypto_destructor (_notmuch_message_crypto_t *msg_crypto)
{
- if (!msg_crypto)
+ if (! msg_crypto)
return 0;
if (msg_crypto->sig_list)
g_object_unref (msg_crypto->sig_list);
@@ -99,6 +101,7 @@ _notmuch_message_crypto_t *
_notmuch_message_crypto_new (void *ctx)
{
_notmuch_message_crypto_t *ret = talloc_zero (ctx, _notmuch_message_crypto_t);
+
talloc_set_destructor (ret, _notmuch_message_crypto_destructor);
return ret;
}
@@ -106,7 +109,7 @@ _notmuch_message_crypto_new (void *ctx)
notmuch_status_t
_notmuch_message_crypto_potential_sig_list (_notmuch_message_crypto_t *msg_crypto, GMimeSignatureList *sigs)
{
- if (!msg_crypto)
+ if (! msg_crypto)
return NOTMUCH_STATUS_NULL_POINTER;
/* Signatures that arrive after a payload part during DFS are not
@@ -139,7 +142,7 @@ _notmuch_message_crypto_potential_payload (_notmuch_message_crypto_t *msg_crypto
const char *forwarded = NULL;
const char *subject = NULL;
- if (!msg_crypto || !payload)
+ if (! msg_crypto || ! payload)
return NOTMUCH_STATUS_NULL_POINTER;
/* only fire on the first payload part encountered */
@@ -182,7 +185,7 @@ _notmuch_message_crypto_potential_payload (_notmuch_message_crypto_t *msg_crypto
} else {
/* Consider "memoryhole"-style protected headers as practiced by Enigmail and K-9 */
protected_headers = g_mime_object_get_content_type_parameter (payload, "protected-headers");
- if (protected_headers && strcasecmp("v1", protected_headers) == 0)
+ if (protected_headers && strcasecmp ("v1", protected_headers) == 0)
subject = g_mime_object_get_header (payload, "Subject");
/* FIXME: handle more than just Subject: at some point */
}
@@ -200,12 +203,12 @@ _notmuch_message_crypto_potential_payload (_notmuch_message_crypto_t *msg_crypto
notmuch_status_t
_notmuch_message_crypto_successful_decryption (_notmuch_message_crypto_t *msg_crypto)
{
- if (!msg_crypto)
+ if (! msg_crypto)
return NOTMUCH_STATUS_NULL_POINTER;
/* see the rationale for different values of
* _notmuch_message_decryption_status_t in util/crypto.h */
- if (!msg_crypto->payload_encountered)
+ if (! msg_crypto->payload_encountered)
msg_crypto->decryption_status = NOTMUCH_MESSAGE_DECRYPTED_FULL;
else if (msg_crypto->decryption_status == NOTMUCH_MESSAGE_DECRYPTED_NONE)
msg_crypto->decryption_status = NOTMUCH_MESSAGE_DECRYPTED_PARTIAL;
diff --git a/util/crypto.h b/util/crypto.h
index fdbb5da5..11e8060a 100644
--- a/util/crypto.h
+++ b/util/crypto.h
@@ -50,7 +50,7 @@ typedef struct _notmuch_message_crypto {
/* signature status of the whole message (either the whole message
* is signed, or it is not) -- this means that partially-signed
* messages will get no signature status. */
- GMimeSignatureList * sig_list;
+ GMimeSignatureList *sig_list;
/* if part of the message was signed, and the MUA is clever, it
* can determine on its own exactly which part and try to make
* more sense of it. */
@@ -62,7 +62,7 @@ typedef struct _notmuch_message_crypto {
/* the value of any "Subject:" header in the cryptographic payload
* (the top level part within the crypto envelope), converted to
* UTF-8 */
- char * payload_subject;
+ char *payload_subject;
/* if both signed and encrypted, was the signature encrypted? */
bool signature_encrypted;
diff --git a/util/error_util.h b/util/error_util.h
index aa3b77c4..a51f001f 100644
--- a/util/error_util.h
+++ b/util/error_util.h
@@ -44,8 +44,8 @@ _internal_error (const char *format, ...) PRINTF_ATTRIBUTE (1, 2) NORETURN_ATTRI
*
* Note that __location__ comes from talloc.h.
*/
-#define INTERNAL_ERROR(format, ...) \
- _internal_error (format " (%s).\n", \
+#define INTERNAL_ERROR(format, ...) \
+ _internal_error (format " (%s).\n", \
##__VA_ARGS__, __location__)
#ifdef __cplusplus
diff --git a/util/gmime-extra.c b/util/gmime-extra.c
index 7562d906..b515d126 100644
--- a/util/gmime-extra.c
+++ b/util/gmime-extra.c
@@ -3,7 +3,8 @@
static
GMimeStream *
-_gzfile_maybe_filter (GMimeStream *file_stream) {
+_gzfile_maybe_filter (GMimeStream *file_stream)
+{
char buf[4];
int bytes_read;
@@ -14,7 +15,7 @@ _gzfile_maybe_filter (GMimeStream *file_stream) {
return NULL;
/* check for gzipped input */
- if (bytes_read >= 2 && buf[0] == 0x1f && (unsigned char)buf[1] == 0x8b) {
+ if (bytes_read >= 2 && buf[0] == 0x1f && (unsigned char) buf[1] == 0x8b) {
GMimeStream *gzstream;
GMimeFilter *gzfilter;
@@ -27,7 +28,7 @@ _gzfile_maybe_filter (GMimeStream *file_stream) {
return NULL;
/* ignore filter id */
- (void)g_mime_stream_filter_add ((GMimeStreamFilter *)gzstream, gzfilter);
+ (void) g_mime_stream_filter_add ((GMimeStreamFilter *) gzstream, gzfilter);
return gzstream;
} else {
return file_stream;
@@ -59,13 +60,13 @@ g_mime_stream_gzfile_open (const char *filename)
}
GMimeStream *
-g_mime_stream_stdout_new()
+g_mime_stream_stdout_new ()
{
GMimeStream *stream_stdout = NULL;
GMimeStream *stream_buffered = NULL;
stream_stdout = g_mime_stream_pipe_new (STDOUT_FILENO);
- if (!stream_stdout)
+ if (! stream_stdout)
return NULL;
g_mime_stream_pipe_set_owner (GMIME_STREAM_PIPE (stream_stdout), FALSE);
@@ -80,10 +81,11 @@ g_mime_stream_stdout_new()
/**
* copy a glib string into a talloc context, and free it.
*/
-static char*
+static char *
g_string_talloc_strdup (void *ctx, char *g_string)
{
char *new_str = talloc_strdup (ctx, g_string);
+
g_free (g_string);
return new_str;
}
@@ -93,6 +95,7 @@ g_mime_certificate_get_valid_userid (GMimeCertificate *cert)
{
/* output user id only if validity is FULL or ULTIMATE. */
const char *uid = g_mime_certificate_get_user_id (cert);
+
if (uid == NULL)
return uid;
GMimeValidity validity = g_mime_certificate_get_id_validity (cert);
@@ -101,10 +104,12 @@ g_mime_certificate_get_valid_userid (GMimeCertificate *cert)
return NULL;
}
-const char*
-g_mime_certificate_get_fpr16 (GMimeCertificate *cert) {
+const char *
+g_mime_certificate_get_fpr16 (GMimeCertificate *cert)
+{
const char *fpr = g_mime_certificate_get_fingerprint (cert);
- if (!fpr || strlen (fpr) < 16)
+
+ if (! fpr || strlen (fpr) < 16)
return fpr;
return fpr + (strlen (fpr) - 16);
@@ -114,23 +119,25 @@ char *
g_mime_message_get_address_string (GMimeMessage *message, GMimeAddressType type)
{
InternetAddressList *list = g_mime_message_get_addresses (message, type);
+
return internet_address_list_to_string (list, NULL, 0);
}
char *
g_mime_message_get_date_string (void *ctx, GMimeMessage *message)
{
- GDateTime* parsed_date = g_mime_message_get_date (message);
+ GDateTime *parsed_date = g_mime_message_get_date (message);
+
if (parsed_date) {
char *date = g_mime_utils_header_format_date (parsed_date);
return g_string_talloc_strdup (ctx, date);
} else {
- return talloc_strdup(ctx, "Thu, 01 Jan 1970 00:00:00 +0000");
+ return talloc_strdup (ctx, "Thu, 01 Jan 1970 00:00:00 +0000");
}
}
InternetAddressList *
-g_mime_message_get_reply_to_list(GMimeMessage *message)
+g_mime_message_get_reply_to_list (GMimeMessage *message)
{
return g_mime_message_get_reply_to (message);
}
@@ -145,6 +152,7 @@ char *
g_mime_message_get_reply_to_string (void *ctx, GMimeMessage *message)
{
InternetAddressList *list = g_mime_message_get_reply_to (message);
+
return g_string_talloc_strdup (ctx, internet_address_list_to_string (list, NULL, 0));
}
@@ -161,23 +169,27 @@ g_mime_parser_set_scan_from (GMimeParser *parser, gboolean flag)
*/
gboolean
-g_mime_signature_status_good (GMimeSignatureStatus status) {
- return ((status & (GMIME_SIGNATURE_STATUS_RED | GMIME_SIGNATURE_STATUS_ERROR_MASK)) == 0);
+g_mime_signature_status_good (GMimeSignatureStatus status)
+{
+ return ((status & (GMIME_SIGNATURE_STATUS_RED | GMIME_SIGNATURE_STATUS_ERROR_MASK)) == 0);
}
gboolean
-g_mime_signature_status_bad (GMimeSignatureStatus status) {
+g_mime_signature_status_bad (GMimeSignatureStatus status)
+{
return (status & GMIME_SIGNATURE_STATUS_RED);
}
gboolean
-g_mime_signature_status_error (GMimeSignatureStatus status) {
+g_mime_signature_status_error (GMimeSignatureStatus status)
+{
return (status & GMIME_SIGNATURE_STATUS_ERROR_MASK);
}
gint64
-g_mime_utils_header_decode_date_unix (const char *date) {
- GDateTime* parsed_date = g_mime_utils_header_decode_date (date);
+g_mime_utils_header_decode_date_unix (const char *date)
+{
+ GDateTime *parsed_date = g_mime_utils_header_decode_date (date);
time_t ret;
if (parsed_date) {
diff --git a/util/gmime-extra.h b/util/gmime-extra.h
index b0c8d3d8..094309ec 100644
--- a/util/gmime-extra.h
+++ b/util/gmime-extra.h
@@ -7,7 +7,7 @@
extern "C" {
#endif
-GMimeStream *g_mime_stream_stdout_new(void);
+GMimeStream *g_mime_stream_stdout_new (void);
/* Return a GMime stream for this open file descriptor, un-gzipping if
* necessary */
@@ -27,7 +27,7 @@ const char *g_mime_certificate_get_fpr16 (GMimeCertificate *cert);
*/
char *g_mime_message_get_address_string (GMimeMessage *message, GMimeAddressType type);
-InternetAddressList * g_mime_message_get_addresses (GMimeMessage *message, GMimeAddressType type);
+InternetAddressList *g_mime_message_get_addresses (GMimeMessage *message, GMimeAddressType type);
/**
* return talloc allocated date string
@@ -39,21 +39,21 @@ char *g_mime_message_get_date_string (void *ctx, GMimeMessage *message);
* glib allocated list of From: addresses
*/
-InternetAddressList * g_mime_message_get_from (GMimeMessage *message);
+InternetAddressList *g_mime_message_get_from (GMimeMessage *message);
/**
* return string for From: address
* (owned by gmime)
*/
-const char * g_mime_message_get_from_string (GMimeMessage *message);
+const char *g_mime_message_get_from_string (GMimeMessage *message);
-InternetAddressList * g_mime_message_get_reply_to_list (GMimeMessage *message);
+InternetAddressList *g_mime_message_get_reply_to_list (GMimeMessage *message);
/**
* return talloc allocated reply-to string
*/
-char * g_mime_message_get_reply_to_string (void *ctx, GMimeMessage *message);
+char *g_mime_message_get_reply_to_string (void *ctx, GMimeMessage *message);
void g_mime_parser_set_scan_from (GMimeParser *parser, gboolean flag);
@@ -68,7 +68,7 @@ gint64 g_mime_utils_header_decode_date_unix (const char *date);
/**
* Return string for valid User ID (or NULL if no valid User ID exists)
*/
-const char * g_mime_certificate_get_valid_userid (GMimeCertificate *cert);
+const char *g_mime_certificate_get_valid_userid (GMimeCertificate *cert);
#ifdef __cplusplus
}
diff --git a/util/hex-escape.c b/util/hex-escape.c
index 8883ff90..81534a8c 100644
--- a/util/hex-escape.c
+++ b/util/hex-escape.c
@@ -72,7 +72,7 @@ hex_encode (void *ctx, const char *in, char **out, size_t *out_size)
if (*out == NULL)
*out_size = 0;
- if (!maybe_realloc (ctx, needed, out, out_size))
+ if (! maybe_realloc (ctx, needed, out, out_size))
return HEX_OUT_OF_MEMORY;
q = *out;
@@ -82,7 +82,7 @@ hex_encode (void *ctx, const char *in, char **out, size_t *out_size)
if (is_output (*p)) {
*q++ = *p++;
} else {
- sprintf (q, "%%%02x", (unsigned char)*p++);
+ sprintf (q, "%%%02x", (unsigned char) *p++);
q += 3;
}
}
@@ -105,8 +105,8 @@ hex_decode_internal (const char *in, unsigned char *out)
char *endp;
/* This also handles unexpected end-of-string. */
- if (!isxdigit ((unsigned char) in[1]) ||
- !isxdigit ((unsigned char) in[2]))
+ if (! isxdigit ((unsigned char) in[1]) ||
+ ! isxdigit ((unsigned char) in[2]))
return HEX_SYNTAX_ERROR;
buf[0] = in[1];
@@ -139,10 +139,10 @@ hex_decode_inplace (char *s)
}
hex_status_t
-hex_decode (void *ctx, const char *in, char **out, size_t * out_size)
+hex_decode (void *ctx, const char *in, char **out, size_t *out_size)
{
const char *p;
- size_t needed = 1; /* for the NUL */
+ size_t needed = 1; /* for the NUL */
assert (ctx); assert (in); assert (out); assert (out_size);
@@ -152,7 +152,7 @@ hex_decode (void *ctx, const char *in, char **out, size_t * out_size)
else
needed += 1;
- if (!maybe_realloc (ctx, needed, out, out_size))
+ if (! maybe_realloc (ctx, needed, out, out_size))
return HEX_OUT_OF_MEMORY;
return hex_decode_internal (in, (unsigned char *) *out);
diff --git a/util/hex-escape.h b/util/hex-escape.h
index 50d946ed..8703334c 100644
--- a/util/hex-escape.h
+++ b/util/hex-escape.h
@@ -29,11 +29,11 @@ typedef enum hex_status {
hex_status_t
hex_encode (void *talloc_ctx, const char *in, char **out,
- size_t *out_size);
+ size_t *out_size);
hex_status_t
hex_decode (void *talloc_ctx, const char *in, char **out,
- size_t *out_size);
+ size_t *out_size);
/*
* Non-allocating hex decode to decode 's' in-place. The length of the
diff --git a/util/string-util.c b/util/string-util.c
index fc2058e0..de8430b2 100644
--- a/util/string-util.c
+++ b/util/string-util.c
@@ -42,7 +42,7 @@ strtok_len_c (const char *s, const char *delim, size_t *len)
{
/* strtok_len is already const-safe, but we can't express both
* versions in the C type system. */
- return strtok_len ((char*)s, delim, len);
+ return strtok_len ((char *) s, delim, len);
}
char *
@@ -60,7 +60,7 @@ sanitize_string (const void *ctx, const char *str)
for (loop = out; *loop; loop++) {
if (*loop == '\t' || *loop == '\n')
*loop = ' ';
- else if ((unsigned char)(*loop) < 32)
+ else if ((unsigned char) (*loop) < 32)
*loop = '?';
}
@@ -87,9 +87,9 @@ make_boolean_term (void *ctx, const char *prefix, const char *term,
* beginning, and anything containing non-ASCII text. */
if (! term[0])
need_quoting = 1;
- for (in = term; *in && !need_quoting; in++)
+ for (in = term; *in && ! need_quoting; in++)
if (is_unquoted_terminator (*in) || *in == '"' || *in == '('
- || (unsigned char)*in > 127)
+ || (unsigned char) *in > 127)
need_quoting = 1;
if (need_quoting)
@@ -141,7 +141,7 @@ make_boolean_term (void *ctx, const char *prefix, const char *term,
return 0;
}
-const char*
+const char *
skip_space (const char *str)
{
while (*str && isspace ((unsigned char) *str))
@@ -154,6 +154,7 @@ parse_boolean_term (void *ctx, const char *str,
char **prefix_out, char **term_out)
{
int err = EINVAL;
+
*prefix_out = *term_out = NULL;
/* Parse prefix */
@@ -193,7 +194,7 @@ parse_boolean_term (void *ctx, const char *str,
}
/* Did the term terminate without a closing quote or is there
* trailing text after the closing quote? */
- if (!closed || *pos)
+ if (! closed || *pos)
goto FAIL;
*out = '\0';
} else {
@@ -215,7 +216,7 @@ parse_boolean_term (void *ctx, const char *str,
}
return 0;
- FAIL:
+ FAIL:
talloc_free (*prefix_out);
talloc_free (*term_out);
errno = err;
@@ -230,9 +231,9 @@ strcmp_null (const char *s1, const char *s2)
else if (! s1 && ! s2)
return 0;
else if (s1)
- return 1; /* s1 (non-NULL) is greater than s2 (NULL) */
+ return 1; /* s1 (non-NULL) is greater than s2 (NULL) */
else
- return -1; /* s1 (NULL) is less than s2 (non-NULL) */
+ return -1; /* s1 (NULL) is less than s2 (non-NULL) */
}
int
@@ -248,6 +249,7 @@ strcase_hash (const void *ptr)
/* This is the djb2 hash. */
unsigned int hash = 5381;
+
while (s && *s) {
hash = ((hash << 5) + hash) + tolower (*s);
s++;
diff --git a/util/string-util.h b/util/string-util.h
index 4c110a20..fb95a740 100644
--- a/util/string-util.h
+++ b/util/string-util.h
@@ -77,7 +77,7 @@ unsigned int strcase_hash (const void *ptr);
void strip_trailing (char *str, char ch);
-const char* skip_space (const char *str);
+const char *skip_space (const char *str);
#ifdef __cplusplus
}
diff --git a/util/unicode-util.c b/util/unicode-util.c
index 312e900f..ccb787e2 100644
--- a/util/unicode-util.c
+++ b/util/unicode-util.c
@@ -1,8 +1,8 @@
#include "unicode-util.h"
/* Based on Xapian::Unicode::is_wordchar, to avoid forcing clients to
- link directly to libxapian.
-*/
+ * link directly to libxapian.
+ */
static bool
unicode_is_wordchar (notmuch_unichar ch)
diff --git a/util/util.c b/util/util.c
index 06659b35..6abe2215 100644
--- a/util/util.c
+++ b/util/util.c
@@ -19,6 +19,6 @@ util_error_string (util_status_t errnum)
/* we lack context to be more informative here */
return "zlib error";
default:
- INTERNAL_ERROR("unexpected error status %d", errnum);
+ INTERNAL_ERROR ("unexpected error status %d", errnum);
}
}
diff --git a/util/xutil.c b/util/xutil.c
index f211eaaa..07a00343 100644
--- a/util/xutil.c
+++ b/util/xutil.c
@@ -111,7 +111,7 @@ xregcomp (regex_t *preg, const char *regex, int cflags)
regerror (rerr, preg, error, error_size);
fprintf (stderr, "compiling regex %s: %s\n",
- regex, error);
+ regex, error);
free (error);
return 1;
}
diff --git a/util/zlib-extra.c b/util/zlib-extra.c
index 2b2cd8f9..f691cccf 100644
--- a/util/zlib-extra.c
+++ b/util/zlib-extra.c
@@ -70,13 +70,14 @@ gz_getline (void *talloc_ctx, char **bufptr, ssize_t *bytes_read, gzFile stream)
if (buf == NULL)
return UTIL_OUT_OF_MEMORY;
}
- SUCCESS:
+ SUCCESS:
*bufptr = buf;
*bytes_read = offset;
return UTIL_SUCCESS;
}
-const char *gz_error_string (util_status_t status, gzFile file)
+const char *
+gz_error_string (util_status_t status, gzFile file)
{
if (status == UTIL_GZERROR)
return gzerror (file, NULL);
--
2.20.1
More information about the notmuch
mailing list