File 0002-Fix-GCC-warnings.patch of Package xhomer

From 1fffd86f19890664ad116e5cdfd3ff1cdbbbbc3b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Klaus=20K=C3=A4mpf?= <kkaempf@gmail.com>
Date: Sun, 12 Oct 2025 09:45:23 +0200
Subject: [PATCH 2/2] Fix GCC warnings
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Klaus Kämpf <kkaempf@gmail.com>
---
 Makefile           |  2 +-
 pdp11_cpu.c        | 26 ++++++++++++++------------
 pdp11_fp.c         |  4 +++-
 pro_2661kb.c       |  2 +-
 pro_2661ptr.c      |  2 +-
 pro_init.c         |  8 ++++----
 pro_la50.c         |  4 ++--
 scp.c              |  2 +-
 sim_defs.h         |  2 +-
 term_overlay_x11.c |  4 ++--
 term_x11.c         | 15 ++++++++-------
 11 files changed, 38 insertions(+), 33 deletions(-)

diff --git a/Makefile b/Makefile
index 44261e6..bb60a53 100644
--- a/Makefile
+++ b/Makefile
@@ -125,7 +125,7 @@ CC += -ffloat-store
 # The 1st choice runs about 15% slower than the 2nd (-O3 -fomit-frame-pointer).
 # but it (re)compiles faster and unlike the second choice, it is debuggable.
 # CC += -g -O -fno-inline
-CC += -O3 -Winline -fomit-frame-pointer
+CC += -O3 -fomit-frame-pointer
 
 # Some older gcc's need this on i386 to work around a bug.  As long as
 # omit-frame-pointer is also set, it doesn't seem to hurt performance, so
diff --git a/pdp11_cpu.c b/pdp11_cpu.c
index 090b50b..8385d6d 100644
--- a/pdp11_cpu.c
+++ b/pdp11_cpu.c
@@ -241,7 +241,7 @@ extern int sim_int_char;
 /* XXX added LOCAL, GLOBAL, and INLINE; define to nothing to compile old way */
 
 LOCAL int cpu_ex (unsigned int *vptr, int addr, UNIT *uptr, int sw);
-LOCAL int cpu_dep (int val, int addr, UNIT *uptr, int sw);
+LOCAL int cpu_dep (unsigned int val, int addr, UNIT *uptr, int sw);
 LOCAL int cpu_reset (DEVICE *dptr);
 LOCAL int cpu_svc (UNIT *uptr);
 LOCAL int cpu_set_size (UNIT *uptr, int value);
@@ -258,8 +258,8 @@ GLOBAL void WriteW (int data, int addr);
 LOCAL void WriteB (int data, int addr);
 LOCAL void PWriteW (int data, int addr);
 LOCAL void PWriteB (int data, int addr);
-LOCAL int iopageR (int *data, int addr, int access);
-LOCAL int iopageW (int data, int addr, int access);
+LOCAL int iopageR (unsigned int *data, int addr, int access);
+LOCAL int iopageW (unsigned int data, int addr, int access);
 
 LOCAL int CPU_rd (int *data, int addr, int access);
 LOCAL int CPU_wr (int data, int addr, int access);
