unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* Trial run uncrustifying some of the CLI
@ 2019-06-12 11:34 David Bremner
  2019-06-12 11:35 ` [PATCH 1/7] cli: replace use of !! with macro David Bremner
                   ` (6 more replies)
  0 siblings, 7 replies; 10+ messages in thread
From: David Bremner @ 2019-06-12 11:34 UTC (permalink / raw)
  To: notmuch

I made a few (hopefully inoffensive) changes to accomodate the
enforced styling. What do people think? Assuming this series is OK, do
you want mega patches (~500 line diff) or more small patches for
semi-auto styling?

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 1/7] cli: replace use of !! with macro
  2019-06-12 11:34 Trial run uncrustifying some of the CLI David Bremner
@ 2019-06-12 11:35 ` David Bremner
  2019-06-12 20:13   ` Tomi Ollila
  2019-06-12 20:17   ` Jorge P. de Morais Neto
  2019-06-12 11:35 ` [PATCH 2/7] devel: remove between ++ / -- and argument David Bremner
                   ` (5 subsequent siblings)
  6 siblings, 2 replies; 10+ messages in thread
From: David Bremner @ 2019-06-12 11:35 UTC (permalink / raw)
  To: notmuch

The slightly annoying reason to do this is because uncrustify can't
handle '!! foo' sensibly. The less annoying reason is that it helps
understand what the code does.
---
 command-line-arguments.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/command-line-arguments.c b/command-line-arguments.c
index d64aa85b..5f0607be 100644
--- a/command-line-arguments.c
+++ b/command-line-arguments.c
@@ -4,6 +4,8 @@
 #include "error_util.h"
 #include "command-line-arguments.h"
 
+#define TO_BOOL(thing) (!! thing)
+
 typedef enum {
     OPT_FAILED, /* false */
     OPT_OK, /* good */
@@ -120,13 +122,13 @@ _process_string_arg (const notmuch_opt_desc_t *arg_desc, char next, const char *
 static int _opt_set_count (const notmuch_opt_desc_t *opt_desc)
 {
     return
-	!!opt_desc->opt_inherit +
-	!!opt_desc->opt_bool +
-	!!opt_desc->opt_int +
-	!!opt_desc->opt_keyword +
-	!!opt_desc->opt_flags +
-	!!opt_desc->opt_string +
-	!!opt_desc->opt_position;
+	TO_BOOL (opt_desc->opt_inherit) +
+	TO_BOOL (opt_desc->opt_bool) +
+	TO_BOOL (opt_desc->opt_int) +
+	TO_BOOL (opt_desc->opt_keyword) +
+	TO_BOOL (opt_desc->opt_flags) +
+	TO_BOOL (opt_desc->opt_string) +
+	TO_BOOL (opt_desc->opt_position);
 }
 
 /* Return true if opt_desc is valid. */
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 2/7] devel: remove between ++ / -- and argument
  2019-06-12 11:34 Trial run uncrustifying some of the CLI David Bremner
  2019-06-12 11:35 ` [PATCH 1/7] cli: replace use of !! with macro David Bremner
@ 2019-06-12 11:35 ` David Bremner
  2019-06-12 11:35 ` [PATCH 3/7] cli: uncrustify command-line-arguments.c David Bremner
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 10+ messages in thread
From: David Bremner @ 2019-06-12 11:35 UTC (permalink / raw)
  To: notmuch

Apparently we just missed the option to get "x++" while keeping "x + y".
---
 devel/uncrustify.cfg | 1 +
 1 file changed, 1 insertion(+)

diff --git a/devel/uncrustify.cfg b/devel/uncrustify.cfg
index 6a8769c6..b8e57324 100644
--- a/devel/uncrustify.cfg
+++ b/devel/uncrustify.cfg
@@ -71,6 +71,7 @@ type sprinter_t
 # inter-character spacing options
 #
 
+sp_incdec		= remove
 sp_before_ptr_star	= force
 sp_between_ptr_star	= remove
 sp_after_ptr_star	= remove
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 3/7] cli: uncrustify command-line-arguments.c
  2019-06-12 11:34 Trial run uncrustifying some of the CLI David Bremner
  2019-06-12 11:35 ` [PATCH 1/7] cli: replace use of !! with macro David Bremner
  2019-06-12 11:35 ` [PATCH 2/7] devel: remove between ++ / -- and argument David Bremner
@ 2019-06-12 11:35 ` David Bremner
  2019-06-12 11:35 ` [PATCH 4/7] cli: uncrustify debugger.c David Bremner
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 10+ messages in thread
From: David Bremner @ 2019-06-12 11:35 UTC (permalink / raw)
  To: notmuch

