From 48f73ca167262efb1a09078ff77d6d8fdf078268 Mon Sep 17 00:00:00 2001
From: Rob Swindell <rob@synchro.net>
Date: Sun, 20 Dec 2020 16:48:28 -0800
Subject: [PATCH] Don't log errno info for ERR_CHK errormsg() calls

The errno (global error number) information is not relevant for any sbbs "checking" type errors.
Also, use safe_strerror() for thread-safe errno descriptions.
---
 src/sbbs3/logfile.cpp | 37 +++++++++++++++----------------------
 1 file changed, 15 insertions(+), 22 deletions(-)

diff --git a/src/sbbs3/logfile.cpp b/src/sbbs3/logfile.cpp
index c702bfe788..b4d92520aa 100644
--- a/src/sbbs3/logfile.cpp
+++ b/src/sbbs3/logfile.cpp
@@ -1,7 +1,5 @@
 /* Synchronet log file routines */
 
-/* $Id: logfile.cpp,v 1.69 2020/08/08 19:32:30 rswindell Exp $ */
-
 /****************************************************************************
  * @format.tab-size 4		(Plain Text/Source Code File Header)			*
  * @format.use-tabs true	(see http://www.synchro.net/ptsc_hdr.html)		*
@@ -15,21 +13,9 @@
  * See the GNU General Public License for more details: gpl.txt or			*
  * http://www.fsf.org/copyleft/gpl.html										*
  *																			*
- * Anonymous FTP access to the most recent released source is available at	*
- * ftp://vert.synchro.net, ftp://cvs.synchro.net and ftp://ftp.synchro.net	*
- *																			*
- * Anonymous CVS access to the development source and modification history	*
- * is available at cvs.synchro.net:/cvsroot/sbbs, example:					*
- * cvs -d :pserver:anonymous@cvs.synchro.net:/cvsroot/sbbs login			*
- *     (just hit return, no password is necessary)							*
- * cvs -d :pserver:anonymous@cvs.synchro.net:/cvsroot/sbbs checkout src		*
- *																			*
  * For Synchronet coding style and modification guidelines, see				*
  * http://www.synchro.net/source.html										*
  *																			*
- * You are encouraged to submit any modifications (preferably in Unix diff	*
- * format) via e-mail to mods@synchro.net									*
- *																			*
  * Note: If this box doesn't appear square, then you need to fix your tabs.	*
  ****************************************************************************/
 
@@ -239,21 +225,28 @@ void sbbs_t::errormsg(int line, const char* function, const char *src, const cha
 					  ,long access, const char *extinfo)
 {
     char	str[2048];
+	char	errno_str[128];
+	char	errno_info[256] = "";
 
 	/* prevent recursion */
 	if(errormsg_inside)
 		return;
 	errormsg_inside=true;
 
-	safe_snprintf(str,sizeof(str),"ERROR %d (%s) "
-#ifdef _WIN32
-		"(WinError %u) "
-#endif
+	if(strcmp(action, ERR_CHK) != 0)
+		safe_snprintf(errno_info, sizeof(errno_info), "%d (%s) "
+	#ifdef _WIN32
+			"(WinError %u) "
+	#endif
+			,errno, safe_strerror(errno, errno_str, sizeof(errno_str))
+	#ifdef _WIN32
+			,GetLastError()
+	#endif
+		);
+
+	safe_snprintf(str,sizeof(str),"ERROR %s"
 		"in %s line %u (%s) %s \"%s\" access=%ld %s%s"
-		,errno,STRERROR(errno)
-#ifdef _WIN32
-		,GetLastError()
-#endif
+		,errno_info
 		,src, line, function, action, object, access
 		,extinfo==NULL ? "":"info="
 		,extinfo==NULL ? "":extinfo);
-- 
GitLab