shithub: 9pro

Download patch

ref: 2ca228ddf3befc5feb0d980ec9efc867ad296c7e
parent: 507bd8e86d9f0f9d225d5a0ae7d6c3be0dbac085
author: Sigrid Haflínudóttir <ftrvxmtrx@gmail.com>
date: Tue May 19 13:27:31 EDT 2020

9gc: exit if no chat found

--- a/9gc.c
+++ b/9gc.c
@@ -25,10 +25,6 @@
 	Joined = 1<<2,
 };
 
-#define max(a,b) ((a)>(b)?(a):(b))
-#define used(x) ((void)(x))
-#define nelem(x) (int)(sizeof(x)/sizeof((x)[0]))
-
 typedef struct C9aux C9aux;
 typedef struct REntry REntry;
 
@@ -243,7 +239,6 @@
 			*s = 0;
 			if (strstr(b, "tlssrv") == NULL && (s = strchr(b, ' ')) != NULL) {
 				*s = 0;
-				printf("chat is at %s\n", b);
 				close(a->f);
 				if ((a->f = dial(b)) < 0)
 					exit(1);
@@ -251,11 +246,14 @@
 				a->r = ctxchatR;
 				a->wroff = a->wrend = 0;
 				c9version(ctx, &tag, Msize);
-				wrsend(a);
-				break;
+				if (wrsend(a) != 0)
+					exit(1);
+				return;
 			}
 			
 		}
+		fprintf(stderr, "chat hasn't been found in the registry\n");
+		exit(1);
 		break;
 
 	case Rerror: