From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 6E924429E33 for ; Fri, 6 Jan 2012 00:11:50 -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 o8vpZREy2G4g for ; Fri, 6 Jan 2012 00:11:48 -0800 (PST) Received: from mail-ee0-f53.google.com (mail-ee0-f53.google.com [74.125.83.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 58D2F429E32 for ; Fri, 6 Jan 2012 00:11:48 -0800 (PST) Received: by eekd41 with SMTP id d41so1073505eek.26 for ; Fri, 06 Jan 2012 00:11:47 -0800 (PST) Received: by 10.213.29.131 with SMTP id q3mr1078049ebc.65.1325837506753; Fri, 06 Jan 2012 00:11:46 -0800 (PST) Received: from localhost (dsl-hkibrasgw4-fe5cdc00-23.dhcp.inet.fi. [80.220.92.23]) by mx.google.com with ESMTPS id s16sm244469455eef.2.2012.01.06.00.11.43 (version=SSLv3 cipher=OTHER); Fri, 06 Jan 2012 00:11:45 -0800 (PST) From: Jani Nikula To: David Bremner , notmuch@notmuchmail.org Subject: Re: [PATCH 1/4] cli: fix use of uninitialized variable in "notmuch reply" In-Reply-To: <87boqhy0p1.fsf@zancas.localnet> References: <974a2ef1f1df7d93e0b5bd642ca8a49f8b727a86.1325794371.git.jani@nikula.org> <87boqhy0p1.fsf@zancas.localnet> User-Agent: Notmuch/0.10.2+182~g93862a2 (http://notmuchmail.org) Emacs/23.3.1 (i686-pc-linux-gnu) Date: Fri, 06 Jan 2012 10:11:42 +0200 Message-ID: <87ipkp8d35.fsf@nikula.org> 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, 06 Jan 2012 08:11:50 -0000 On Thu, 05 Jan 2012 23:22:34 -0400, David Bremner wrote: > On Thu, 5 Jan 2012 22:25:12 +0200, Jani Nikula wrote: > > - notmuch_show_params_t params; > > + notmuch_show_params_t params = { .part = -1 }; > > > > reply_format_func = notmuch_reply_format_default; > > - params.part = -1; > > Do I understand correctly that this is just a style change, or do you > rely on some c99(?) behaviour of initializing the other elements to 0? It is not just a style change, and initializing a struct partially initializes the rest of the elements to 0. That's not C99 specific behaviour, though using the designated initializer to initialize .part to -1 is. All of these result in the same value for params: notmuch_show_params_t params = { .part = -1 }; notmuch_show_params_t params = { 0, 0, -1 }; notmuch_show_params_t params = { 0, 0, -1, NULL, 0 }; notmuch_show_params_t params = { 0 }; params.part = -1; IMHO the first is cleanest and unaffected by changes in notmuch_show_params_t, though might be surprising if you're not (yet) used to C99 designated initializers. In any case, in the current implementation only .part and .cryptoctx are initialized, and the rest of the fields are random. This needs to be fixed one way or another. BR, Jani.