From 2e2ab2510aa35d61fda176c1bb1526479490f34a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Deuc=D0=B5?= <shurd@sasktel.net>
Date: Sun, 11 Feb 2024 00:45:04 -0500
Subject: [PATCH] Fix some warnings.

We can't use const protection for the sample buffer because the Win32
API takes non-const buffers.  For standard implicit conversions,
simply disable the warning where it occurs on purpose.  It appears
that MSVC builds use the equivilent of -Wconversion (which isn't even
part of -Wall).
---
 src/xpdev/xpbeep.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/src/xpdev/xpbeep.c b/src/xpdev/xpbeep.c
index d7979c80fc..49bf3222b6 100644
--- a/src/xpdev/xpbeep.c
+++ b/src/xpdev/xpbeep.c
@@ -239,6 +239,10 @@ void xptone_makewave(double freq, unsigned char *wave, int samples, enum WAVE_SH
 		inc=8.0*atan(1.0);
 		inc *= ((double)freq / (double)S_RATE);
 
+#ifdef MSVC
+#pragma warning(push)
+#pragma warning(disable : 4244)
+#endif
 		for(i=0;i<samples;i++) {
 			pos=(inc*(double)i);
 			pos -= (int)(pos/WAVE_TPI)*WAVE_TPI;
@@ -272,6 +276,9 @@ void xptone_makewave(double freq, unsigned char *wave, int samples, enum WAVE_SH
 					break;
 			}
 		}
+#ifdef MSVC
+#pragma warning(pop)
+#endif
 
 		/* Now we have a "perfect" wave... 
 		 * we must clean it up now to avoid click/pop
@@ -823,10 +830,11 @@ xptone_close(void)
 	return ret;
 }
 
+// This can't be const because the Win32 API is not const.
 static bool
 do_xp_play_sample(const unsigned char *sampo, size_t sz, int *freed)
 {
-	const unsigned char *samp;
+	unsigned char *samp;
 	int need_copy = 0;
 #ifdef AFMT_U8
 	int wr;
@@ -1152,8 +1160,15 @@ bool xptone(double freq, DWORD duration, enum WAVE_SHAPE shape)
 		freq=17;
 	samples=S_RATE*duration/1000;
 	if(freq) {
+#ifdef MSVC
+#pragma warning(push)
+#pragma warning(disable : 4244)
+#endif
 		if(samples<=S_RATE/freq*2)
 			samples=S_RATE/freq*2;
+#ifdef MSVC
+#pragma warning(pop)
+#endif
 	}
 	if(freq==0 || samples > S_RATE/freq*2) {
 		int sample_len;
-- 
GitLab