Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 525C6429E25 for ; Fri, 23 Dec 2011 19:45:21 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.7 X-Spam-Level: X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id cCAf0-dApj5y for ; Fri, 23 Dec 2011 19:45:20 -0800 (PST) Received: from dmz-mailsec-scanner-1.mit.edu (DMZ-MAILSEC-SCANNER-1.MIT.EDU [18.9.25.12]) by olra.theworths.org (Postfix) with ESMTP id C3D11431FB6 for ; Fri, 23 Dec 2011 19:45:20 -0800 (PST) X-AuditID: 1209190c-b7fad6d000000920-f1-4ef54ad02546 Received: from mailhub-auth-2.mit.edu ( [18.7.62.36]) by dmz-mailsec-scanner-1.mit.edu (Symantec Messaging Gateway) with SMTP id 8D.2C.02336.0DA45FE4; Fri, 23 Dec 2011 22:45:20 -0500 (EST) Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103]) by mailhub-auth-2.mit.edu (8.13.8/8.9.2) with ESMTP id pBO3jJKg008667; Fri, 23 Dec 2011 22:45:20 -0500 Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91]) (authenticated bits=0) (User authenticated as amdragon@ATHENA.MIT.EDU) by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id pBO3jIEB017741 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); Fri, 23 Dec 2011 22:45:19 -0500 (EST) Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.77) (envelope-from ) id 1ReIYt-0002FY-EW; Fri, 23 Dec 2011 22:46:19 -0500 Date: Fri, 23 Dec 2011 22:46:19 -0500 From: Austin Clements To: Dmitry Kurochkin Subject: Re: [PATCH 3/4] Utility function to seek in MIME trees in depth-first order. Message-ID: <20111224034603.GC1927@mit.edu> References: <1323027100-10307-1-git-send-email-amdragon@mit.edu> <1323460468-4030-1-git-send-email-amdragon@mit.edu> <1323460468-4030-4-git-send-email-amdragon@mit.edu> <87hb187iu6.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87hb187iu6.fsf@gmail.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupjleLIzCtJLcpLzFFi42IRYrdT0b3g9dXP4P53AYurW/vZLa7fnMns wOSxc9Zddo9nq24xBzBFcdmkpOZklqUW6dslcGXMuu1csFC44v6dnUwNjBf4uhg5OCQETCQa j5V0MXICmWISF+6tZ+ti5OIQEtjHKNH/r50dJCEksIFR4s8xHojESSaJ6VfeMUI4SxglOh/1 MYFUsQioSvRf/8QGYrMJaEhs27+cEcQWETCUuHXxFTOIzSwgLfHtdzNYvbBAuMSE9XPANvAK aEtMeH0HauhJRon5q+4yQyQEJU7OfMIC0awlcePfSyaQs0EGLf/HARLmFFCXOLJpNtgcUQEV iSknt7FNYBSahaR7FpLuWQjdCxiZVzHKpuRW6eYmZuYUpybrFicn5uWlFuka6uVmluilppRu YgQFNackzw7GNweVDjEKcDAq8fA2Lv3iJ8SaWFZcmXuIUZKDSUmU96rbVz8hvqT8lMqMxOKM +KLSnNTiQ4wSHMxKIryaSUDlvCmJlVWpRfkwKWkOFiVxXhWtd35CAumJJanZqakFqUUwWRkO DiUJ3ieeQEMFi1LTUyvSMnNKENJMHJwgw3mAhnMDk4AQb3FBYm5xZjpE/hSjLsfiVRvOMgqx 5OXnpUqJ874DGSQAUpRRmgc3B5aMXjGKA70lzNsDMooHmMjgJr0CWsIEtCTGCOSD4pJEhJRU A2NF3Z5NOW8tz2+XWsOmFcl8Kbjz17nSA9wrZPe4HX3DvCxuZcGKN2l25Ta39r++P81hwspS B/nkHykdunUP4y46bDdLWcDxyGbmTQ7B5lNlh403nAtZ+8hf/zvLV/Ec83hlCaG5e+8+eRxp U53R0nUqun/24j1BK1qiEvZf70u9wfp280qn7fxKLMUZiYZazEXFiQD2x+kxIQMAAA== Cc: notmuch@notmuchmail.org X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 24 Dec 2011 03:45:21 -0000 Quoth Dmitry Kurochkin on Dec 10 at 3:43 pm: > On Fri, 9 Dec 2011 14:54:27 -0500, Austin Clements wrote: > > This function matches how we number parts for the --part argument to > > show. It will allow us to jump directly to the desired part, rather > > than traversing the entire tree and carefully tracking whether or not > > we're "in the zone". > > --- > > mime-node.c | 25 +++++++++++++++++++++++++ > > notmuch-client.h | 5 +++++ > > 2 files changed, 30 insertions(+), 0 deletions(-) > > > > diff --git a/mime-node.c b/mime-node.c > > index a8e4a59..207818e 100644 > > --- a/mime-node.c > > +++ b/mime-node.c > > @@ -232,3 +232,28 @@ mime_node_child (const mime_node_t *parent, int child) > > g_type_name (G_OBJECT_TYPE (parent->part))); > > } > > } > > + > > +static mime_node_t * > > +_mime_node_seek_dfs_walk (mime_node_t *node, int *n) > > +{ > > + mime_node_t *ret = NULL; > > + int i; > > + > > Can we move declarations below the if (which does not need them)? I > always have troubles remembering if (recent enough) C standard allows > that or it is a GCC extension. FWIW in the previous patch there are > declarations in the middle of a block, e.g.: > > } else { > out->is_signed = TRUE; > ... > GMimeSignatureValidity *sig_validity = g_mime_multipart_signed_verify > (GMIME_MULTIPART_SIGNED (part), out->ctx->cryptoctx, &err); > > So either we can move these declarations to where they are needed, or we > should fix it in _mime_node_create(). Since prevailing notmuch style seems to be top-declarations, I fixed up _mime_node_create instead (personally I prefer C99-style declarations, but *shrug*). > > + if (*n <= 0) > > Comment for mime_node_seek_dfs() says that the function returns the node > itself for n = 0, but does not say anything about n < 0. I would expect > the function to return NULL for n < 0. In any case, the comment below > should probably mention what happens for n < 0; Good point. I made it return NULL for n < 0. I think this logically falls under "Returns NULL if there is no such part." > > + return node; > > + > > + *n = *n - 1; > > Perhaps *n -= 1? Or even --(*n)? Changed to *n -= 1. > > + for (i = 0; i < node->children && !ret; i++) { > > Consider s/i++/++i/. notmuch uses i++ remarkably consistently, so I left this. > Regards, > Dmitry