unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH] Fix compilation warnings in test/smtp-dummy.c.
@ 2011-06-16 10:32 Dmitry Kurochkin
  2011-06-21 21:59 ` Carl Worth
  0 siblings, 1 reply; 2+ messages in thread
From: Dmitry Kurochkin @ 2011-06-16 10:32 UTC (permalink / raw)
  To: notmuch

* Remove unused variables in main(): buf, bytes and greeting.
* Replace return with no value in main() with exit(3).
---
 test/smtp-dummy.c |    5 +----
 1 files changed, 1 insertions(+), 4 deletions(-)

diff --git a/test/smtp-dummy.c b/test/smtp-dummy.c
index e58d0ad..133d6c4 100644
--- a/test/smtp-dummy.c
+++ b/test/smtp-dummy.c
@@ -99,9 +99,6 @@ process_command (FILE *peer, FILE *output, const char *command)
 static void
 do_smtp_to_file (FILE *peer, FILE *output)
 {
-	char buf[4096];
-	ssize_t bytes;
-	char greeting[] = "220 localhost smtp-dummy\r\n";
 	char *line = NULL;
 	size_t line_size;
 	ssize_t line_len;
@@ -193,7 +190,7 @@ main (int argc, char *argv[])
 	if (peer_file == NULL) {
 		fprintf (stderr, "Error: fdopen() failed: %s\n",
 			 strerror (errno));
-		return;
+		exit (1);
 	}
 
 	do_smtp_to_file (peer_file, output);
-- 
1.7.5.4

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] Fix compilation warnings in test/smtp-dummy.c.
  2011-06-16 10:32 [PATCH] Fix compilation warnings in test/smtp-dummy.c Dmitry Kurochkin
@ 2011-06-21 21:59 ` Carl Worth
  0 siblings, 0 replies; 2+ messages in thread
From: Carl Worth @ 2011-06-21 21:59 UTC (permalink / raw)
  To: Dmitry Kurochkin, notmuch

[-- Attachment #1: Type: text/plain, Size: 1263 bytes --]

On Thu, 16 Jun 2011 14:32:08 +0400, Dmitry Kurochkin <dmitry.kurochkin@gmail.com> wrote:
> * Remove unused variables in main(): buf, bytes and greeting.
> * Replace return with no value in main() with exit(3).

Thanks. I'd notice these occasionally when running the test suite and
had meant for some time to fix them. But when doing my typical
compilation within emacs, (with just "make"), I wouldn't get these
warnings so I wasn't cleaning these in my typical work to make the
compilation error/warning-free.

I did follow up with a commit to prefer return (with a value) over
exit(), which I applied throughout the main() function:

commit b1aa676cca01ce0d907d220dc3c3a5142991c1cf
Author: Carl Worth <cworth@cworth.org>
Date:   Tue Jun 21 14:54:10 2011 -0700

    smtp-dummy: Prefer return rather than exit() in main.
    
    The main() function should be written as just another function with a
    return value. This allows for more reliable code reuse. Imagine that
    main() grows too large and needs to be factored into multiple
    functions. At that point, exit() is probably the wrong thing, yet can
    also be hard to notice as it's in less-frequently-tested exceptional
    cases.


-Carl

-- 
carl.d.worth@intel.com

[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-06-21 21:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-16 10:32 [PATCH] Fix compilation warnings in test/smtp-dummy.c Dmitry Kurochkin
2011-06-21 21:59 ` Carl Worth

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).