@@ -829,7 +829,8 @@ return pa;
 
 int ReadW (int va)
 {
-int pa, data;
+int pa;
+unsigned int data;
 
 /* Odd addressing errors are NOT detected on the PRO */
 
@@ -851,7 +852,8 @@ return data;
 
 int ReadB (int va)
 {
-int pa, data;
+int pa;
+unsigned int data;
 
 pa = relocR (va);					/* relocate */
 if (pa < MEMSIZE) return (va & 1? M[pa >> 1] >> 8: M[pa >> 1]) & 0377;
@@ -866,7 +868,7 @@ return ((va & 1)? data >> 8: data) & 0377;
 
 int ReadMW (int va)
 {
-int data;
+unsigned int data;
 
 #ifndef PRO
 if (va & 1) {						/* odd address? */
@@ -886,7 +888,7 @@ return data;
 
 int ReadMB (int va)
 {
-int data;
+unsigned int data;
 
 last_pa = relocW (va);					/* reloc, wrt chk */
 if (last_pa < MEMSIZE)
@@ -1138,27 +1140,27 @@ case 7:							/* @d(R) */
 	status	=	SCPE_OK or SCPE_NXM
 */
 
-int iopageR (int *data, int pa, int access)
+int iopageR (unsigned int *data, int pa, int access)
 {
 int stat;
 struct iolink *p;
 
 for (p = &iotable[0]; p -> low != 0; p++ ) {
 	if ((pa >= p -> low) && (pa <= p -> high))  {
-		stat = p -> read (data, pa, access);
+		stat = p -> read ((int *)data, pa, access);
 		trap_req = calc_ints (ipl, int_req, trap_req);
 		return stat;  }  }
 return SCPE_NXM;
 }
 
-int iopageW (int data, int pa, int access)
+int iopageW (unsigned int data, int pa, int access)
 {
 int stat;
 struct iolink *p;
 
 for (p = &iotable[0]; p -> low != 0; p++ ) {
 	if ((pa >= p -> low) && (pa <= p -> high))  {
-		stat = p -> write (data, pa, access);
+		stat = p -> write ((int)data, pa, access);
 		trap_req = calc_ints (ipl, int_req, trap_req);
 		return stat;  }  }
 return SCPE_NXM;
@@ -1437,7 +1439,7 @@ return iopageR (vptr, addr, READC);
 
 /* Memory deposit */
 
-int cpu_dep (int val, int addr, UNIT *uptr, int sw)
+int cpu_dep (unsigned int val, int addr, UNIT *uptr, int sw)
 {
 if (sw & SWMASK ('V')) {				/* -v */
 	if (addr >= VASIZE) return SCPE_NXM;
diff --git a/pdp11_fp.c b/pdp11_fp.c
index e627e95..58b679d 100644
--- a/pdp11_fp.c
+++ b/pdp11_fp.c
@@ -571,7 +571,9 @@ case 7:							/* @d(R) */
 	adr = ReadW (PC | isenable);
 	PC = (PC + 2) & 0177777;
 	adr = ReadW (((R[reg] + adr) & 0177777) | dsenable);
-	return (adr | dsenable);  }			/* end switch */
+	return (adr | dsenable);
+}			/* end switch */
+    return 0;
 }
 
 /* Read integer operand
diff --git a/pro_2661kb.c b/pro_2661kb.c
index bba7863..2ea5f7b 100644
--- a/pro_2661kb.c
+++ b/pro_2661kb.c
@@ -277,7 +277,7 @@ void pro_2661kb_wr (int data, int pa, int access)
 
 	    /* Clear transmitter ready if auto-echo or remote loopback modes */
 
-	    if (((pro_2661kb_cmd & PRO_2661_OM0) == 1)
+	    if ((pro_2661kb_cmd & PRO_2661_OM0)
 	       || ((pro_2661kb_cmd & PRO_2661_TXEN) == 0))
 	      pro_2661kb_stat = pro_2661kb_stat & ~PRO_2661_TR;
 	    else
diff --git a/pro_2661ptr.c b/pro_2661ptr.c
index 2424021..7d2336f 100644
--- a/pro_2661ptr.c
+++ b/pro_2661ptr.c
@@ -277,7 +277,7 @@ void pro_2661ptr_wr (int data, int pa, int access)
 
 	    /* Clear transmitter ready if auto-echo or remote loopback modes */
 
-	    if (((pro_2661ptr_cmd & PRO_2661_OM0) == 1)
+	    if ((pro_2661ptr_cmd & PRO_2661_OM0)
 	       || ((pro_2661ptr_cmd & PRO_2661_TXEN) == 0))
 	      pro_2661ptr_stat = pro_2661ptr_stat & ~PRO_2661_TR;
 	    else
diff --git a/pro_init.c b/pro_init.c
index a7a6714..31e94de 100644
--- a/pro_init.c
+++ b/pro_init.c
@@ -173,7 +173,7 @@ void pro_reset ()
 FILE		*fptr;
 char		*eofptr;
 char		str1[1024], str2[1024];
-char		filename[1024];
+char		filename[2048];
 char		*stra, *strv[MAXPAR];
 unsigned char	h, l;
 int		i, j, k, len, linenum, numpar, error, file_found;
@@ -332,7 +332,7 @@ char		*strtmp;
 
 	/* If $HOME is not defined, then look for /.xhomerrc */
 
-	sprintf(filename, "%.1000s/%s", getenv("HOME")?getenv("HOME"):"", ".xhomerrc");
+	snprintf(filename, 2048, "%.1000s/%s", getenv("HOME")?getenv("HOME"):"", ".xhomerrc");
 	fptr = fopen(filename,"r");
 
 	if (fptr != NULL)
@@ -345,9 +345,9 @@ char		*strtmp;
 	     simply use "./" */
 
 	  if (getcwd(str1, 1000) == NULL)
-	    sprintf(str1, ".");
+	    snprintf(str1, 1024, ".");
 
-	  sprintf(filename, "%s/%s", str1, "xhomer.cfg");
+	  snprintf(filename, 2048, "%s/%s", str1, "xhomer.cfg");
 	  fptr = fopen(filename,"r");
 
 	  if (fptr != NULL)
diff --git a/pro_la50.c b/pro_la50.c
index 32d6540..8ac23f1 100644
--- a/pro_la50.c
+++ b/pro_la50.c
@@ -60,7 +60,7 @@ struct sercall pro_la50 = {&pro_la50_get, &pro_la50_put,
 
 int			pro_la50_dpi = 300;	/* actual output resolution in DPI */
 
-LOCAL unsigned char	tmpstr[256];
+LOCAL char		tmpstr[256];
 
 LOCAL int		col;
 LOCAL int		maxcols, maxpos;
@@ -94,7 +94,7 @@ void ptr_fifo_put (int c)
 }
 
 
-void ptr_fifo_printf (unsigned char *s)
+void ptr_fifo_printf (const char *s)
 {
 	while(*s != '\0')
 	{
diff --git a/scp.c b/scp.c
index 91d81a1..d47be8c 100644
--- a/scp.c
+++ b/scp.c
@@ -552,7 +552,7 @@ if ((dptr = find_dev_from_unit (uptr)) == NULL) return SCPE_NOATT;
 if (uptr -> flags & UNIT_ATT) {				/* already attached? */
 	reason = detach_unit (uptr);
 	if (reason != SCPE_OK) return reason;  }
-uptr -> filename = calloc (CBUFSIZE, sizeof (char));
+uptr -> filename = calloc (CBUFSIZE+1, sizeof (char));
 if (uptr -> filename == NULL) return SCPE_MEM;
 strncpy (uptr -> filename, cptr, CBUFSIZE);
 uptr -> fileref = fopen (cptr, "rb+");
diff --git a/sim_defs.h b/sim_defs.h
index 3fbb237..36b9992 100644
--- a/sim_defs.h
+++ b/sim_defs.h
@@ -128,7 +128,7 @@ struct device {
 	int		dradix;				/* data radix */
 	int		dwidth;				/* data width */
 	t_stat		(*examine)(unsigned int *, int, struct unit *, int);	/* examine routine */
-	t_stat		(*deposit)(int, int, struct unit *, int);	/* deposit routine */
+	t_stat		(*deposit)(unsigned int, int, struct unit *, int);	/* deposit routine */
 	t_stat		(*reset)(struct device *);	/* reset routine */
 	t_stat		(*boot)(int);			/* boot routine */
 	t_stat		(*attach)(struct unit *, char *);/* attach routine */
diff --git a/term_overlay_x11.c b/term_overlay_x11.c
index 1767fe9..45aeb7a 100644
--- a/term_overlay_x11.c
+++ b/term_overlay_x11.c
@@ -229,8 +229,8 @@ void pro_overlay_init (int psize, int cmode, int bpixel, int wpixel)
 	  else
 	    overlay_a = PRO_OVERLAY_A;
 
-	  pro_overlay_data = (char *)malloc(PRO_VID_SCRWIDTH*PRO_VID_MEMHEIGHT*pixsize);
-	  pro_overlay_alpha = (char *)malloc(PRO_VID_SCRWIDTH*PRO_VID_MEMHEIGHT);
+	  pro_overlay_data = (unsigned char *)malloc(PRO_VID_SCRWIDTH*PRO_VID_MEMHEIGHT*pixsize);
+	  pro_overlay_alpha = (unsigned char *)malloc(PRO_VID_SCRWIDTH*PRO_VID_MEMHEIGHT);
 	  pro_overlay_on = 0;
 	  pro_overlay_open = 1;
 	}
diff --git a/term_x11.c b/term_x11.c
index 6c2f387..3f9b2dd 100644
--- a/term_x11.c
+++ b/term_x11.c
@@ -53,6 +53,7 @@
 #ifdef PRO
 
 #include <X11/Xlib.h>
+#include <X11/XKBlib.h>
 #include <X11/Xutil.h>
 #include <X11/keysym.h>
 #ifdef SHM
@@ -151,7 +152,7 @@ LOCAL XKeyboardControl	pro_keyboard_control;
 LOCAL XKeyboardState	pro_keyboard_state;		/* state to be restored on exit */
 LOCAL unsigned char	pro_keyboard_keys[32];		/* key vector */
 
-LOCAL unsigned char	*pro_image_data;
+LOCAL char		*pro_image_data;
 LOCAL int		pro_image_stride;
 
 LOCAL int		pro_screen_clutmode;		/* indicates whether window is in CLUT mode */
@@ -204,7 +205,7 @@ void pro_screen_title (char *title)
 void pro_screen_clear ()
 {
 int		i, j, k;
-unsigned char	*mptr;
+char		*mptr;
 
 
 	/* Clear image buffer */
@@ -435,7 +436,7 @@ int	key;
 void pro_screen_save_keys ()
 {
 int		i;
-unsigned char	keys[32];
+char		keys[32];
 
 
 	XQueryKeymap(ProDisplay, keys);
@@ -451,7 +452,7 @@ unsigned char	keys[32];
 void pro_screen_update_keys ()
 {
 int		i, key, oldkey, curkey;
-unsigned char	keys[32];
+char		keys[32];
 
 
 	XQueryKeymap(ProDisplay, keys);
@@ -463,7 +464,7 @@ unsigned char	keys[32];
 
 	  if (oldkey != curkey) 
 	  {
-	    key = XKeycodeToKeysym(ProDisplay, i, 0);
+	    key = XkbKeycodeToKeysym(ProDisplay, i, 0, 0); /* assumes no-shift */
 
 	    if (curkey == 0)
 	      key = pro_keyboard_lookup_up(key);
@@ -952,7 +953,7 @@ int			old_uid = geteuid();
 	    {
 	      /* Use non-shared memory */
 
-	      pro_image_data = (unsigned char *)malloc(PRO_VID_SCRWIDTH*PRO_VID_SCRHEIGHT*pro_screen_pixsize);
+	      pro_image_data = (char *)malloc(PRO_VID_SCRWIDTH*PRO_VID_SCRHEIGHT*pro_screen_pixsize);
 
 	      pro_image = XCreateImage(ProDisplay,
 			  DefaultVisual(ProDisplay, DefaultScreen(ProDisplay)),
@@ -1376,7 +1377,7 @@ int		a, na, opix, pnum, color, cindex;
 #ifdef DGA
 int		j, cur_scroll, scroll;
 #endif
-unsigned char	*image_data;
+char		*image_data;
 
 
 	/* Service X events */
-- 
2.51.0

openSUSE Build Service is sponsored by