From a09cecfffd5151adfc50e343c821ed8ebdd1ab87 Mon Sep 17 00:00:00 2001
From: Michele Calgaro <michele.calgaro@yahoo.it>
Date: Fri, 20 Feb 2026 23:38:28 +0900
Subject: Some generic fixes required for future cmake conversion

Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
---
 config.h.in                                      |  9 ---------
 src/kvilib/config/kvi_wincfg.h                   | 12 ------------
 src/kvilib/core/kvi_error.cpp                    |  7 +------
 src/kvilib/net/kvi_dns.cpp                       | 13 -------------
 src/kvilib/system/kvi_env.cpp                    |  2 --
 src/kvilib/system/kvi_env.h                      | 10 ++--------
 src/kvirc/kernel/kvi_app_setup.cpp               | 10 ++++------
 src/modules/help/index.cpp                       |  2 +-
 src/modules/mediaplayer/mp_mp3.cpp               | 16 +++++++++-------
 src/modules/options/optw_messages.cpp            |  3 ++-
 src/modules/options/optw_sound.cpp               |  1 +
 src/modules/perlcore/ppport.h                    | 14 ++++++++------
 src/modules/setup/setupwizard.cpp                |  3 ++-
 src/modules/torrent/tc_ktorrentdcopinterface.cpp | 14 ++++++--------
 14 files changed, 36 insertions(+), 80 deletions(-)

diff --git a/config.h.in b/config.h.in
index f6f379d2..4c87ab73 100644
--- a/config.h.in
+++ b/config.h.in
@@ -87,12 +87,6 @@
 /* Define to 1 if you have the <dlfcn.h> header file. */
 #undef HAVE_DLFCN_H
 
-/* Define to 1 if you have the `getenv' function. */
-#undef HAVE_GETENV
-
-/* Define to 1 if you have the `getnameinfo' function. */
-#undef HAVE_GETNAMEINFO
-
 /* Define to 1 if you have the `inet_aton' function. */
 #undef HAVE_INET_ATON
 
@@ -111,9 +105,6 @@
 /* Define to 1 if you have the <soundcard.h> header file. */
 #undef HAVE_SOUNDCARD_H
 
-/* Define to 1 if you have the `strerror' function. */
-#undef HAVE_STRERROR
-
 /* Define to 1 if you have the <sys/soundcard.h> header file. */
 #undef HAVE_SYS_SOUNDCARD_H
 
diff --git a/src/kvilib/config/kvi_wincfg.h b/src/kvilib/config/kvi_wincfg.h
index 0e634dd9..84f590a3 100644
--- a/src/kvilib/config/kvi_wincfg.h
+++ b/src/kvilib/config/kvi_wincfg.h
@@ -76,12 +76,6 @@
 /* define if you have the SIOCGIFADDR ioctl and the related headers */
 /* #undef COMPILE_GET_INTERFACE_ADDRESS */
 
-/* define if you have the getenv function */
-/* #undef HAVE_GETENV */
-
-/* define if you have the strerror function */
-#define HAVE_STRERROR 1
-
 /* define if you have the inet_aton function */
 /* #define HAVE_INET_ATON 1 */
 
@@ -94,9 +88,6 @@
 /* define if you have the inet_ntop function */
 /* #undef HAVE_INET_NTOP */
 
-/* define if you have the getnameinfo function */
-#define HAVE_GETNAMEINFO
-
 /* define if you have the getaddrinfo function */
 #define HAVE_GETADDRINFO
 
@@ -115,9 +106,6 @@
 /* define this if you want to disable the inter-process communication support */
 /* #undef COMPILE_NO_IPC */
 
-/* Define if you have the `getenv' function. */
-/* #undef HAVE_GETENV */
-
 /* Define if you have the <linux/soundcard.h> header file. */
 /* #undef HAVE_LINUX_SOUNDCARD_H */
 
diff --git a/src/kvilib/core/kvi_error.cpp b/src/kvilib/core/kvi_error.cpp
index 2786984b..fa4af021 100644
--- a/src/kvilib/core/kvi_error.cpp
+++ b/src/kvilib/core/kvi_error.cpp
@@ -36,10 +36,7 @@
 #endif
 
 #include <errno.h>
-
-#ifdef HAVE_STRERROR
-#include <string.h> // for strerror()
-#endif
+#include <string.h>
 
 // FIXME: This stuff should basically die and be eventually replaced with some
 //        helper functions for handling ONLY system errors.
@@ -177,9 +174,7 @@ namespace KviError
 	{
 		if((iErrorCode < KVI_NUM_ERRORS) && (iErrorCode >= 0))
 			return g_errorTable[iErrorCode];
-#ifdef HAVE_STRERROR
 		if(iErrorCode < 0)return strerror(-iErrorCode);
-#endif
 		return g_errorTable[KviError_unknownError];
 	}
 	