Ignore one exploding '!!' -> '! !' and add one pair of parens.
---
 command-line-arguments.c | 58 +++++++++++++++++++++++-----------------
 1 file changed, 33 insertions(+), 25 deletions(-)

diff --git a/command-line-arguments.c b/command-line-arguments.c
index 5f0607be..a628929b 100644
--- a/command-line-arguments.c
+++ b/command-line-arguments.c
@@ -7,16 +7,16 @@
 #define TO_BOOL(thing) (!! thing)
 
 typedef enum {
-    OPT_FAILED, /* false */
-    OPT_OK, /* good */
-    OPT_GIVEBACK, /* pop one of the arguments you thought you were getting off the stack */
+    OPT_FAILED,         /* false */
+    OPT_OK,             /* good */
+    OPT_GIVEBACK,       /* pop one of the arguments you thought you were getting off the stack */
 } opt_handled;
 
 /*
-  Search the array of keywords for a given argument, assigning the
-  output variable to the corresponding value.  Return false if nothing
-  matches.
-*/
+ * Search the array of keywords for a given argument, assigning the
+ * output variable to the corresponding value.  Return false if nothing
+ * matches.
+ */
 
 static opt_handled
 _process_keyword_arg (const notmuch_opt_desc_t *arg_desc, char next,
@@ -80,15 +80,17 @@ _process_boolean_arg (const notmuch_opt_desc_t *arg_desc, char next,
 	return OPT_FAILED;
     }
 
-    *arg_desc->opt_bool = negate ? !value : value;
+    *arg_desc->opt_bool = negate ? (! value) : value;
 
     return OPT_OK;
 }
 
 static opt_handled
