util: run uncrustify

This is the result of running

     $ uncrustify --replace --config ../devel/uncrustify.cfg *.c *.h

in the util directory
This commit is contained in:
uncrustify 2019-06-13 07:33:13 -03:00 committed by David Bremner
parent 33382c2b5b
commit 1a8916786f
13 changed files with 81 additions and 63 deletions

View file

@ -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,7 +80,7 @@ _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,
ret = g_mime_multipart_encrypted_decrypt (part, flags, NULL,
decrypt_result, err);
return ret;
}
@ -86,7 +88,7 @@ _notmuch_crypto_decrypt (bool *attempted,
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;

View file

@ -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;

View file

@ -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) {
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) {

View file

@ -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
}

View file

@ -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,7 +139,7 @@ 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 */
@ -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);

View file

@ -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 {
@ -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++;

View file

@ -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
}

View file

@ -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)

View file

@ -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);
}
}

View file

@ -76,7 +76,8 @@ gz_getline (void *talloc_ctx, char **bufptr, ssize_t *bytes_read, gzFile stream)
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);