Re: [PATCH 1/4] cli: fix use of uninitialized variable in "notmuch reply"
[notmuch-archives.git] / db / c5dfc4bab29ec8cd61566b071e03b7acda2f40
1 Return-Path: <jani@nikula.org>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5         by olra.theworths.org (Postfix) with ESMTP id 6E924429E33\r
6         for <notmuch@notmuchmail.org>; Fri,  6 Jan 2012 00:11:50 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -0.7\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
12         tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
13 Received: from olra.theworths.org ([127.0.0.1])\r
14         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
15         with ESMTP id o8vpZREy2G4g for <notmuch@notmuchmail.org>;\r
16         Fri,  6 Jan 2012 00:11:48 -0800 (PST)\r
17 Received: from mail-ee0-f53.google.com (mail-ee0-f53.google.com\r
18  [74.125.83.53])        (using TLSv1 with cipher RC4-SHA (128/128 bits))        (No client\r
19  certificate requested) by olra.theworths.org (Postfix) with ESMTPS id\r
20  58D2F429E32    for <notmuch@notmuchmail.org>; Fri,  6 Jan 2012 00:11:48 -0800\r
21  (PST)\r
22 Received: by eekd41 with SMTP id d41so1073505eek.26\r
23         for <notmuch@notmuchmail.org>; Fri, 06 Jan 2012 00:11:47 -0800 (PST)\r
24 Received: by 10.213.29.131 with SMTP id q3mr1078049ebc.65.1325837506753;\r
25         Fri, 06 Jan 2012 00:11:46 -0800 (PST)\r
26 Received: from localhost (dsl-hkibrasgw4-fe5cdc00-23.dhcp.inet.fi.\r
27         [80.220.92.23])\r
28         by mx.google.com with ESMTPS id s16sm244469455eef.2.2012.01.06.00.11.43\r
29         (version=SSLv3 cipher=OTHER); Fri, 06 Jan 2012 00:11:45 -0800 (PST)\r
30 From: Jani Nikula <jani@nikula.org>\r
31 To: David Bremner <david@tethera.net>, notmuch@notmuchmail.org\r
32 Subject: Re: [PATCH 1/4] cli: fix use of uninitialized variable in "notmuch\r
33         reply"\r
34 In-Reply-To: <87boqhy0p1.fsf@zancas.localnet>\r
35 References: <cover.1325794371.git.jani@nikula.org>\r
36         <974a2ef1f1df7d93e0b5bd642ca8a49f8b727a86.1325794371.git.jani@nikula.org>\r
37         <87boqhy0p1.fsf@zancas.localnet>\r
38 User-Agent: Notmuch/0.10.2+182~g93862a2 (http://notmuchmail.org) Emacs/23.3.1\r
39         (i686-pc-linux-gnu)\r
40 Date: Fri, 06 Jan 2012 10:11:42 +0200\r
41 Message-ID: <87ipkp8d35.fsf@nikula.org>\r
42 MIME-Version: 1.0\r
43 Content-Type: text/plain; charset=us-ascii\r
44 X-BeenThere: notmuch@notmuchmail.org\r
45 X-Mailman-Version: 2.1.13\r
46 Precedence: list\r
47 List-Id: "Use and development of the notmuch mail system."\r
48         <notmuch.notmuchmail.org>\r
49 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
50         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
51 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
52 List-Post: <mailto:notmuch@notmuchmail.org>\r
53 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
54 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
55         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
56 X-List-Received-Date: Fri, 06 Jan 2012 08:11:50 -0000\r
57 \r
58 On Thu, 05 Jan 2012 23:22:34 -0400, David Bremner <david@tethera.net> wrote:\r
59 > On Thu,  5 Jan 2012 22:25:12 +0200, Jani Nikula <jani@nikula.org> wrote:\r
60 > > -    notmuch_show_params_t params;\r
61 > > +    notmuch_show_params_t params = { .part = -1 };\r
62 > >  \r
63 > >      reply_format_func = notmuch_reply_format_default;\r
64 > > -    params.part = -1;\r
65\r
66 > Do I understand correctly that this is just a style change, or do you\r
67 > rely on some c99(?) behaviour of initializing the other elements to 0?\r
68 \r
69 It is not just a style change, and initializing a struct partially\r
70 initializes the rest of the elements to 0. That's not C99 specific\r
71 behaviour, though using the designated initializer to initialize .part\r
72 to -1 is.\r
73 \r
74 All of these result in the same value for params:\r
75 \r
76         notmuch_show_params_t params = { .part = -1 };\r
77 \r
78         notmuch_show_params_t params = { 0, 0, -1 };\r
79 \r
80         notmuch_show_params_t params = { 0, 0, -1, NULL, 0 };\r
81 \r
82         notmuch_show_params_t params = { 0 };\r
83         params.part = -1;\r
84 \r
85 IMHO the first is cleanest and unaffected by changes in\r
86 notmuch_show_params_t, though might be surprising if you're not (yet)\r
87 used to C99 designated initializers.\r
88 \r
89 In any case, in the current implementation only .part and .cryptoctx are\r
90 initialized, and the rest of the fields are random. This needs to be\r
91 fixed one way or another.\r
92 \r
93 \r
94 BR,\r
95 Jani.\r