Module: ngircd.git
Branch: master
Commit: 025342fe46ae504a08be8c642901ec7eb7c4fccb
URL: http://ngircd.barton.de/cgi-bin/gitweb.cgi?p=ngircd.git&a=commit;h=025342fe…
Author: Alexander Barton <alex(a)barton.de>
Date: Fri Apr 9 20:08:47 2010 +0200
Fix gcc warning "ignoring return value of ..."
This patch fixes two warnings of gcc 4.4.3 when used with eglibc 2.11.1:
ngircd.c: In function ‘NGIRCd_Init’:
ngircd.c:801: warning: ignoring return value of ‘chdir’, declared with
attribute warn_unused_result
conn.c: In function ‘Simple_Message’:
conn.c:2041: warning: ignoring return value of ‘write’, declared with
attribute warn_unused_result
The first by checking the return code and an appropriate error message,
the second by "better" ignoring it (which is correct there!) ...
---
src/ngircd/conn.c | 32 ++++++++++++++++++++++----------
src/ngircd/ngircd.c | 4 +++-
2 files changed, 25 insertions(+), 11 deletions(-)
diff --git a/src/ngircd/conn.c b/src/ngircd/conn.c
index cd350a8..ab975b3 100644
--- a/src/ngircd/conn.c
+++ b/src/ngircd/conn.c
@@ -2025,20 +2025,32 @@ cb_Read_Resolver_Result( int r_fd, UNUSED short events )
} /* cb_Read_Resolver_Result */
+/**
+ * Write a "simple" (error) message to a socket.
+ * The message is sent without using the connection write buffers, without
+ * compression/encryption, and even without any error reporting. It is
+ * designed for error messages of e.g. New_Connection(). */
static void
-Simple_Message( int Sock, const char *Msg )
+Simple_Message(int Sock, const char *Msg)
{
char buf[COMMAND_LEN];
size_t len;
- /* Write "simple" message to socket, without using compression
- * or even the connection write buffers. Used e.g. for error
- * messages by New_Connection(). */
- assert( Sock > NONE );
- assert( Msg != NULL );
-
- strlcpy( buf, Msg, sizeof buf - 2);
- len = strlcat( buf, "\r\n", sizeof buf);
- (void)write(Sock, buf, len);
+
+ assert(Sock > NONE);
+ assert(Msg != NULL);
+
+ strlcpy(buf, Msg, sizeof buf - 2);
+ len = strlcat(buf, "\r\n", sizeof buf);
+ if (write(Sock, buf, len) < 0) {
+ /* Because this function most probably got called to log
+ * an error message, any write error is ignored here to
+ * avoid an endless loop. But casting the result of write()
+ * to "void" doesn't satisfy the GNU C code attribute
+ * "warn_unused_result" which is used by some versions of
+ * glibc (e.g. 2.11.1), therefore this silly error
+ * "handling" code here :-( */
+ return;
+ }
} /* Simple_Error */
diff --git a/src/ngircd/ngircd.c b/src/ngircd/ngircd.c
index 82ba67c..b951bad 100644
--- a/src/ngircd/ngircd.c
+++ b/src/ngircd/ngircd.c
@@ -798,7 +798,9 @@ NGIRCd_Init( bool NGIRCd_NoDaemon )
#else
setpgrp(0, getpid());
#endif
- chdir( "/" );
+ if (chdir( "/" ) != 0)
+ Log(LOG_ERR, "Can't change directory to '/': %s",
+ strerror(errno));
/* Detach stdin, stdout and stderr */
Setup_FDStreams( );
Module: ngircd.git
Branch: master
Commit: 1ed49de83a335713ee437171335c93725dd19ee6
URL: http://ngircd.barton.de/cgi-bin/gitweb.cgi?p=ngircd.git&a=commit;h=1ed49de8…
Author: Alexander Barton <alex(a)barton.de>
Date: Fri Apr 2 14:22:07 2010 +0200
Updated some more copyright notices, it's 2010 already (part 2)
Silly me forgot the most important place, the program output itself ...
---
src/ngircd/ngircd.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/ngircd/ngircd.c b/src/ngircd/ngircd.c
index 5fc88c9..82ba67c 100644
--- a/src/ngircd/ngircd.c
+++ b/src/ngircd/ngircd.c
@@ -1,6 +1,6 @@
/*
* ngIRCd -- The Next Generation IRC Daemon
- * Copyright (c)2001-2009 Alexander Barton (alex(a)barton.de).
+ * Copyright (c)2001-2010 Alexander Barton (alex(a)barton.de).
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -562,7 +562,7 @@ static void
Show_Version( void )
{
puts( NGIRCd_Version );
- puts( "Copyright (c)2001-2009 Alexander Barton (<alex(a)barton.de>) and Contributors." );
+ puts( "Copyright (c)2001-2010 Alexander Barton (<alex(a)barton.de>) and Contributors." );
puts( "Homepage: <http://ngircd.barton.de/>\n" );
puts( "This is free software; see the source for copying conditions. There is NO" );
puts( "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." );