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 91132431FD0 for ; Fri, 9 Dec 2011 15:26:25 -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 hVy241oU8Gvo for ; Fri, 9 Dec 2011 15:26:25 -0800 (PST) Received: from mail-bw0-f53.google.com (mail-bw0-f53.google.com [209.85.214.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id D6729431FB6 for ; Fri, 9 Dec 2011 15:26:24 -0800 (PST) Received: by bkat8 with SMTP id t8so3776676bka.26 for ; Fri, 09 Dec 2011 15:26:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:subject:in-reply-to:references:user-agent:date:message-id :mime-version:content-type; bh=BxWEN0oXZ6V5zUqAPIVs+OerFqE+qFzKlXKnFD4xi/c=; b=uKRZAdY3aI322pXRyRGOCoS1cBl0rcC84OY3pYuIQ13/rkNaJz1mcI+R+/dj10ScMO xnQchAg6VYksV1OVVEy+vX+gXmw0DkLZdkS2XJSmPq1Nw4u6u8AlityJBNHPVmeSK9jy mJaYVBGMUCCwqaVj95TyyIc7hl/z66eyVQgOw= Received: by 10.204.14.208 with SMTP id h16mr4908359bka.2.1323473181738; Fri, 09 Dec 2011 15:26:21 -0800 (PST) Received: from localhost ([91.144.186.21]) by mx.google.com with ESMTPS id cc2sm13272545bkb.8.2011.12.09.15.26.20 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 09 Dec 2011 15:26:20 -0800 (PST) From: Dmitry Kurochkin To: Austin Clements , notmuch@notmuchmail.org Subject: Re: [PATCH 2/4] Introduce a generic tree-like abstraction for MIME traversal. In-Reply-To: <1323460468-4030-3-git-send-email-amdragon@mit.edu> References: <1323027100-10307-1-git-send-email-amdragon@mit.edu> <1323460468-4030-1-git-send-email-amdragon@mit.edu> <1323460468-4030-3-git-send-email-amdragon@mit.edu> User-Agent: Notmuch/0.10.2+82~g96a629c (http://notmuchmail.org) Emacs/23.3.1 (x86_64-pc-linux-gnu) Date: Sat, 10 Dec 2011 03:25:48 +0400 Message-ID: <87k46572f7.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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: Fri, 09 Dec 2011 23:26:26 -0000 Hi Austin. + /* The number of children of this part. */ + int children; Consider renaming to children_count or similar to make it clear that it is a counter and not the actual children. + notmuch_bool_t decrypt_success; Perhaps s/decrypt_success/is_decrypted/ for consistency with is_encrypted? +mime_node_child (const mime_node_t *parent, int child); + #include "command-line-arguments.h" #endif #include should go above declarations. + mime_node_t *out = talloc_zero (parent, mime_node_t); Perhaps s/out/node/? + /* this violates RFC 3156 section 4, so we won't bother with it. */ + fprintf (stderr, "Error: %d part(s) for a multipart/encrypted " + "message (should be exactly 2)\n", + out->children); Perhaps s/should be exactly/must be exactly/? That is what the RFC says. Same for signature. + out->is_encrypted = TRUE; + out->is_signed = TRUE; These are set only if we do decryption/verification. But their names and comments imply that they should reflect properties of the part and be set independently from whether we are actually doing decryption or verification. + /* For some reason the GMimeSignatureValidity returned + * here is not a const (inconsistent with that + * returned by + * g_mime_multipart_encrypted_get_signature_validity, + * and therefore needs to be properly disposed of. + * Hopefully the API will become more consistent. */ Ouch. In gmime 2.6 this API has changed, but looks like the issue is still there. Is there a bug for it? If yes, we should add a reference to the comment. Otherwise, we should file the bug and then add a reference to the comment :) Both decryption and verification use cryptoctx. But decryption is done iff decrypt is true (without checking if cryptoctx is set) and verification is done iff cryptoctx is set (without any special flag). Why is it asymmetric? Do we need to check if cryptoctx is set for decryption? In mime_node_child(): + GMimeMultipart *multipart = GMIME_MULTIPART (parent->part); + if (child == 1 && parent->decrypted_child) + return _mime_node_create (parent, parent->decrypted_child); Multipart is not needed here, please move it's declaration below the condition. + GMimeObject *child = g_mime_message_get_mime_part (message); The child variable eclipses the (int child) parameter. Consider using a different name for the variable (or parameter). + return _mime_node_create (parent, parent->decrypted_child); + return _mime_node_create (parent, g_mime_multipart_get_part (multipart, child)); ... + return _mime_node_create (parent, child); All returns are similar. Consider declaring a local variable for storing the part and using a single return, i.e.: GMimeObject *part; if (...) part = ...; else ... part = ...; return _mime_node_create (parent, part); Regards, Dmitry