shithub: barrera

Download patch

ref: 05fe1c3b2b5c3d1f8467ed0c39a02eb916512221
parent: a3fb851f0e29e8e0fd50acef703e7d16f809a666
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Mon Jan 2 13:33:16 EST 2023

just sysfatal on write error

--- a/barrera.c
+++ b/barrera.c
@@ -304,22 +304,21 @@
 	m->e = m->p + len;
 }
 
-int
+void
 writemsg(char *fmt, ...)
 {
 	static Msg m;
 	va_list arg;
-	int n, l;
+	int l;
 
 	va_start(arg, fmt);
 	l = 4 + vpackmsglen(fmt, arg);
 	sizemsg(&m, l);
 	packmsg(&m, "%4i", l-4);
-	n = vpackmsg(&m, fmt, arg);
+	vpackmsg(&m, fmt, arg);
 	va_end(arg);
 	if(write(1, m.b, l)!=l)
-		return -1;
-	return n;
+		sysfatal("writemsg: %r");
 }
 
 void
@@ -564,8 +563,7 @@
 		case MSGID('B','a','r','r'):	/* hello from server */
 			if(unpackmsg(&m, "ier%2i%2i", &major, &minjor)!=2)
 				goto unhandled;
-			if(writemsg("Barrier%2i%2i%s", 1, 6, sysname())!=3)
-				return;
+			writemsg("Barrier%2i%2i%s", 1, 6, sysname());
 			break;
 
 		case MSGID('Q','I','N','F'):	/* query info from server */
@@ -578,8 +576,7 @@
 
 		case MSGID('C','A','L','V'):
 			/* Keep alive ping */
-			if(writemsg("CALV")!=0)
-				return;
+			writemsg("CALV");
 			break;
 
 		case MSGID('C','N','O','P'):	/* nop */
@@ -608,17 +605,14 @@
 				if(!clip[i])
 					continue;
 				snprint(size, sizeof(size), "%d", z);
-				if(writemsg("DCLP%1i%4i%1i%s", i, seq, 1, size) != 4)
-					return;
+				writemsg("DCLP%1i%4i%1i%s", i, seq, 1, size);
 				for(l = 0; l < z; l += n){
 					n = z - l;
 					if(n > 1024)
 						n = 1024;
-					if(writemsg("DCLP%1i%4i%1i%*", i, seq, 2, n, snarfbuf.p+l) != 4)
-						return;
+					writemsg("DCLP%1i%4i%1i%*", i, seq, 2, n, snarfbuf.p+l);
 				}
-				if(writemsg("DCLP%1i%4i%1i%s", i, seq, 3, "") != 4)
-					return;
+				writemsg("DCLP%1i%4i%1i%s", i, seq, 3, "");
 				clip[i] = 0;
 			}
 			sizemsg(&snarfbuf, 0);
@@ -739,7 +733,7 @@
 
 			readscreensize();
 			readscreenmouse();
-			if(writemsg("DINF%2i%2i%2i%2i%2i%2i%2i", 
+			writemsg("DINF%2i%2i%2i%2i%2i%2i%2i", 
 				screensize.min.x,
 				screensize.min.y,
 				screensize.max.x,
@@ -746,14 +740,12 @@
 				screensize.max.y,
 				0,			/* size of warp zone (obsolete) */
 				screenmouse.x, 
-				screenmouse.y)!=7)	/* current mouse position */
-				return;
+				screenmouse.y);		/* current mouse position */
 		}
 
 		if(readsnarf()){
 			for(i=0; i<2; i++){
-				if(writemsg("CCLP%1i%4i", i, seq)!=2)
-					return;
+				writemsg("CCLP%1i%4i", i, seq);
 				clip[i] = 1;
 			}
 		}