Hello,

I'm a happy user of wmii. It is a great piece of software.

I'm running it on a 64 bit system, and I just noticed some
pointer-integer arithmetic problems in the wmii code. As 64 bit
pointers don't fit into 32bit int datatypes, it is neccessary to use
unsigned long for pointer arithmetic. I am attaching a diff with the
neccessary changes against wmii-tip to this email.

As I understand it should work on 32 bit and 64 bit systems, but I did
not test this.

Thanks for the great software,

Brian

-- 
Brian Amberg
http://ruby.brian-amberg.de/
diff -r 59b2862bc2a0 config.mk
--- a/config.mk	Wed Jul 18 19:45:36 2007 -0400
+++ b/config.mk	Fri Aug 31 09:35:12 2007 +0200
@@ -1,7 +1,7 @@
 # Customize below to fit your system
 
 # paths
-PREFIX = /usr/local
+PREFIX = /usr/
 BIN = ${PREFIX}/bin
 MAN = ${PREFIX}/share/man
 ETC = ${PREFIX}/etc
diff -r 59b2862bc2a0 include/fmt.h
--- a/include/fmt.h	Wed Jul 18 19:45:36 2007 -0400
+++ b/include/fmt.h	Fri Aug 31 09:44:09 2007 +0200
@@ -112,7 +112,7 @@ int		dorfmt(Fmt *f, const Rune *fmt);
 int		dorfmt(Fmt *f, const Rune *fmt);
 double		fmtcharstod(int(*f)(void*), void *vp);
 int		fmtfdflush(Fmt *f);
-int		fmtfdinit(Fmt *f, int fd, char *buf, int size);
+int		fmtfdinit(Fmt *f, unsigned long fd, char *buf, int size);
 int		fmtinstall(int c, int (*f)(Fmt*));
 int		fmtprint(Fmt *f, const char *fmt, ...);
 int		fmtrune(Fmt *f, int r);
diff -r 59b2862bc2a0 libfmt/fmtfd.c
--- a/libfmt/fmtfd.c	Wed Jul 18 19:45:36 2007 -0400
+++ b/libfmt/fmtfd.c	Fri Aug 31 09:41:49 2007 +0200
@@ -33,7 +33,7 @@ fmtfdflush(Fmt *f)
  * initialize an output buffer for buffered printing
  */
 int
-fmtfdinit(Fmt *f, int fd, char *buf, int size)
+fmtfdinit(Fmt *f, unsigned long fd, char *buf, int size)
 {
 	f->runes = 0;
 	f->start = buf;
diff -r 59b2862bc2a0 libfmt/fmtfdflush.c
--- a/libfmt/fmtfdflush.c	Wed Jul 18 19:45:36 2007 -0400
+++ b/libfmt/fmtfdflush.c	Fri Aug 31 09:44:23 2007 +0200
@@ -24,10 +24,10 @@ int
 int
 __fmtFdFlush(Fmt *f)
 {
-	int n;
+	unsigned long n;
 
 	n = (char*)f->to - (char*)f->start;
-	if(n && write((int)f->farg, f->start, n) != n)
+	if(n && write((unsigned long)f->farg, f->start, n) != n)
 		return 0;
 	f->to = f->start;
 	return 1;
diff -r 59b2862bc2a0 libfmt/runevsmprint.c
--- a/libfmt/runevsmprint.c	Wed Jul 18 19:45:36 2007 -0400
+++ b/libfmt/runevsmprint.c	Fri Aug 31 09:44:36 2007 +0200
@@ -26,11 +26,11 @@ runeFmtStrFlush(Fmt *f)
 runeFmtStrFlush(Fmt *f)
 {
 	Rune *s;
-	int n;
+	unsigned long n;
 
 	if(f->start == nil)
 		return 0;
-	n = (int)f->farg;
+	n = (unsigned long)f->farg;
 	n *= 2;
 	s = (Rune*)f->start;
 	f->start = realloc(s, sizeof(Rune)*n);
@@ -50,7 +50,7 @@ int
 int
 runefmtstrinit(Fmt *f)
 {
-	int n;
+	unsigned long n;
 
 	memset(f, 0, sizeof *f);
 	f->runes = 1;
diff -r 59b2862bc2a0 libfmt/sprint.c
--- a/libfmt/sprint.c	Wed Jul 18 19:45:36 2007 -0400
+++ b/libfmt/sprint.c	Fri Aug 31 09:45:52 2007 +0200
@@ -18,8 +18,8 @@ int
 int
 sprint(char *buf, const char *fmt, ...)
 {
-	int n;
-	uint len;
+	unsigned long n;
+	unsigned long len;
 	va_list args;
 
 	len = 1<<30;  /* big number, but sprint is deprecated anyway */
@@ -28,7 +28,7 @@ sprint(char *buf, const char *fmt, ...)
 	 * we must be sure not to overflow a 32-bit pointer.
 	 */
 	if(buf+len < buf)
-		len = -(uint)buf-1;
+		len = -(unsigned long)buf-1;
 
 	va_start(args, fmt);
 	n = vsnprint(buf, len, fmt, args);
diff -r 59b2862bc2a0 libfmt/vsmprint.c
--- a/libfmt/vsmprint.c	Wed Jul 18 19:45:36 2007 -0400
+++ b/libfmt/vsmprint.c	Fri Aug 31 09:46:26 2007 +0200
@@ -26,11 +26,11 @@ fmtStrFlush(Fmt *f)
 fmtStrFlush(Fmt *f)
 {
 	char *s;
-	int n;
+	unsigned long n;
 
 	if(f->start == nil)
 		return 0;
-	n = (int)f->farg;
+	n = (unsigned long)f->farg;
 	n *= 2;
 	s = (char*)f->start;
 	f->start = realloc(s, n);
@@ -50,7 +50,7 @@ int
 int
 fmtstrinit(Fmt *f)
 {
-	int n;
+	unsigned long n;
 
 	memset(f, 0, sizeof *f);
 	f->runes = 0;

Reply via email to