-_process_int_arg (const notmuch_opt_desc_t *arg_desc, char next, const char *arg_str) {
+_process_int_arg (const notmuch_opt_desc_t *arg_desc, char next, const char *arg_str)
+{
 
     char *endptr;
+
     if (next == '\0' || arg_str[0] == '\0') {
 	fprintf (stderr, "Option \"%s\" needs an integer argument.\n", arg_desc->name);
 	return OPT_FAILED;
@@ -104,7 +106,8 @@ _process_int_arg (const notmuch_opt_desc_t *arg_desc, char next, const char *arg
 }
 
 static opt_handled
-_process_string_arg (const notmuch_opt_desc_t *arg_desc, char next, const char *arg_str) {
+_process_string_arg (const notmuch_opt_desc_t *arg_desc, char next, const char *arg_str)
+{
 
     if (next == '\0') {
 	fprintf (stderr, "Option \"%s\" needs a string argument.\n", arg_desc->name);
@@ -119,7 +122,8 @@ _process_string_arg (const notmuch_opt_desc_t *arg_desc, char next, const char *
 }
 
 /* Return number of non-NULL opt_* fields in opt_desc. */
-static int _opt_set_count (const notmuch_opt_desc_t *opt_desc)
+static int
+_opt_set_count (const notmuch_opt_desc_t *opt_desc)
 {
     return
 	TO_BOOL (opt_desc->opt_inherit) +
@@ -132,7 +136,8 @@ static int _opt_set_count (const notmuch_opt_desc_t *opt_desc)
 }
 
 /* Return true if opt_desc is valid. */
-static bool _opt_valid (const notmuch_opt_desc_t *opt_desc)
+static bool
+_opt_valid (const notmuch_opt_desc_t *opt_desc)
 {
     int n = _opt_set_count (opt_desc);
 
@@ -144,15 +149,17 @@ static bool _opt_valid (const notmuch_opt_desc_t *opt_desc)
 }
 
 /*
-   Search for the {pos_arg_index}th position argument, return false if
-   that does not exist.
-*/
+ * Search for the {pos_arg_index}th position argument, return false if
+ * that does not exist.
+ */
 
 bool
 parse_position_arg (const char *arg_str, int pos_arg_index,
-		    const notmuch_opt_desc_t *arg_desc) {
+		    const notmuch_opt_desc_t *arg_desc)
+{
 
     int pos_arg_counter = 0;
+
     while (_opt_valid (arg_desc)) {
 	if (arg_desc->opt_position) {
 	    if (pos_arg_counter == pos_arg_index) {
@@ -178,12 +185,12 @@ parse_position_arg (const char *arg_str, int pos_arg_index,
 int
 parse_option (int argc, char **argv, const notmuch_opt_desc_t *options, int opt_index)
 {
-    assert(argv);
+    assert (argv);
 
     const char *_arg = argv[opt_index];
 
-    assert(_arg);
-    assert(options);
+    assert (_arg);
+    assert (options);
 
     const char *arg = _arg + 2; /* _arg starts with -- */
     const char *negative_arg = NULL;
@@ -241,7 +248,7 @@ parse_option (int argc, char **argv, const notmuch_opt_desc_t *options, int opt_
 	if (lookahead) {
 	    next = ' ';
 	    value = next_arg;
-	    opt_index ++;
+	    opt_index++;
 	}
 
 	opt_handled opt_status = OPT_FAILED;
@@ -260,12 +267,12 @@ parse_option (int argc, char **argv, const notmuch_opt_desc_t *options, int opt_
 	    return -1;
 
 	if (lookahead && opt_status == OPT_GIVEBACK)
-	    opt_index --;
+	    opt_index--;
 
 	if (try->present)
 	    *try->present = true;
 
-	return opt_index+1;
+	return opt_index + 1;
     }
     return -1;
 }
@@ -273,13 +280,14 @@ parse_option (int argc, char **argv, const notmuch_opt_desc_t *options, int opt_
 /* See command-line-arguments.h for description */
 int
 parse_arguments (int argc, char **argv,
-		 const notmuch_opt_desc_t *options, int opt_index) {
+		 const notmuch_opt_desc_t *options, int opt_index)
+{
 
     int pos_arg_index = 0;
     bool more_args = true;
 
     while (more_args && opt_index < argc) {
-	if (strncmp (argv[opt_index],"--",2) != 0) {
+	if (strncmp (argv[opt_index], "--", 2) != 0) {
 
 	    more_args = parse_position_arg (argv[opt_index], pos_arg_index, options);
 
@@ -292,7 +300,7 @@ parse_arguments (int argc, char **argv,
 	    int prev_opt_index = opt_index;
 
 	    if (strlen (argv[opt_index]) == 2)
-		return opt_index+1;
+		return opt_index + 1;
 
 	    opt_index = parse_option (argc, argv, options, opt_index);
 	    if (opt_index < 0) {
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 4/7] cli: uncrustify debugger.c
  2019-06-12 11:34 Trial run uncrustifying some of the CLI David Bremner
                   ` (2 preceding siblings ...)
  2019-06-12 11:35 ` [PATCH 3/7] cli: uncrustify command-line-arguments.c David Bremner
@ 2019-06-12 11:35 ` David Bremner
  2019-06-12 11:35 ` [PATCH 5/7] cli: uncrustify gmime-filter-reply.c David Bremner
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 10+ messages in thread
From: David Bremner @ 2019-06-12 11:35 UTC (permalink / raw)
  To: notmuch

---
 debugger.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/debugger.c b/debugger.c
index 0febf170..5f47a1d7 100644
--- a/debugger.c
+++ b/debugger.c
@@ -39,8 +39,7 @@ debugger_is_active (void)
 
     sprintf (buf, "/proc/%d/exe", getppid ());
     if (readlink (buf, buf2, sizeof (buf2)) != -1 &&
-	strncmp (basename (buf2), "gdb", 3) == 0)
-    {
+	strncmp (basename (buf2), "gdb", 3) == 0) {
 	return true;
     }
 
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 5/7] cli: uncrustify gmime-filter-reply.c
  2019-06-12 11:34 Trial run uncrustifying some of the CLI David Bremner
                   ` (3 preceding siblings ...)
  2019-06-12 11:35 ` [PATCH 4/7] cli: uncrustify debugger.c David Bremner
@ 2019-06-12 11:35 ` David Bremner
  2019-06-12 11:35 ` [PATCH 6/7] cli: uncrustify hooks.c David Bremner
  2019-06-12 11:35 ` [PATCH 7/7] cli: uncrustify mime-node.c David Bremner
  6 siblings, 0 replies; 10+ messages in thread
From: David Bremner @ 2019-06-12 11:35 UTC (permalink / raw)
  To: notmuch

The previous indentation used pure tabs.
---
 gmime-filter-reply.c | 190 +++++++++++++++++++++----------------------
 1 file changed, 95 insertions(+), 95 deletions(-)

diff --git a/gmime-filter-reply.c b/gmime-filter-reply.c
index 480d9381..2b067669 100644
--- a/gmime-filter-reply.c
+++ b/gmime-filter-reply.c
@@ -47,143 +47,143 @@ static GMimeFilterClass *parent_class = NULL;
 GType
 g_mime_filter_reply_get_type (void)
 {
-	static GType type = 0;
-
-	if (!type) {
-		static const GTypeInfo info = {
-			.class_size = sizeof (GMimeFilterReplyClass),
-			.base_init = NULL,
-			.base_finalize = NULL,
-			.class_init = (GClassInitFunc) g_mime_filter_reply_class_init,
-			.class_finalize = NULL,
-			.class_data = NULL,
-			.instance_size = sizeof (GMimeFilterReply),
-			.n_preallocs = 0,
-			.instance_init = (GInstanceInitFunc) g_mime_filter_reply_init,
-			.value_table = NULL,
-		};
-
-		type = g_type_register_static (GMIME_TYPE_FILTER, "GMimeFilterReply", &info, (GTypeFlags) 0);
-	}
-
-	return type;
+    static GType type = 0;
+
+    if (! type) {
+	static const GTypeInfo info = {
+	    .class_size = sizeof (GMimeFilterReplyClass),
+	    .base_init = NULL,
+	    .base_finalize = NULL,
+	    .class_init = (GClassInitFunc) g_mime_filter_reply_class_init,
+	    .class_finalize = NULL,
+	    .class_data = NULL,
+	    .instance_size = sizeof (GMimeFilterReply),
+	    .n_preallocs = 0,
+	    .instance_init = (GInstanceInitFunc) g_mime_filter_reply_init,
+	    .value_table = NULL,
+	};
+
+	type = g_type_register_static (GMIME_TYPE_FILTER, "GMimeFilterReply", &info, (GTypeFlags) 0);
+    }
+
+    return type;
 }
 
 
 static void
 g_mime_filter_reply_class_init (GMimeFilterReplyClass *klass, unused (void *class_data))
 {
-	GObjectClass *object_class = G_OBJECT_CLASS (klass);
-	GMimeFilterClass *filter_class = GMIME_FILTER_CLASS (klass);
+    GObjectClass *object_class = G_OBJECT_CLASS (klass);
+    GMimeFilterClass *filter_class = GMIME_FILTER_CLASS (klass);
 
-	parent_class = (GMimeFilterClass *) g_type_class_ref (GMIME_TYPE_FILTER);
+    parent_class = (GMimeFilterClass *) g_type_class_ref (GMIME_TYPE_FILTER);
 
-	object_class->finalize = g_mime_filter_reply_finalize;
+    object_class->finalize = g_mime_filter_reply_finalize;
 
-	filter_class->copy = filter_copy;
-	filter_class->filter = filter_filter;
-	filter_class->complete = filter_complete;
-	filter_class->reset = filter_reset;
+    filter_class->copy = filter_copy;
+    filter_class->filter = filter_filter;
+    filter_class->complete = filter_complete;
+    filter_class->reset = filter_reset;
 }
 
 static void
 g_mime_filter_reply_init (GMimeFilterReply *filter, GMimeFilterReplyClass *klass)
 {
-	(void) klass;
-	filter->saw_nl = true;
-	filter->saw_angle = false;
+    (void) klass;
+    filter->saw_nl = true;
+    filter->saw_angle = false;
 }
 
 static void
 g_mime_filter_reply_finalize (GObject *object)
 {
-	G_OBJECT_CLASS (parent_class)->finalize (object);
+    G_OBJECT_CLASS (parent_class)->finalize (object);
 }
 
 
 static GMimeFilter *
 filter_copy (GMimeFilter *filter)
 {
-	GMimeFilterReply *reply = (GMimeFilterReply *) filter;
+    GMimeFilterReply *reply = (GMimeFilterReply *) filter;
 
-	return g_mime_filter_reply_new (reply->encode);
+    return g_mime_filter_reply_new (reply->encode);
 }
 
 static void
 filter_filter (GMimeFilter *filter, char *inbuf, size_t inlen, size_t prespace,
 	       char **outbuf, size_t *outlen, size_t *outprespace)
 {
-	GMimeFilterReply *reply = (GMimeFilterReply *) filter;
-	const char *inptr = inbuf;
-	const char *inend = inbuf + inlen;
-	char *outptr;
-
-	(void) prespace;
-	if (reply->encode) {
-		g_mime_filter_set_size (filter, 3 * inlen, false);
-
-		outptr = filter->outbuf;
-		while (inptr < inend) {
-			if (reply->saw_nl) {
-				*outptr++ = '>';
-				*outptr++ = ' ';
-				reply->saw_nl = false;
-			}
-			if (*inptr == '\n')
-				reply->saw_nl = true;
-			else
-				reply->saw_nl = false;
-			if (*inptr != '\r')
-				*outptr++ = *inptr;
-			inptr++;
-		}
-	} else {
-		g_mime_filter_set_size (filter, inlen + 1, false);
-
-		outptr = filter->outbuf;
-		while (inptr < inend) {
-			if (reply->saw_nl) {
-				if (*inptr == '>')
-					reply->saw_angle = true;
-				else
-					*outptr++ = *inptr;
-				reply->saw_nl = false;
-			} else if (reply->saw_angle) {
-				if (*inptr == ' ')
-					;
-				else
-					*outptr++ = *inptr;
-				reply->saw_angle = false;
-			} else if (*inptr != '\r') {
-				if (*inptr == '\n')
-					reply->saw_nl = true;
-				*outptr++ = *inptr;
-			}
-
-			inptr++;
-		}
+    GMimeFilterReply *reply = (GMimeFilterReply *) filter;
+    const char *inptr = inbuf;
+    const char *inend = inbuf + inlen;
+    char *outptr;
+
+    (void) prespace;
+    if (reply->encode) {
+	g_mime_filter_set_size (filter, 3 * inlen, false);
+
+	outptr = filter->outbuf;
+	while (inptr < inend) {
+	    if (reply->saw_nl) {
+		*outptr++ = '>';
+		*outptr++ = ' ';
+		reply->saw_nl = false;
+	    }
+	    if (*inptr == '\n')
+		reply->saw_nl = true;
+	    else
+		reply->saw_nl = false;
+	    if (*inptr != '\r')
+		*outptr++ = *inptr;
+	    inptr++;
+	}
+    } else {
+	g_mime_filter_set_size (filter, inlen + 1, false);
+
+	outptr = filter->outbuf;
+	while (inptr < inend) {
+	    if (reply->saw_nl) {
+		if (*inptr == '>')
+		    reply->saw_angle = true;
+		else
+		    *outptr++ = *inptr;
+		reply->saw_nl = false;
+	    } else if (reply->saw_angle) {
+		if (*inptr == ' ')
+		    ;
+		else
+		    *outptr++ = *inptr;
+		reply->saw_angle = false;
+	    } else if (*inptr != '\r') {
+		if (*inptr == '\n')
+		    reply->saw_nl = true;
+		*outptr++ = *inptr;
+	    }
+
+	    inptr++;
 	}
+    }
 
-	*outlen = outptr - filter->outbuf;
-	*outprespace = filter->outpre;
-	*outbuf = filter->outbuf;
+    *outlen = outptr - filter->outbuf;
+    *outprespace = filter->outpre;
+    *outbuf = filter->outbuf;
 }
 
 static void
 filter_complete (GMimeFilter *filter, char *inbuf, size_t inlen, size_t prespace,
 		 char **outbuf, size_t *outlen, size_t *outprespace)
 {
-	if (inbuf && inlen)
-		filter_filter (filter, inbuf, inlen, prespace, outbuf, outlen, outprespace);
+    if (inbuf && inlen)
+	filter_filter (filter, inbuf, inlen, prespace, outbuf, outlen, outprespace);
 }
 
 static void
 filter_reset (GMimeFilter *filter)
 {
-	GMimeFilterReply *reply = (GMimeFilterReply *) filter;
+    GMimeFilterReply *reply = (GMimeFilterReply *) filter;
 
-	reply->saw_nl = true;
-	reply->saw_angle = false;
+    reply->saw_nl = true;
+    reply->saw_angle = false;
 }
 
 
@@ -202,11 +202,11 @@ filter_reset (GMimeFilter *filter)
 GMimeFilter *
 g_mime_filter_reply_new (gboolean encode)
 {
-	GMimeFilterReply *new_reply;
+    GMimeFilterReply *new_reply;
 
-	new_reply = (GMimeFilterReply *) g_object_new (GMIME_TYPE_FILTER_REPLY, NULL);
-	new_reply->encode = encode;
+    new_reply = (GMimeFilterReply *) g_object_new (GMIME_TYPE_FILTER_REPLY, NULL);
+    new_reply->encode = encode;
 
-	return (GMimeFilter *) new_reply;
+    return (GMimeFilter *) new_reply;
 }
 
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 6/7] cli: uncrustify hooks.c
  2019-06-12 11:34 Trial run uncrustifying some of the CLI David Bremner
                   ` (4 preceding siblings ...)
  2019-06-12 11:35 ` [PATCH 5/7] cli: uncrustify gmime-filter-reply.c David Bremner
@ 2019-06-12 11:35 ` David Bremner
  2019-06-12 11:35 ` [PATCH 7/7] cli: uncrustify mime-node.c David Bremner
  6 siblings, 0 replies; 10+ messages in thread
From: David Bremner @ 2019-06-12 11:35 UTC (permalink / raw)
  To: notmuch

---
 hooks.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/hooks.c b/hooks.c
index 7348d322..59c58070 100644
--- a/hooks.c
+++ b/hooks.c
@@ -53,7 +53,7 @@ notmuch_run_hook (const char *db_path, const char *hook)
     /* Flush any buffered output before forking. */
     fflush (stdout);
 
-    pid = fork();
+    pid = fork ();
     if (pid == -1) {
 	fprintf (stderr, "Error: %s hook fork failed: %s\n", hook,
 		 strerror (errno));
@@ -78,7 +78,7 @@ notmuch_run_hook (const char *db_path, const char *hook)
 	goto DONE;
     }
 
-    if (!WIFEXITED (status) || WEXITSTATUS (status)) {
+    if (! WIFEXITED (status) || WEXITSTATUS (status)) {
 	if (WIFEXITED (status)) {
 	    fprintf (stderr, "Error: %s hook failed with status %d\n",
 		     hook, WEXITSTATUS (status));
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 7/7] cli: uncrustify mime-node.c
  2019-06-12 11:34 Trial run uncrustifying some of the CLI David Bremner
                   ` (5 preceding siblings ...)
  2019-06-12 11:35 ` [PATCH 6/7] cli: uncrustify hooks.c David Bremner
@ 2019-06-12 11:35 ` David Bremner
  6 siblings, 0 replies; 10+ messages in thread
From: David Bremner @ 2019-06-12 11:35 UTC (permalink / raw)
  To: notmuch

Cuddle a few parens on function calls per Tomi's suggestion to make
uncrustify match emacs indentation.
---
 mime-node.c | 34 +++++++++++++++++-----------------
 1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/mime-node.c b/mime-node.c
index a93cbb31..3133ca44 100644
--- a/mime-node.c
+++ b/mime-node.c
@@ -55,7 +55,7 @@ _mime_node_context_free (mime_node_context_t *res)
     return 0;
 }
 
-const _notmuch_message_crypto_t*
+const _notmuch_message_crypto_t *
 mime_node_get_message_crypto_status (mime_node_t *node)
 {
     return node->ctx->msg_crypto;
@@ -97,8 +97,7 @@ mime_node_open (const void *ctx, notmuch_message_t *message,
 	notmuch_filenames_t *filenames;
 	for (filenames = notmuch_message_get_filenames (message);
 	     notmuch_filenames_valid (filenames);
-	     notmuch_filenames_move_to_next (filenames))
-	{
+	     notmuch_filenames_move_to_next (filenames)) {
 	    filename = notmuch_filenames_get (filenames);
 	    fd = open (filename, O_RDONLY);
 	    if (fd != -1)
@@ -109,27 +108,27 @@ mime_node_open (const void *ctx, notmuch_message_t *message,
 	if (fd == -1) {
 	    /* Give up */
 	    fprintf (stderr, "Error opening %s: %s\n", filename, strerror (errno));
-		status = NOTMUCH_STATUS_FILE_ERROR;
-		goto DONE;
-	    }
+	    status = NOTMUCH_STATUS_FILE_ERROR;
+	    goto DONE;
 	}
+    }
 
     mctx->stream = g_mime_stream_gzfile_new (fd);
-    if (!mctx->stream) {
+    if (! mctx->stream) {
 	fprintf (stderr, "Out of memory.\n");
 	status = NOTMUCH_STATUS_OUT_OF_MEMORY;
 	goto DONE;
     }
 
     mctx->parser = g_mime_parser_new_with_stream (mctx->stream);
-    if (!mctx->parser) {
+    if (! mctx->parser) {
 	fprintf (stderr, "Out of memory.\n");
 	status = NOTMUCH_STATUS_OUT_OF_MEMORY;
 	goto DONE;
     }
 
     mctx->mime_message = g_mime_parser_construct_message (mctx->parser, NULL);
-    if (!mctx->mime_message) {
+    if (! mctx->mime_message) {
 	fprintf (stderr, "Failed to parse %s\n", filename);
 	status = NOTMUCH_STATUS_FILE_ERROR;
 	goto DONE;
@@ -153,7 +152,7 @@ mime_node_open (const void *ctx, notmuch_message_t *message,
     *root_out = root;
     return NOTMUCH_STATUS_SUCCESS;
 
-DONE:
+  DONE:
     talloc_free (root);
     return status;
 }
@@ -171,6 +170,7 @@ static void
 set_signature_list_destructor (mime_node_t *node)
 {
     GMimeSignatureList **proxy = talloc (node, GMimeSignatureList *);
+
     if (proxy) {
 	*proxy = node->sig_list;
 	talloc_set_destructor (proxy, _signature_list_free);
@@ -185,8 +185,8 @@ node_verify (mime_node_t *node, GMimeObject *part)
     notmuch_status_t status;
 
     node->verify_attempted = true;
-    node->sig_list = g_mime_multipart_signed_verify
-	(GMIME_MULTIPART_SIGNED (part), GMIME_ENCRYPT_NONE, &err);
+    node->sig_list = g_mime_multipart_signed_verify (
+	GMIME_MULTIPART_SIGNED (part), GMIME_ENCRYPT_NONE, &err);
 
     if (node->sig_list)
 	set_signature_list_destructor (node);
@@ -259,7 +259,7 @@ node_decrypt_and_verify (mime_node_t *node, GMimeObject *part)
 	g_object_unref (decrypt_result);
     }
 
- DONE:
+  DONE:
     if (err)
 	g_error_free (err);
 }
@@ -273,7 +273,7 @@ _mime_node_create (mime_node_t *parent, GMimeObject *part, int numchild)
     /* Set basic node properties */
     node->part = part;
     node->ctx = parent->ctx;
-    if (!talloc_reference (node, node->ctx)) {
+    if (! talloc_reference (node, node->ctx)) {
 	fprintf (stderr, "Out of memory.\n");
 	talloc_free (node);
 	return NULL;
@@ -335,15 +335,15 @@ mime_node_child (mime_node_t *parent, int child)
     GMimeObject *sub;
     mime_node_t *node;
 
-    if (!parent || !parent->part || child < 0 || child >= parent->nchildren)
+    if (! parent || ! parent->part || child < 0 || child >= parent->nchildren)
 	return NULL;
 
     if (GMIME_IS_MULTIPART (parent->part)) {
 	if (child == GMIME_MULTIPART_ENCRYPTED_CONTENT && parent->decrypted_child)
 	    sub = parent->decrypted_child;
 	else
-	    sub = g_mime_multipart_get_part
-		(GMIME_MULTIPART (parent->part), child);
+	    sub = g_mime_multipart_get_part (
+		GMIME_MULTIPART (parent->part), child);
     } else if (GMIME_IS_MESSAGE (parent->part)) {
 	sub = g_mime_message_get_mime_part (GMIME_MESSAGE (parent->part));
     } else {
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/7] cli: replace use of !! with macro
  2019-06-12 11:35 ` [PATCH 1/7] cli: replace use of !! with macro David Bremner
@ 2019-06-12 20:13   ` Tomi Ollila
  2019-06-12 20:17   ` Jorge P. de Morais Neto
  1 sibling, 0 replies; 10+ messages in thread
From: Tomi Ollila @ 2019-06-12 20:13 UTC (permalink / raw)
  To: David Bremner, notmuch

On Wed, Jun 12 2019, David Bremner wrote:

> The slightly annoying reason to do this is because uncrustify can't
> handle '!! foo' sensibly. The less annoying reason is that it helps
> understand what the code does.
> ---
>  command-line-arguments.c | 16 +++++++++-------
>  1 file changed, 9 insertions(+), 7 deletions(-)
>
> diff --git a/command-line-arguments.c b/command-line-arguments.c
> index d64aa85b..5f0607be 100644
> --- a/command-line-arguments.c
> +++ b/command-line-arguments.c
> @@ -4,6 +4,8 @@
>  #include "error_util.h"
>  #include "command-line-arguments.h"
>  
> +#define TO_BOOL(thing) (!! thing)

If this is the way, then #define TO_BOOL(thing) (!! (thing))

(does uncrustify then change this to (! ! (thing)) ?

Alternative is to do (bool) cast -- i.e. return (bool)opt_desc->opt_inherit + (bool) ...

-- for the question in PATCH 0 -email:

I'd prefer just one commit doing all the uncrustify changes for now, and
preferably set 

GIT_AUTHOR_NAME=uncrustify

(GIT_AUTHOR_EMAIL not modified)

this way anyone who does git annotate can easily see who not to blame for
changes and notice what such style changes was done at the same time...

after first big bump in it is easier to fix some leftover smaller things
(if any) -- incrementally, as the effort required is significantly smaller...


I'm not sure whether TO_BOOL looks so good, but these changes LGTM. someone
more familiar seeing '!!' in other codebases could comment??


Tomi

> +
>  typedef enum {
>      OPT_FAILED, /* false */
>      OPT_OK, /* good */
> @@ -120,13 +122,13 @@ _process_string_arg (const notmuch_opt_desc_t *arg_desc, char next, const char *
>  static int _opt_set_count (const notmuch_opt_desc_t *opt_desc)
>  {
>      return
> -	!!opt_desc->opt_inherit +
> -	!!opt_desc->opt_bool +
> -	!!opt_desc->opt_int +
> -	!!opt_desc->opt_keyword +
> -	!!opt_desc->opt_flags +
> -	!!opt_desc->opt_string +
> -	!!opt_desc->opt_position;
> +	TO_BOOL (opt_desc->opt_inherit) +
> +	TO_BOOL (opt_desc->opt_bool) +
> +	TO_BOOL (opt_desc->opt_int) +
> +	TO_BOOL (opt_desc->opt_keyword) +
> +	TO_BOOL (opt_desc->opt_flags) +
> +	TO_BOOL (opt_desc->opt_string) +
> +	TO_BOOL (opt_desc->opt_position);
>  }
>  
>  /* Return true if opt_desc is valid. */
> -- 
> 2.20.1
>
> _______________________________________________
> notmuch mailing list
> notmuch@notmuchmail.org
> https://notmuchmail.org/mailman/listinfo/notmuch

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/7] cli: replace use of !! with macro
  2019-06-12 11:35 ` [PATCH 1/7] cli: replace use of !! with macro David Bremner
  2019-06-12 20:13   ` Tomi Ollila
@ 2019-06-12 20:17   ` Jorge P. de Morais Neto
  1 sibling, 0 replies; 10+ messages in thread
From: Jorge P. de Morais Neto @ 2019-06-12 20:17 UTC (permalink / raw)
  To: David Bremner, notmuch

Hi.  Isn't it good practice to parenthesize the arguments of C macros?
So TO_BOOL would be defined as

#define TO_BOOL(thing) (!! (thing))

In fact, why not just cast to bool?

Regards

David Bremner <david@tethera.net> writes:

> The slightly annoying reason to do this is because uncrustify can't
> handle '!! foo' sensibly. The less annoying reason is that it helps
> understand what the code does.
> ---
>  command-line-arguments.c | 16 +++++++++-------
>  1 file changed, 9 insertions(+), 7 deletions(-)
>
> diff --git a/command-line-arguments.c b/command-line-arguments.c
> index d64aa85b..5f0607be 100644
> --- a/command-line-arguments.c
> +++ b/command-line-arguments.c
> @@ -4,6 +4,8 @@
>  #include "error_util.h"
>  #include "command-line-arguments.h"
>  
> +#define TO_BOOL(thing) (!! thing)
> +
>  typedef enum {
>      OPT_FAILED, /* false */
>      OPT_OK, /* good */
> @@ -120,13 +122,13 @@ _process_string_arg (const notmuch_opt_desc_t *arg_desc, char next, const char *
>  static int _opt_set_count (const notmuch_opt_desc_t *opt_desc)
>  {
>      return
> -	!!opt_desc->opt_inherit +
> -	!!opt_desc->opt_bool +
> -	!!opt_desc->opt_int +
> -	!!opt_desc->opt_keyword +
> -	!!opt_desc->opt_flags +
> -	!!opt_desc->opt_string +
> -	!!opt_desc->opt_position;
> +	TO_BOOL (opt_desc->opt_inherit) +
> +	TO_BOOL (opt_desc->opt_bool) +
> +	TO_BOOL (opt_desc->opt_int) +
> +	TO_BOOL (opt_desc->opt_keyword) +
> +	TO_BOOL (opt_desc->opt_flags) +
> +	TO_BOOL (opt_desc->opt_string) +
> +	TO_BOOL (opt_desc->opt_position);
>  }
>  
>  /* Return true if opt_desc is valid. */
> -- 
> 2.20.1
>
> _______________________________________________
> notmuch mailing list
> notmuch@notmuchmail.org
> https://notmuchmail.org/mailman/listinfo/notmuch

-- 
- I am Brazilian.  I hope my English is correct and I welcome feedback
- Please adopt free formats like PDF, ODF, Org, LaTeX, Opus, WebM and 7z
- Free/libre software for Android: https://f-droid.org/
- [[https://www.gnu.org/philosophy/free-sw.html][What is free software?]]

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2019-06-12 20:18 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-12 11:34 Trial run uncrustifying some of the CLI David Bremner
2019-06-12 11:35 ` [PATCH 1/7] cli: replace use of !! with macro David Bremner
2019-06-12 20:13   ` Tomi Ollila
2019-06-12 20:17   ` Jorge P. de Morais Neto
2019-06-12 11:35 ` [PATCH 2/7] devel: remove between ++ / -- and argument David Bremner
2019-06-12 11:35 ` [PATCH 3/7] cli: uncrustify command-line-arguments.c David Bremner
2019-06-12 11:35 ` [PATCH 4/7] cli: uncrustify debugger.c David Bremner
2019-06-12 11:35 ` [PATCH 5/7] cli: uncrustify gmime-filter-reply.c David Bremner
2019-06-12 11:35 ` [PATCH 6/7] cli: uncrustify hooks.c David Bremner
2019-06-12 11:35 ` [PATCH 7/7] cli: uncrustify mime-node.c David Bremner

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).