From patchwork Mon Jan 28 21:33:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anders Waldenborg X-Patchwork-Id: 10784937 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4A89E91E for ; Mon, 28 Jan 2019 21:51:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3A8822B516 for ; Mon, 28 Jan 2019 21:51:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2F2062BF4D; Mon, 28 Jan 2019 21:51:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D9FD22B516 for ; Mon, 28 Jan 2019 21:51:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727947AbfA1VvZ (ORCPT ); Mon, 28 Jan 2019 16:51:25 -0500 Received: from 0x63.nu ([109.74.10.199]:44910 "EHLO 0x63.nu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726802AbfA1VvZ (ORCPT ); Mon, 28 Jan 2019 16:51:25 -0500 Received: from ip6-localhost ([::1] helo=moveme2.lan) by 0x63.nu with esmtp (Exim 4.89) (envelope-from ) id 1goEXW-0002Au-T2; Mon, 28 Jan 2019 22:33:58 +0100 From: Anders Waldenborg To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Anders Waldenborg Subject: [PATCH v5 3/7] pretty: single return path in %(trailers) handling Date: Mon, 28 Jan 2019 22:33:33 +0100 Message-Id: <20190128213337.24752-4-anders@0x63.nu> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190128213337.24752-1-anders@0x63.nu> References: <20181028125025.30952-1-anders@0x63.nu> <20190128213337.24752-1-anders@0x63.nu> X-SA-Exim-Connect-IP: ::1 X-SA-Exim-Mail-From: anders@0x63.nu X-SA-Exim-Scanned: No (on 0x63.nu); SAEximRunCond expanded to false Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP No functional change intended. This change may not seem useful on its own, but upcoming commits will do memory allocation in there, and a single return path makes deallocation easier. Signed-off-by: Anders Waldenborg --- pretty.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pretty.c b/pretty.c index b8d71a57c9..65a1b9bd82 100644 --- a/pretty.c +++ b/pretty.c @@ -1353,6 +1353,7 @@ static size_t format_commit_one(struct strbuf *sb, /* in UTF-8 */ if (skip_prefix(placeholder, "(trailers", &arg)) { struct process_trailer_options opts = PROCESS_TRAILER_OPTIONS_INIT; + size_t ret = 0; opts.no_divider = 1; @@ -1366,8 +1367,9 @@ static size_t format_commit_one(struct strbuf *sb, /* in UTF-8 */ } if (*arg == ')') { format_trailers_from_commit(sb, msg + c->subject_off, &opts); - return arg - placeholder + 1; + ret = arg - placeholder + 1; } + return ret; } return 0; /* unknown placeholder */