diff --git a/src/kvilib/net/kvi_dns.cpp b/src/kvilib/net/kvi_dns.cpp
index c6f2612c..f4e8d8c9 100644
--- a/src/kvilib/net/kvi_dns.cpp
+++ b/src/kvilib/net/kvi_dns.cpp
@@ -220,9 +220,6 @@ void KviDnsThread::run()
 #else //!COMPILE_ON_WINDOWS || COMPILE_IPV6_SUPPORT
 
 	int retVal;
-
-
-//#ifdef HAVE_GETNAMEINFO
 	struct sockaddr_in ipv4Addr;
 
 #ifdef COMPILE_IPV6_SUPPORT
@@ -236,8 +233,6 @@ void KviDnsThread::run()
 	if(!bIsIpV4Ip)bIsIpV6Ip = KviNetUtils::stringIpToBinaryIp_V6(m_szQuery,(struct in6_addr *)&(ipv6Addr.sin6_addr));
 #endif
 
-//#ifdef HAVE_GETNAMEINFO
-
 #ifdef COMPILE_IPV6_SUPPORT
 	if(bIsIpV4Ip || bIsIpV6Ip)
 	{
@@ -271,12 +266,7 @@ void KviDnsThread::run()
 		}
 			
 	} else {
-//#endif //HAVE_GETNAMEINFO
 
-
-//#ifdef COMPILE_IPV6_SUPPORT
-//		struct in6_addr in6Addr;
-//#endif
 		struct addrinfo * pRet = 0;
 		struct addrinfo * pNext;
 		struct addrinfo hints;
@@ -334,10 +324,7 @@ void KviDnsThread::run()
 			}
 		}
 		if(pRet)freeaddrinfo(pRet);
-//#ifdef HAVE_GETNAMEINFO
 	}
-//#endif //HAVE_GETNAMEINFO
-
 #endif // !COMPILE_ON_WINDOWS
 
 
diff --git a/src/kvilib/system/kvi_env.cpp b/src/kvilib/system/kvi_env.cpp
index 1497632e..7905feb5 100644
--- a/src/kvilib/system/kvi_env.cpp
+++ b/src/kvilib/system/kvi_env.cpp
@@ -23,8 +23,6 @@
 //=============================================================================
 #define __KVILIB__
 
-#define _KVI_ENV_CPP_
-
 #include "kvi_env.h"
 #include "kvi_string.h"
 #include "kvi_malloc.h"
diff --git a/src/kvilib/system/kvi_env.h b/src/kvilib/system/kvi_env.h
index b3b24a2f..00ab8c0d 100644
--- a/src/kvilib/system/kvi_env.h
+++ b/src/kvilib/system/kvi_env.h
@@ -37,21 +37,15 @@
 
 inline char * kvi_getenv(const char * name)
 {
-#ifdef HAVE_GETENV
 	return getenv(name);
-#else
-	return 0;
-#endif
 }
 
 #ifdef COMPILE_ON_WINDOWS
 	#define kvi_setenv(__name,__value) SetEnvironmentVariable(__name,__value)
 	#define kvi_unsetenv(__name) SetEnvironmentVariable(__name,NULL)
 #else
-	#ifndef _KVI_ENV_CPP_
-		KVILIB_API extern bool kvi_setenv(const char * name,const char * value);
-		KVILIB_API extern void kvi_unsetenv(const char * name);
-	#endif
+	KVILIB_API extern bool kvi_setenv(const char * name,const char * value);
+	KVILIB_API extern void kvi_unsetenv(const char * name);
 #endif
 
 
diff --git a/src/kvirc/kernel/kvi_app_setup.cpp b/src/kvirc/kernel/kvi_app_setup.cpp
index 7cf75830..8a94def3 100644
--- a/src/kvirc/kernel/kvi_app_setup.cpp
+++ b/src/kvirc/kernel/kvi_app_setup.cpp
@@ -558,12 +558,10 @@ void KviApp::findGlobalKvircDirectory()
 		{
 			m_szGlobalKvircDir = locate("appdata","");
 			if(checkGlobalKvircDirectory(m_szGlobalKvircDir))return;
-			#ifdef HAVE_GETENV
-				//TDEDIR sanity check...
-				m_szGlobalKvircDir = getenv("TDEDIR");
-				m_szGlobalKvircDir+="/share/apps/kvirc/";
-				if(checkGlobalKvircDirectory(m_szGlobalKvircDir))return;
-			#endif
+			//TDEDIR sanity check...
+			m_szGlobalKvircDir = getenv("TDEDIR");
+			m_szGlobalKvircDir+="/share/apps/kvirc/";
+			if(checkGlobalKvircDirectory(m_szGlobalKvircDir))return;
 		}
 		// FAILED ? Check the usual way...
 	#endif //COMPILE_TDE_SUPPORT
