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 B83D8431FD0 for ; Sun, 25 Dec 2011 15:40:45 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.799 X-Spam-Level: X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_FROM=0.001, 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 bglNPG7swhvX for ; Sun, 25 Dec 2011 15:40:45 -0800 (PST) Received: from mail-wi0-f181.google.com (mail-wi0-f181.google.com [209.85.212.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 149F0431FB6 for ; Sun, 25 Dec 2011 15:40:44 -0800 (PST) Received: by wibhq2 with SMTP id hq2so5051930wib.26 for ; Sun, 25 Dec 2011 15:40:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:cc:subject:in-reply-to:references:user-agent:date :message-id:mime-version:content-type; bh=Tk4hQXiMEPsanJ4hPAMsiZeFUtqIOUUnP0Uw0rWR2Y0=; b=bup5Vdx4r4lTFNIN60MIdV+MgcFDx6lD6S6Dcfxhma12G1U1M5txXKx/vCW5NCQp7E JiP1cqL+FlS928+AUnSDsGkDv2DBa78Z32KjNSIffH4o/huRH5+BdtTwKMAwumPQV1h/ +ys79sCn02JwtnAvY5a4GddfMWdHu24l28bNA= Received: by 10.180.19.106 with SMTP id d10mr49658931wie.2.1324856443766; Sun, 25 Dec 2011 15:40:43 -0800 (PST) Received: from localhost ([91.144.186.21]) by mx.google.com with ESMTPS id fy5sm52303194wib.7.2011.12.25.15.40.42 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 25 Dec 2011 15:40:42 -0800 (PST) From: Dmitry Kurochkin To: Austin Clements Subject: Re: [PATCH 3/4] Utility function to seek in MIME trees in depth-first order. In-Reply-To: <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> <20111224034603.GC1927@mit.edu> User-Agent: Notmuch/0.10.2+116~g4c449d4 (http://notmuchmail.org) Emacs/23.3.1 (x86_64-pc-linux-gnu) Date: Mon, 26 Dec 2011 03:39:57 +0400 Message-ID: <87pqfc1ar6.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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: Sun, 25 Dec 2011 23:40:45 -0000 On Fri, 23 Dec 2011 22:46:19 -0500, Austin Clements wrote: > 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 there is any code which already uses C99-style declarations, then we should use them in the new code IMO. Perhaps whether to use C99-style declarations or not should be a coding style requirement. Regards, Dmitry > > > + 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