1 Return-Path: <m.walters@qmul.ac.uk>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by olra.theworths.org (Postfix) with ESMTP id 130FB431FBD
\r
6 for <notmuch@notmuchmail.org>; Sat, 18 Jan 2014 05:16:46 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-1.098 tagged_above=-999 required=5
\r
12 tests=[DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001,
\r
13 NML_ADSP_CUSTOM_MED=1.2, RCVD_IN_DNSWL_MED=-2.3] autolearn=disabled
\r
14 Received: from olra.theworths.org ([127.0.0.1])
\r
15 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
16 with ESMTP id xhGhAMJq2WuZ for <notmuch@notmuchmail.org>;
\r
17 Sat, 18 Jan 2014 05:16:38 -0800 (PST)
\r
18 Received: from mail2.qmul.ac.uk (mail2.qmul.ac.uk [138.37.6.6])
\r
19 (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
\r
20 (No client certificate requested)
\r
21 by olra.theworths.org (Postfix) with ESMTPS id CD175431FBC
\r
22 for <notmuch@notmuchmail.org>; Sat, 18 Jan 2014 05:16:37 -0800 (PST)
\r
23 Received: from smtp.qmul.ac.uk ([138.37.6.40])
\r
24 by mail2.qmul.ac.uk with esmtp (Exim 4.71)
\r
25 (envelope-from <m.walters@qmul.ac.uk>)
\r
26 id 1W4VlL-00011V-7F; Sat, 18 Jan 2014 13:16:35 +0000
\r
27 Received: from 93-97-24-31.zone5.bethere.co.uk ([93.97.24.31] helo=localhost)
\r
28 by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.71)
\r
29 (envelope-from <m.walters@qmul.ac.uk>)
\r
30 id 1W4VlK-0004Ni-E4; Sat, 18 Jan 2014 13:16:35 +0000
\r
31 From: Mark Walters <markwalters1009@gmail.com>
\r
32 To: Tomi Ollila <tomi.ollila@iki.fi>, notmuch@notmuchmail.org
\r
33 Subject: Re: [PATCH 1/1] cli: tuned coding style on a small set of c files in
\r
35 In-Reply-To: <1388843250-4714-1-git-send-email-tomi.ollila@iki.fi>
\r
36 References: <1388843250-4714-1-git-send-email-tomi.ollila@iki.fi>
\r
37 User-Agent: Notmuch/0.15.2+484~gfb59956 (http://notmuchmail.org) Emacs/23.4.1
\r
38 (x86_64-pc-linux-gnu)
\r
39 Date: Sat, 18 Jan 2014 13:16:33 +0000
\r
40 Message-ID: <87lhydctvy.fsf@qmul.ac.uk>
\r
42 Content-Type: text/plain; charset=us-ascii
\r
43 X-Sender-Host-Address: 93.97.24.31
\r
44 X-QM-Geographic: According to ripencc,
\r
45 this message was delivered by a machine in Britain (UK) (GB).
\r
46 X-QM-SPAM-Info: Sender has good ham record. :)
\r
47 X-QM-Body-MD5: de2d6c0d930d895c26e44591c04790f2 (of first 20000 bytes)
\r
48 X-SpamAssassin-Score: 0.0
\r
49 X-SpamAssassin-SpamBar: /
\r
50 X-SpamAssassin-Report: The QM spam filters have analysed this message to
\r
52 spam. We require at least 5.0 points to mark a message as spam.
\r
53 This message scored 0.0 points. Summary of the scoring:
\r
54 * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail
\r
55 provider * (markwalters1009[at]gmail.com)
\r
56 * 0.0 AWL AWL: From: address is in the auto white-list
\r
57 X-QM-Scan-Virus: ClamAV says the message is clean
\r
58 Cc: tomi.ollila@iki.fi
\r
59 X-BeenThere: notmuch@notmuchmail.org
\r
60 X-Mailman-Version: 2.1.13
\r
62 List-Id: "Use and development of the notmuch mail system."
\r
63 <notmuch.notmuchmail.org>
\r
64 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
65 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
66 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
67 List-Post: <mailto:notmuch@notmuchmail.org>
\r
68 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
69 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
70 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
71 X-List-Received-Date: Sat, 18 Jan 2014 13:16:46 -0000
\r
74 This basically looks good. There was one type of change I was unsure
\r
77 On Sat, 04 Jan 2014, Tomi Ollila <tomi.ollila@iki.fi> wrote:
\r
78 > The c files in root directory not starting with 'notmuch'.
\r
80 > gmime-filter-reply.c used 8-character indenting and seems to
\r
81 > be "external" in this project; therefore it was left intact.
\r
83 > No functional change.
\r
86 > Based on the response to this patch I may submit much larger
\r
87 > patch which tunes the style in ./notmuch*.[ch] files...
\r
89 > command-line-arguments.c | 71 +++++++++++++++++++++++++++---------------------
\r
90 > command-line-arguments.h | 34 +++++++++++------------
\r
93 > mime-node.c | 24 ++++++++--------
\r
94 > 5 files changed, 73 insertions(+), 63 deletions(-)
\r
96 > diff --git a/command-line-arguments.c b/command-line-arguments.c
\r
97 > index bf9aeca..969269c 100644
\r
98 > --- a/command-line-arguments.c
\r
99 > +++ b/command-line-arguments.c
\r
100 > @@ -5,13 +5,14 @@
\r
101 > #include "command-line-arguments.h"
\r
104 > - Search the array of keywords for a given argument, assigning the
\r
105 > - output variable to the corresponding value. Return FALSE if nothing
\r
108 > + * Search the array of keywords for a given argument, assigning the
\r
109 > + * output variable to the corresponding value. Return FALSE if nothing
\r
113 > static notmuch_bool_t
\r
114 > -_process_keyword_arg (const notmuch_opt_desc_t *arg_desc, char next, const char *arg_str) {
\r
115 > +_process_keyword_arg (const notmuch_opt_desc_t *arg_desc, char next, const char *arg_str)
\r
118 > const notmuch_keyword_t *keywords = arg_desc->keywords;
\r
121 Should the blank line be deleted now the { is on its own line? This type
\r
122 of change occurred several times.
\r
128 > @@ -23,7 +24,7 @@ _process_keyword_arg (const notmuch_opt_desc_t *arg_desc, char next, const char
\r
129 > while (keywords->name) {
\r
130 > if (strcmp (arg_str, keywords->name) == 0) {
\r
131 > if (arg_desc->output_var) {
\r
132 > - *((int *)arg_desc->output_var) = keywords->value;
\r
133 > + *((int *) arg_desc->output_var) = keywords->value;
\r
137 > @@ -37,18 +38,19 @@ _process_keyword_arg (const notmuch_opt_desc_t *arg_desc, char next, const char
\r
140 > static notmuch_bool_t
\r
141 > -_process_boolean_arg (const notmuch_opt_desc_t *arg_desc, char next, const char *arg_str) {
\r
142 > +_process_boolean_arg (const notmuch_opt_desc_t *arg_desc, char next, const char *arg_str)
\r
145 > if (next == '\0') {
\r
146 > - *((notmuch_bool_t *)arg_desc->output_var) = TRUE;
\r
147 > + *((notmuch_bool_t *) arg_desc->output_var) = TRUE;
\r
150 > if (strcmp (arg_str, "false") == 0) {
\r
151 > - *((notmuch_bool_t *)arg_desc->output_var) = FALSE;
\r
152 > + *((notmuch_bool_t *) arg_desc->output_var) = FALSE;
\r
155 > if (strcmp (arg_str, "true") == 0) {
\r
156 > - *((notmuch_bool_t *)arg_desc->output_var) = TRUE;
\r
157 > + *((notmuch_bool_t *) arg_desc->output_var) = TRUE;
\r
160 > fprintf (stderr, "Unknown argument \"%s\" for (boolean) option \"%s\".\n", arg_str, arg_desc->name);
\r
161 > @@ -56,15 +58,17 @@ _process_boolean_arg (const notmuch_opt_desc_t *arg_desc, char next, const char
\r
164 > static notmuch_bool_t
\r
165 > -_process_int_arg (const notmuch_opt_desc_t *arg_desc, char next, const char *arg_str) {
\r
166 > +_process_int_arg (const notmuch_opt_desc_t *arg_desc, char next, const char *arg_str)
\r
171 > if (next == '\0' || arg_str[0] == '\0') {
\r
172 > fprintf (stderr, "Option \"%s\" needs an integer argument.\n", arg_desc->name);
\r
176 > - *((int *)arg_desc->output_var) = strtol (arg_str, &endptr, 10);
\r
177 > + *((int *) arg_desc->output_var) = strtol (arg_str, &endptr, 10);
\r
178 > if (*endptr == '\0')
\r
181 > @@ -74,7 +78,8 @@ _process_int_arg (const notmuch_opt_desc_t *arg_desc, char next, const char *arg
\r
184 > static notmuch_bool_t
\r
185 > -_process_string_arg (const notmuch_opt_desc_t *arg_desc, char next, const char *arg_str) {
\r
186 > +_process_string_arg (const notmuch_opt_desc_t *arg_desc, char next, const char *arg_str)
\r
189 > if (next == '\0') {
\r
190 > fprintf (stderr, "Option \"%s\" needs a string argument.\n", arg_desc->name);
\r
191 > @@ -84,25 +89,27 @@ _process_string_arg (const notmuch_opt_desc_t *arg_desc, char next, const char *
\r
192 > fprintf (stderr, "String argument for option \"%s\" must be non-empty.\n", arg_desc->name);
\r
195 > - *((const char **)arg_desc->output_var) = arg_str;
\r
196 > + *((const char **) arg_desc->output_var) = arg_str;
\r
201 > - Search for the {pos_arg_index}th position argument, return FALSE if
\r
202 > - that does not exist.
\r
204 > + * Search for the {pos_arg_index}th position argument, return FALSE if
\r
205 > + * that does not exist.
\r
209 > parse_position_arg (const char *arg_str, int pos_arg_index,
\r
210 > - const notmuch_opt_desc_t *arg_desc) {
\r
211 > + const notmuch_opt_desc_t *arg_desc)
\r
214 > int pos_arg_counter = 0;
\r
215 > - while (arg_desc->opt_type != NOTMUCH_OPT_END){
\r
217 > + while (arg_desc->opt_type != NOTMUCH_OPT_END) {
\r
218 > if (arg_desc->opt_type == NOTMUCH_OPT_POSITION) {
\r
219 > if (pos_arg_counter == pos_arg_index) {
\r
220 > if (arg_desc->output_var) {
\r
221 > - *((const char **)arg_desc->output_var) = arg_str;
\r
222 > + *((const char **) arg_desc->output_var) = arg_str;
\r
226 > @@ -120,10 +127,11 @@ parse_position_arg (const char *arg_str, int pos_arg_index,
\r
229 > parse_option (const char *arg,
\r
230 > - const notmuch_opt_desc_t *options) {
\r
231 > + const notmuch_opt_desc_t *options)
\r
235 > - assert(options);
\r
237 > + assert (options);
\r
241 > @@ -131,13 +139,13 @@ parse_option (const char *arg,
\r
242 > for (try = options; try->opt_type != NOTMUCH_OPT_END; try++) {
\r
243 > if (try->name && strncmp (arg, try->name, strlen (try->name)) == 0) {
\r
244 > char next = arg[strlen (try->name)];
\r
245 > - const char *value= arg+strlen(try->name)+1;
\r
246 > + const char *value = arg + strlen (try->name) + 1;
\r
248 > /* If we have not reached the end of the argument
\r
249 > - (i.e. the next character is not a space or delimiter)
\r
250 > - then the argument could still match a longer option
\r
251 > - name later in the option table.
\r
253 > + * (i.e. the next character is not a space or delimiter)
\r
254 > + * then the argument could still match a longer option
\r
255 > + * name later in the option table.
\r
257 > if (next != '=' && next != ':' && next != '\0')
\r
260 > @@ -172,13 +180,14 @@ parse_option (const char *arg,
\r
261 > /* See command-line-arguments.h for description */
\r
263 > parse_arguments (int argc, char **argv,
\r
264 > - const notmuch_opt_desc_t *options, int opt_index) {
\r
265 > + const notmuch_opt_desc_t *options, int opt_index)
\r
268 > int pos_arg_index = 0;
\r
269 > notmuch_bool_t more_args = TRUE;
\r
271 > while (more_args && opt_index < argc) {
\r
272 > - if (strncmp (argv[opt_index],"--",2) != 0) {
\r
273 > + if (strncmp (argv[opt_index], "--", 2) != 0) {
\r
275 > more_args = parse_position_arg (argv[opt_index], pos_arg_index, options);
\r
277 > @@ -190,7 +199,7 @@ parse_arguments (int argc, char **argv,
\r
280 > if (strlen (argv[opt_index]) == 2)
\r
281 > - return opt_index+1;
\r
282 > + return opt_index + 1;
\r
284 > more_args = parse_option (argv[opt_index], options);
\r
286 > diff --git a/command-line-arguments.h b/command-line-arguments.h
\r
287 > index de1734a..3ac714e 100644
\r
288 > --- a/command-line-arguments.h
\r
289 > +++ b/command-line-arguments.h
\r
290 > @@ -37,26 +37,26 @@ typedef struct notmuch_opt_desc {
\r
291 > enum notmuch_opt_type opt_type;
\r
292 > void *output_var;
\r
293 > const char *name;
\r
296 > const struct notmuch_keyword *keywords;
\r
297 > } notmuch_opt_desc_t;
\r
301 > - This is the main entry point for command line argument parsing.
\r
303 > - Parse command line arguments according to structure options,
\r
304 > - starting at position opt_index.
\r
306 > - All output of parsed values is via pointers in options.
\r
308 > - Parsing stops at -- (consumed) or at the (k+1)st argument
\r
309 > - not starting with -- (a "positional argument") if options contains
\r
310 > - k positional argument descriptors.
\r
312 > - Returns the index of first non-parsed argument, or -1 in case of error.
\r
315 > + * This is the main entry point for command line argument parsing.
\r
317 > + * Parse command line arguments according to structure options,
\r
318 > + * starting at position opt_index.
\r
320 > + * All output of parsed values is via pointers in options.
\r
322 > + * Parsing stops at -- (consumed) or at the (k+1)st argument
\r
323 > + * not starting with -- (a "positional argument") if options contains
\r
324 > + * k positional argument descriptors.
\r
326 > + * Returns the index of first non-parsed argument, or -1 in case of error.
\r
330 > parse_arguments (int argc, char **argv, const notmuch_opt_desc_t *options, int opt_index);
\r
332 > @@ -69,12 +69,12 @@ parse_arguments (int argc, char **argv, const notmuch_opt_desc_t *options, int o
\r
336 > -parse_option (const char *arg, const notmuch_opt_desc_t* options);
\r
337 > +parse_option (const char *arg, const notmuch_opt_desc_t *options);
\r
340 > parse_position_arg (const char *arg,
\r
341 > int position_arg_index,
\r
342 > - const notmuch_opt_desc_t* options);
\r
343 > + const notmuch_opt_desc_t *options);
\r
347 > diff --git a/debugger.c b/debugger.c
\r
348 > index e8b9378..1d35e1f 100644
\r
351 > @@ -38,8 +38,7 @@ debugger_is_active (void)
\r
353 > sprintf (buf, "/proc/%d/exe", getppid ());
\r
354 > if (readlink (buf, buf, sizeof (buf)) != -1 &&
\r
355 > - strncmp (basename (buf), "gdb", 3) == 0)
\r
357 > + strncmp (basename (buf), "gdb", 3) == 0) {
\r
361 > diff --git a/hooks.c b/hooks.c
\r
362 > index 44ee419..d995171 100644
\r
365 > @@ -50,7 +50,7 @@ notmuch_run_hook (const char *db_path, const char *hook)
\r
372 > fprintf (stderr, "Error: %s hook fork failed: %s\n", hook,
\r
373 > strerror (errno));
\r
374 > @@ -75,7 +75,7 @@ notmuch_run_hook (const char *db_path, const char *hook)
\r
378 > - if (!WIFEXITED (status) || WEXITSTATUS (status)) {
\r
379 > + if (! WIFEXITED (status) || WEXITSTATUS (status)) {
\r
380 > if (WIFEXITED (status)) {
\r
381 > fprintf (stderr, "Error: %s hook failed with status %d\n",
\r
382 > hook, WEXITSTATUS (status));
\r
383 > diff --git a/mime-node.c b/mime-node.c
\r
384 > index fd9e4a4..2ff93de 100644
\r
385 > --- a/mime-node.c
\r
386 > +++ b/mime-node.c
\r
387 > @@ -87,7 +87,7 @@ mime_node_open (const void *ctx, notmuch_message_t *message,
\r
390 > mctx->stream = g_mime_stream_file_new (mctx->file);
\r
391 > - if (!mctx->stream) {
\r
392 > + if (! mctx->stream) {
\r
393 > fprintf (stderr, "Out of memory.\n");
\r
394 > status = NOTMUCH_STATUS_OUT_OF_MEMORY;
\r
396 > @@ -95,14 +95,14 @@ mime_node_open (const void *ctx, notmuch_message_t *message,
\r
397 > g_mime_stream_file_set_owner (GMIME_STREAM_FILE (mctx->stream), FALSE);
\r
399 > mctx->parser = g_mime_parser_new_with_stream (mctx->stream);
\r
400 > - if (!mctx->parser) {
\r
401 > + if (! mctx->parser) {
\r
402 > fprintf (stderr, "Out of memory.\n");
\r
403 > status = NOTMUCH_STATUS_OUT_OF_MEMORY;
\r
407 > mctx->mime_message = g_mime_parser_construct_message (mctx->parser);
\r
408 > - if (!mctx->mime_message) {
\r
409 > + if (! mctx->mime_message) {
\r
410 > fprintf (stderr, "Failed to parse %s\n", filename);
\r
411 > status = NOTMUCH_STATUS_FILE_ERROR;
\r
413 > @@ -124,7 +124,7 @@ mime_node_open (const void *ctx, notmuch_message_t *message,
\r
414 > *root_out = root;
\r
415 > return NOTMUCH_STATUS_SUCCESS;
\r
419 > talloc_free (root);
\r
422 > @@ -144,6 +144,7 @@ static void
\r
423 > set_signature_list_destructor (mime_node_t *node)
\r
425 > GMimeSignatureList **proxy = talloc (node, GMimeSignatureList *);
\r
428 > *proxy = node->sig_list;
\r
429 > talloc_set_destructor (proxy, _signature_list_free);
\r
430 > @@ -200,7 +201,7 @@ node_decrypt_and_verify (mime_node_t *node, GMimeObject *part,
\r
432 > g_object_unref (decrypt_result);
\r
437 > g_error_free (err);
\r
439 > @@ -221,6 +222,7 @@ set_signature_validity_destructor (mime_node_t *node,
\r
440 > GMimeSignatureValidity *sig_validity)
\r
442 > GMimeSignatureValidity **proxy = talloc (node, GMimeSignatureValidity *);
\r
445 > *proxy = sig_validity;
\r
446 > talloc_set_destructor (proxy, _signature_validity_free);
\r
447 > @@ -279,12 +281,12 @@ node_decrypt_and_verify (mime_node_t *node, GMimeObject *part,
\r
448 > fprintf (stderr, "Failed to verify encrypted signed part: %s\n",
\r
449 > err ? err->message : "no error explanation given");
\r
454 > g_error_free (err);
\r
457 > -#endif /* GMIME_ATLEAST_26 */
\r
458 > +#endif /* GMIME_ATLEAST_26 */
\r
460 > static mime_node_t *
\r
461 > _mime_node_create (mime_node_t *parent, GMimeObject *part)
\r
462 > @@ -295,7 +297,7 @@ _mime_node_create (mime_node_t *parent, GMimeObject *part)
\r
463 > /* Set basic node properties */
\r
464 > node->part = part;
\r
465 > node->ctx = parent->ctx;
\r
466 > - if (!talloc_reference (node, node->ctx)) {
\r
467 > + if (! talloc_reference (node, node->ctx)) {
\r
468 > fprintf (stderr, "Out of memory.\n");
\r
469 > talloc_free (node);
\r
471 > @@ -360,7 +362,7 @@ mime_node_child (mime_node_t *parent, int child)
\r
472 > GMimeObject *sub;
\r
473 > mime_node_t *node;
\r
475 > - if (!parent || !parent->part || child < 0 || child >= parent->nchildren)
\r
476 > + if (! parent || ! parent->part || child < 0 || child >= parent->nchildren)
\r
479 > if (GMIME_IS_MULTIPART (parent->part)) {
\r
480 > @@ -412,10 +414,10 @@ _mime_node_seek_dfs_walk (mime_node_t *node, int *n)
\r
484 > - for (i = 0; i < node->nchildren && !ret; i++) {
\r
485 > + for (i = 0; i < node->nchildren && ! ret; i++) {
\r
486 > mime_node_t *child = mime_node_child (node, i);
\r
487 > ret = _mime_node_seek_dfs_walk (child, n);
\r
490 > talloc_free (child);
\r
496 > _______________________________________________
\r
497 > notmuch mailing list
\r
498 > notmuch@notmuchmail.org
\r
499 > http://notmuchmail.org/mailman/listinfo/notmuch
\r