diff --git a/src/modules/help/index.cpp b/src/modules/help/index.cpp
index 82c5f575..2d6dbf09 100644
--- a/src/modules/help/index.cpp
+++ b/src/modules/help/index.cpp
@@ -134,7 +134,7 @@ void Index::setupDocumentList()
 
 void Index::insertInDict( const TQString &str, int docNum )
 {
-    if ( strcmp( str, "amp" ) == 0 || strcmp( str, "nbsp" ) == 0 )
+    if ( str == "amp" || str == "nbsp" )
 	return;
     Entry *e = 0;
     if ( dict.count() )
diff --git a/src/modules/mediaplayer/mp_mp3.cpp b/src/modules/mediaplayer/mp_mp3.cpp
index 4942ee50..8000a9a4 100644
--- a/src/modules/mediaplayer/mp_mp3.cpp
+++ b/src/modules/mediaplayer/mp_mp3.cpp
@@ -396,7 +396,9 @@ int get_id3(mp3info *mp3)
 		{
 			retcode |= 4;
 		} else {
-			fread(fbuf,1,3,mp3->file); fbuf[3] = '\0';
+			// silence warning about ignoring return value of fread
+			[[maybe_unused]] size_t _unused = 0;
+			_unused = fread(fbuf,1,3,mp3->file); fbuf[3] = '\0';
 			mp3->id3.genre[0]=255;
 			
 			if(!strcmp((const char *)"TAG",(const char *)fbuf))
@@ -404,16 +406,16 @@ int get_id3(mp3info *mp3)
 				mp3->id3_isvalid=1;
 				mp3->datasize -= 128;
 				fseek(mp3->file, -125, SEEK_END);
-				fread(mp3->id3.title,1,30,mp3->file); mp3->id3.title[30] = '\0';
-				fread(mp3->id3.artist,1,30,mp3->file); mp3->id3.artist[30] = '\0';
-				fread(mp3->id3.album,1,30,mp3->file); mp3->id3.album[30] = '\0';
-				fread(mp3->id3.year,1,4,mp3->file); mp3->id3.year[4] = '\0';
-				fread(mp3->id3.comment,1,30,mp3->file); mp3->id3.comment[30] = '\0';
+				_unused = fread(mp3->id3.title,1,30,mp3->file); mp3->id3.title[30] = '\0';
+				_unused = fread(mp3->id3.artist,1,30,mp3->file); mp3->id3.artist[30] = '\0';
+				_unused = fread(mp3->id3.album,1,30,mp3->file); mp3->id3.album[30] = '\0';
+				_unused = fread(mp3->id3.year,1,4,mp3->file); mp3->id3.year[4] = '\0';
+				_unused = fread(mp3->id3.comment,1,30,mp3->file); mp3->id3.comment[30] = '\0';
 				if(mp3->id3.comment[28] == '\0')
 				{
 					mp3->id3.track[0] = mp3->id3.comment[29];
 				}
-				fread(mp3->id3.genre,1,1,mp3->file);
+				_unused = fread(mp3->id3.genre,1,1,mp3->file);
 				unpad(mp3->id3.title);
 				unpad(mp3->id3.artist);
 				unpad(mp3->id3.album);
diff --git a/src/modules/options/optw_messages.cpp b/src/modules/options/optw_messages.cpp
index a9af812d..9eabcce6 100644
--- a/src/modules/options/optw_messages.cpp
+++ b/src/modules/options/optw_messages.cpp
@@ -614,7 +614,8 @@ void KviMessageColorsOptionsWidget::load()
 	//tqDebug("SYMLINKING %s to %s",szGlobal.ptr(),szLocal.ptr());
 	//tqDebug("SYMLINK RETURNS %d (%d)",::symlink(szGlobal.ptr(),szLocal.ptr()));
 	//tqDebug("ERRNO (%d)",errno);
-	symlink(szGlobal,szLocal);
+	// "int _ = " used to silence warning from compiler about unchecked returned values
+	int _ = symlink(szGlobal,szLocal);
 	// FIXME: Do it also on windows...
 #endif
 
diff --git a/src/modules/options/optw_sound.cpp b/src/modules/options/optw_sound.cpp
index a9d8db6e..1e0df2b9 100644
--- a/src/modules/options/optw_sound.cpp
+++ b/src/modules/options/optw_sound.cpp
@@ -30,6 +30,7 @@
 #include "kvi_modulemanager.h"
 #include "kvi_pointerlist.h"
 #include "kvi_string.h"
+#include "kvi_tal_tooltip.h"
 
 #include <tqlabel.h>
 #include <tqpushbutton.h>
diff --git a/src/modules/perlcore/ppport.h b/src/modules/perlcore/ppport.h
index 8c8a706d..f9deb946 100644
--- a/src/modules/perlcore/ppport.h
+++ b/src/modules/perlcore/ppport.h
@@ -217,14 +217,16 @@ __DATA__
 /* Replace: 0 */
 #endif
 
-#ifdef HASATTRIBUTE
-#  if defined(__GNUC__) && defined(__cplusplus)
-#    define PERL_UNUSED_DECL
+#ifndef PERL_UNUSED_DECL
+#  ifdef HASATTRIBUTE
+#    if defined(__GNUC__) && defined(__cplusplus)
+#      define PERL_UNUSED_DECL
+#    else
+#      define PERL_UNUSED_DECL __attribute__((unused))
+#    endif
 #  else
-#    define PERL_UNUSED_DECL __attribute__((unused))
+#    define PERL_UNUSED_DECL
 #  endif
-#else
-#  define PERL_UNUSED_DECL
 #endif
 
 #ifndef dNOOP
diff --git a/src/modules/setup/setupwizard.cpp b/src/modules/setup/setupwizard.cpp
index 3cf36461..844e0b93 100644
--- a/src/modules/setup/setupwizard.cpp
+++ b/src/modules/setup/setupwizard.cpp
@@ -1001,7 +1001,8 @@ void KviSetupWizard::accept()
 		// Make local->global link
 		TQString localPath = TQString("%1/global").arg(g_pApp->m_szLocalKvircDir);
 		unlink(TQTextCodec::codecForLocale()->fromUnicode(localPath).data());
-		symlink(TQTextCodec::codecForLocale()->fromUnicode(g_pApp->m_szGlobalKvircDir).data(),TQTextCodec::codecForLocale()->fromUnicode(localPath).data());
+		// "int _ = " used to silence warning from compiler about unchecked returned values
+		int _ = symlink(TQTextCodec::codecForLocale()->fromUnicode(g_pApp->m_szGlobalKvircDir).data(),TQTextCodec::codecForLocale()->fromUnicode(localPath).data());
 #endif
 	
 #ifdef COMPILE_TDE_SUPPORT
diff --git a/src/modules/torrent/tc_ktorrentdcopinterface.cpp b/src/modules/torrent/tc_ktorrentdcopinterface.cpp
index 4d5c72d9..a26074ce 100644
--- a/src/modules/torrent/tc_ktorrentdcopinterface.cpp
+++ b/src/modules/torrent/tc_ktorrentdcopinterface.cpp
@@ -25,16 +25,14 @@
 //
 //=============================================================================
 
-#ifdef COMPILE_TDE_SUPPORT
-
-#include "kvi_app.h"
+#include "kvi_settings.h"
 
-
-#include "dcopclient.h" // <-- this include should be hidden in kvilib
+#ifdef COMPILE_TDE_SUPPORT
 
 #include "tc_ktorrentdcopinterface.h"
+#include "dcopclient.h" // <-- this include should be hidden in kvilib
 
-
+#include "kvi_app.h"
 #include "kvi_locale.h"
 #include <tqtimer.h>
 
@@ -58,8 +56,8 @@ TORR_IMPLEMENT_DESCRIPTOR(
 	tqDebug("%s (%s:%d): %s", __PRETTY_FUNCTION__, __FILE__, __LINE__, (const char*)msg); \
 
 #define ERROR_MSG_RANGE(I, SIZE) \
-	KviTQString::sprintf(m_lastError, __tr2qs_ctx("Index out of range: %d [0-%d]!", "torrent"), I, (SIZE>0)?(SIZE-1):0); \
-	tqDebug("%s (%s:%d): Index out of range: %d [0-%d]!", __PRETTY_FUNCTION__ , __FILE__, __LINE__, I, (SIZE>0)?(SIZE-1):0);
+	KviTQString::sprintf(m_lastError, __tr2qs_ctx("Index out of range: %d [0-%ld]!", "torrent"), I, (SIZE>0)?(SIZE-1):0); \
+	tqDebug("%s (%s:%d): Index out of range: %d [0-%ld]!", __PRETTY_FUNCTION__ , __FILE__, __LINE__, I, (SIZE>0)?(SIZE-1):0);
 
 #define ERROR_RET_BOOL \
 	{ \
-- 
cgit v1.2.3

