Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / 9d / ec121ca1018eacd67543bd40a718a78feb380d
1 Return-Path: <dme@dme.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 C810D431FD0\r
6         for <notmuch@notmuchmail.org>; Wed, 21 Dec 2011 13:39:03 -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 Ig6AxIUy42SV for <notmuch@notmuchmail.org>;\r
16         Wed, 21 Dec 2011 13:39:03 -0800 (PST)\r
17 Received: from mail-wi0-f181.google.com (mail-wi0-f181.google.com\r
18         [209.85.212.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
19         (No client certificate requested)\r
20         by olra.theworths.org (Postfix) with ESMTPS id 225E9431FB6\r
21         for <notmuch@notmuchmail.org>; Wed, 21 Dec 2011 13:39:03 -0800 (PST)\r
22 Received: by wibhq2 with SMTP id hq2so2786562wib.26\r
23         for <notmuch@notmuchmail.org>; Wed, 21 Dec 2011 13:39:00 -0800 (PST)\r
24 Received: by 10.180.81.72 with SMTP id y8mr17622322wix.14.1324503540343;\r
25         Wed, 21 Dec 2011 13:39:00 -0800 (PST)\r
26 Received: from hotblack-desiato.hh.sledj.net\r
27         (host81-149-164-25.in-addr.btopenworld.com. [81.149.164.25])\r
28         by mx.google.com with ESMTPS id eg7sm16728841wib.8.2011.12.21.13.38.58\r
29         (version=TLSv1/SSLv3 cipher=OTHER);\r
30         Wed, 21 Dec 2011 13:38:59 -0800 (PST)\r
31 Received: by hotblack-desiato.hh.sledj.net (Postfix, from userid 30000)\r
32         id B5878A05A7; Wed, 21 Dec 2011 21:38:56 +0000 (GMT)\r
33 From: David Edmondson <dme@dme.org>\r
34 To: notmuch@notmuchmail.org\r
35 Subject: [RFC][PATCH] notmuch: Workaround to allow ignoring non-void function\r
36         return.\r
37 Date: Wed, 21 Dec 2011 21:38:52 +0000\r
38 Message-Id: <1324503532-5799-1-git-send-email-dme@dme.org>\r
39 X-Mailer: git-send-email 1.7.7.3\r
40 X-BeenThere: notmuch@notmuchmail.org\r
41 X-Mailman-Version: 2.1.13\r
42 Precedence: list\r
43 List-Id: "Use and development of the notmuch mail system."\r
44         <notmuch.notmuchmail.org>\r
45 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
46         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
47 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
48 List-Post: <mailto:notmuch@notmuchmail.org>\r
49 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
50 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
51         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
52 X-List-Received-Date: Wed, 21 Dec 2011 21:39:03 -0000\r
53 \r
54 ---\r
55 \r
56 The mechanism used here works for me in an isolated test case and no\r
57 warnings appear when using it as below, but I'm unsure why the\r
58 original warning that it is intended to address didn't appear when I\r
59 build. Any thoughts?\r
60 \r
61  compat/compat.h |    6 ++++++\r
62  notmuch-new.c   |    2 +-\r
63  notmuch-show.c  |    2 +-\r
64  notmuch-tag.c   |    2 +-\r
65  4 files changed, 9 insertions(+), 3 deletions(-)\r
66 \r
67 diff --git a/compat/compat.h b/compat/compat.h\r
68 index 7767fe8..1160301 100644\r
69 --- a/compat/compat.h\r
70 +++ b/compat/compat.h\r
71 @@ -30,6 +30,12 @@\r
72  extern "C" {\r
73  #endif\r
74  \r
75 +#ifdef __GNUC__\r
76 +#define ignore_result(x) ({ __typeof__(x) z = x; (void) sizeof (z); })\r
77 +#else /* !__GNUC__ */\r
78 +#define ignore_result(x) x\r
79 +#endif /* __GNUC__ */\r
80 +\r
81  #if !HAVE_GETLINE\r
82  #include <stdio.h>\r
83  #include <unistd.h>\r
84 diff --git a/notmuch-new.c b/notmuch-new.c\r
85 index 3512de7..0ac04cc 100644\r
86 --- a/notmuch-new.c\r
87 +++ b/notmuch-new.c\r
88 @@ -67,7 +67,7 @@ handle_sigint (unused (int sig))\r
89  {\r
90      static char msg[] = "Stopping...         \n";\r
91  \r
92 -    (void) write(2, msg, sizeof(msg)-1);\r
93 +    ignore_result(write(STDERR_FILENO, msg, sizeof(msg)-1));\r
94      interrupted = 1;\r
95  }\r
96  \r
97 diff --git a/notmuch-show.c b/notmuch-show.c\r
98 index 19fb49f..681f778 100644\r
99 --- a/notmuch-show.c\r
100 +++ b/notmuch-show.c\r
101 @@ -866,7 +866,7 @@ do_show_single (void *ctx,\r
102  \r
103         while (!feof (file)) {\r
104             size = fread (buf, 1, sizeof (buf), file);\r
105 -           (void) fwrite (buf, size, 1, stdout);\r
106 +           ignore_result(fwrite (buf, size, 1, stdout));\r
107         }\r
108  \r
109         fclose (file);\r
110 diff --git a/notmuch-tag.c b/notmuch-tag.c\r
111 index 292c5da..2cbfdc3 100644\r
112 --- a/notmuch-tag.c\r
113 +++ b/notmuch-tag.c\r
114 @@ -26,7 +26,7 @@ static void\r
115  handle_sigint (unused (int sig))\r
116  {\r
117      static char msg[] = "Stopping...         \n";\r
118 -    (void) write(2, msg, sizeof(msg)-1);\r
119 +    ignore_result(write(STDERR_FILENO, msg, sizeof(msg)-1));\r
120      interrupted = 1;\r
121  }\r
122  \r
123 -- \r
124 1.7.7.3\r
125 \r