repo: ngircd
action: commit
revision: 
path_from: 
revision_from: d26a283ea9ae86c5c4633a46aaec69b02def7c66:
path_to: 
revision_to: 
git.thebackupbox.net
ngircd
git clone git://git.thebackupbox.net/ngircd
commit d26a283ea9ae86c5c4633a46aaec69b02def7c66
Author: Florian Westphal 
Date:   Wed Dec 17 23:27:25 2008 +0100

    use %ld as format specifier for posix data types

    in the same vein as the earlier commit:
    cast posix data types (pid_t, ...) to long and use
    %ld as format specifier. This will avoid problems
    when sizeof(int) != sizeof(type).

    We could also cast to int, but this might truncate the value.

diff --git a/src/ngircd/log.c b/src/ngircd/log.c
index d450bd0a2ee543e58bd448c10c87f15e04b4beee..
index ..5559a2c6ada62e176d1e39ac0f3fda7d6dc4cb09 100644
--- a/src/ngircd/log.c
+++ b/src/ngircd/log.c
@@ -14,8 +14,6 @@

 #include "portab.h"

-static char UNUSED id[] = "$Id: log.c,v 1.62 2006/08/05 09:16:21 fw Exp $";
-
 #include "imp.h"
 #include 
 #include 
@@ -54,6 +52,22 @@ static char Error_File[FNAME_LEN];

 static void Wall_ServerNotice PARAMS(( char *Msg ));

+static void
+Log_Message(int Level, const char *msg)
+{
+	if (!Is_Daemon) {
+		/* log to console */
+		fprintf(stdout, "[%ld:%d %4ld] %s\n", (long)getpid(), Level,
+				(long)time(NULL) - NGIRCd_Start, msg);
+		fflush(stdout);
+	}
+#ifdef SYSLOG
+	else {
+		syslog(Level, "%s", msg);
+	}
+#endif
+}
+

 GLOBAL void
 Log_Init( bool Daemon_Mode )
@@ -248,25 +262,12 @@ va_dcl
 	vsnprintf( msg, MAX_LOG_MSG_LEN, Format, ap );
 	va_end( ap );

-	if (!Is_Daemon) {
-		/* log to console */
-		fprintf(stdout, "[%d:%d %4ld] %s\n", (int)getpid( ), Level,
-			time(NULL) - NGIRCd_Start, msg);
-		fflush(stdout);
-	}
-#ifdef SYSLOG
-	else
-	{
-		/* Syslog */
-		syslog( Level, "%s", msg );
-	}
-#endif
+	Log_Message(Level, msg);

-	if( Level <= LOG_CRIT )
-	{
+	if (Level <= LOG_CRIT) {
 		/* log critical messages to stderr */
-		fprintf( stderr, "%s\n", msg );
-		fflush( stderr );
+		fprintf(stderr, "%s\n", msg);
+		fflush(stderr);
 	}

 	if (snotice) {
@@ -285,7 +286,7 @@ Log_Init_Resolver( void )
 	openlog( PACKAGE_NAME, LOG_CONS|LOG_PID, LOG_LOCAL5 );
 #endif
 #ifdef DEBUG
-	Log_Resolver( LOG_DEBUG, "Resolver sub-process starting, PID %d.", getpid( ));
+	Log_Resolver(LOG_DEBUG, "Resolver sub-process starting, PID %ld.", (long)getpid());
 #endif
 } /* Log_Init_Resolver */

@@ -294,7 +295,7 @@ GLOBAL void
 Log_Exit_Resolver( void )
 {
 #ifdef DEBUG
-	Log_Resolver( LOG_DEBUG, "Resolver sub-process %d done.", getpid( ));
+	Log_Resolver(LOG_DEBUG, "Resolver sub-process %ld done.", (long)getpid());
 #endif
 #ifdef SYSLOG
 	closelog( );
@@ -335,15 +336,7 @@ va_dcl
 	vsnprintf( msg, MAX_LOG_MSG_LEN, Format, ap );
 	va_end( ap );

-	if (!Is_Daemon) {
-		/* Output to console */
-		fprintf(stdout, "[%d:%d %4ld] %s\n", (int)getpid( ), Level,
-			time(NULL) - NGIRCd_Start, msg);
-		fflush(stdout);
-	}
-#ifdef SYSLOG
-	else syslog( Level, "%s", msg );
-#endif
+	Log_Message(Level, msg);
 } /* Log_Resolver */


-----END OF PAGE-----