From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id 9E3866DE110A for ; Fri, 6 Jan 2017 12:15:11 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References" X-Spam-Flag: NO X-Spam-Score: -0.192 X-Spam-Level: X-Spam-Status: No, score=-0.192 tagged_above=-999 required=5 tests=[AWL=-0.172, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01] autolearn=disabled Received: from arlo.cworth.org ([127.0.0.1]) by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id P-1h_8SLhZsc for ; Fri, 6 Jan 2017 12:15:11 -0800 (PST) Received: from mail-lf0-f65.google.com (mail-lf0-f65.google.com [209.85.215.65]) by arlo.cworth.org (Postfix) with ESMTPS id 0A0BE6DE0C81 for ; Fri, 6 Jan 2017 12:15:05 -0800 (PST) Received: by mail-lf0-f65.google.com with SMTP id k62so4103607lfg.0 for ; Fri, 06 Jan 2017 12:15:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nikula-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=xgK0SriPmKjvMhAk/qPnH1b9l/jeDb1Xe9bjzu9Gl/U=; b=02SB9wwLX23jbwHIL8cvOJm17Aqlc9gWIgfbbUZI17gc6i63WEa7gSfAq2r6YRKIny 3YNfB/6IGxNVepY34GVu0kv4KFIYFIiLtGcoKN1UFE+TPo3UKstnCOKDpDl7nanx+/UC MNOM7Sjtwe56bmEoCD9S1AS8wmYDvT2Vp1MNk5YEjtX9pgB0d+yF2in6LCQmtgiwaZuo o1rUpNzUCrPe+RCFXnEp6eO5MV6vV7rtvgWjfpdCz2afeXYJDDFI8m77DF4Ba8QkoUW3 pDMxBSpclQR5kj2RHk1otKMEhjjW4wgxW1tWCt4oEKYTRyBfkvDR8vVON6LMxiuO+lEv 3S6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=xgK0SriPmKjvMhAk/qPnH1b9l/jeDb1Xe9bjzu9Gl/U=; b=Mai5ATjzRzp66bTj4E2SSWV8WoG+Wvqzu71qrFf4qrCo8QghW1ceoR+DdymmZH88gQ +9WVLogAe+yf5hvxZg8eS5pMKQXPz4IorCseByfR73W/441H/XsknKJwxSBafDPjRGUe Jgyi4cu1Q3LgAp0BVQp69Lo+IECwbs9essDn5LrPN5/3pIR+w+/6/9iD6OFNd1dxpMBH kY+cRNZOkBvnl/S2GRZufEcXpt83G4HKWKzqXr4kJEj96uQjZ8QWswFejlmKcthBSsXd uKgTQUviotIgh3fqpiP4owmGnZ/EerflLmG8oyix+aApH6fW0qUaetS5Dq95BOXv+0py sQ+g== X-Gm-Message-State: AIkVDXLZGQ9PoaxXZMPiXuVv+9dlxDeb7+H/F6yqMXf7yDlWY/VXvNCch/YYdMPlvs9qpQ== X-Received: by 10.25.38.1 with SMTP id m1mr29421773lfm.102.1483733703076; Fri, 06 Jan 2017 12:15:03 -0800 (PST) Received: from localhost (mobile-access-bceec7-199.dhcp.inet.fi. [188.238.199.199]) by smtp.gmail.com with ESMTPSA id i129sm18899084lfd.8.2017.01.06.12.15.02 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 06 Jan 2017 12:15:02 -0800 (PST) From: Jani Nikula To: notmuch@notmuchmail.org Subject: [PATCH 8/9] cli: simplify mime node walk Date: Fri, 6 Jan 2017 22:14:49 +0200 Message-Id: <067056a53ebd1343f502ae1df876d92d9b7ba20b.1483733461.git.jani@nikula.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: References: In-Reply-To: References: X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.22 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, 06 Jan 2017 20:15:11 -0000 The function is more straighforward to read when it's clear that the only non-NULL return is at one place. No functional changes. --- mime-node.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/mime-node.c b/mime-node.c index c9b82330f6e0..f719422ec678 100644 --- a/mime-node.c +++ b/mime-node.c @@ -322,20 +322,21 @@ mime_node_child (mime_node_t *parent, int child) static mime_node_t * _mime_node_seek_dfs_walk (mime_node_t *node, int *n) { - mime_node_t *ret = NULL; int i; if (*n == 0) return node; *n -= 1; - for (i = 0; i < node->nchildren && !ret; i++) { + for (i = 0; i < node->nchildren; i++) { mime_node_t *child = mime_node_child (node, i); - ret = _mime_node_seek_dfs_walk (child, n); - if (!ret) - talloc_free (child); + mime_node_t *ret = _mime_node_seek_dfs_walk (child, n); + if (ret) + return ret; + + talloc_free (child); } - return ret; + return NULL; } mime_node_t * -- 2.11.0