* [PATCH] fix compiler warnings
@ 2009-11-22 15:11 Dirk-Jan C. Binnema
2009-11-23 3:22 ` Carl Worth
0 siblings, 1 reply; 3+ messages in thread
From: Dirk-Jan C. Binnema @ 2009-11-22 15:11 UTC (permalink / raw)
To: notmuch@notmuchmail org
(hopefully this is the correct way to send patches...)
With these minor changes, notmuch compiles warning-free with gcc 4.4.1
---
notmuch-new.c | 4 +++-
notmuch-setup.c | 13 +++++++------
notmuch-tag.c | 4 +++-
3 files changed, 13 insertions(+), 8 deletions(-)
diff --git a/notmuch-new.c b/notmuch-new.c
index 0dd2784..88b48a6 100644
--- a/notmuch-new.c
+++ b/notmuch-new.c
@@ -36,7 +36,9 @@ static void
handle_sigint (unused (int sig))
{
static char msg[] = "Stopping... \n";
- write(2, msg, sizeof(msg)-1);
+ if (write(2, msg, sizeof(msg)-1) < 0) {
+ /* ignore...*/
+ }
interrupted = 1;
}
diff --git a/notmuch-setup.c b/notmuch-setup.c
index 482efd2..0d3f186 100644
--- a/notmuch-setup.c
+++ b/notmuch-setup.c
@@ -99,12 +99,13 @@ notmuch_setup_command (unused (void *ctx),
unsigned int i;
int is_new;
-#define prompt(format, ...) \
- do { \
- printf (format, ##__VA_ARGS__); \
- fflush (stdout); \
- getline (&response, &response_size, stdin); \
- chomp_newline (response); \
+#define prompt(format, ...) \
+ do { \
+ printf (format, ##__VA_ARGS__); \
+ fflush (stdout); \
+ if (getline (&response, &response_size, stdin) < 0) \
+ break; \
+ chomp_newline (response); \
} while (0)
config = notmuch_config_open (ctx, NULL, &is_new);
diff --git a/notmuch-tag.c b/notmuch-tag.c
index e2311f6..5e40f50 100644
--- a/notmuch-tag.c
+++ b/notmuch-tag.c
@@ -26,7 +26,9 @@ static void
handle_sigint (unused (int sig))
{
static char msg[] = "Stopping... \n";
- write(2, msg, sizeof(msg)-1);
+ if (write(2, msg, sizeof(msg)-1) < 0) {
+ /* ignore... */
+ }
interrupted = 1;
}
--
1.6.3.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] fix compiler warnings
2009-11-22 15:11 [PATCH] fix compiler warnings Dirk-Jan C. Binnema
@ 2009-11-23 3:22 ` Carl Worth
2009-11-23 4:43 ` Jeffrey Ollie
0 siblings, 1 reply; 3+ messages in thread
From: Carl Worth @ 2009-11-23 3:22 UTC (permalink / raw)
To: djcb, notmuch@notmuchmail org
On Sun, 22 Nov 2009 17:11:03 +0200, Dirk-Jan C. Binnema <djcb.bulk@gmail.com> wrote:
>
> (hopefully this is the correct way to send patches...)
Looks just fine, and welcome to notmuch!
> With these minor changes, notmuch compiles warning-free with gcc 4.4.1
Could you resend these as separate patches, each patch fixing a single
type of warning? That would make it more clear what the code is doing.
> - write(2, msg, sizeof(msg)-1);
> + if (write(2, msg, sizeof(msg)-1) < 0) {
> + /* ignore...*/
> + }
I don't like the gratuitous conditional here. It clutters the code and
make is less clear. If we're just trying to squelch a warning about an
unused return value from a function, then I think I'd rather see:
ssize_t ignored;
ignored = write (2, msg, sizeof (msg) - 1);
What do you think?
-Carl
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] fix compiler warnings
2009-11-23 3:22 ` Carl Worth
@ 2009-11-23 4:43 ` Jeffrey Ollie
0 siblings, 0 replies; 3+ messages in thread
From: Jeffrey Ollie @ 2009-11-23 4:43 UTC (permalink / raw)
To: Carl Worth; +Cc: notmuch@notmuchmail org, djcb
On Sun, Nov 22, 2009 at 9:22 PM, Carl Worth <cworth@cworth.org> wrote:
> On Sun, 22 Nov 2009 17:11:03 +0200, Dirk-Jan C. Binnema <djcb.bulk@gmail.com> wrote:
>>
>> - write(2, msg, sizeof(msg)-1);
>> + if (write(2, msg, sizeof(msg)-1) < 0) {
>> + /* ignore...*/
>> + }
>
> I don't like the gratuitous conditional here. It clutters the code and
> make is less clear. If we're just trying to squelch a warning about an
> unused return value from a function, then I think I'd rather see:
>
> ssize_t ignored;
>
> ignored = write (2, msg, sizeof (msg) - 1);
Isn't the usual method for ignoring return values casting to void?
(void) write (2, msg, sizeof (msg) - 1);
--
Jeff Ollie
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-11-23 4:43 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-22 15:11 [PATCH] fix compiler warnings Dirk-Jan C. Binnema
2009-11-23 3:22 ` Carl Worth
2009-11-23 4:43 ` Jeffrey Ollie
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).