check arguments to debug() and fix resulting warnings. Notes: Mon Nov 8 14:26:43 EST 2010 geoff added the pragma and fixed the resulting warnings. other changes not applied. Reference: /n/sources/patch/applied/sshdprint Date: Tue Nov 2 14:50:38 CET 2010 Signed-off-by: quanstro@quanstro.net Reviewed-by: geoff --- /sys/src/cmd/ssh/ssh.h Tue Nov 2 14:48:54 2010 +++ /sys/src/cmd/ssh/ssh.h Tue Nov 2 14:48:50 2010 @@ -300,4 +300,4 @@ #pragma varargck argpos error 1 #pragma varargck argpos sshlog 2 - +#pragma varargck argpos debug 2 --- /sys/src/cmd/ssh/cmsg.c Tue Nov 2 14:49:01 2010 +++ /sys/src/cmd/ssh/cmsg.c Tue Nov 2 14:48:58 2010 @@ -90,13 +90,13 @@ } for(i=0; inokauth; i++){ - debug(DBG_AUTH, "authmask %#x, consider %s (%#x)\n", c->authmask, c->okauth[i]->name, 1<okauth[i]->id); + debug(DBG_AUTH, "authmask %#lux, consider %s (%#ux)\n", c->authmask, c->okauth[i]->name, 1<okauth[i]->id); if(c->authmask & (1<okauth[i]->id)) if((*c->okauth[i]->fn)(c) == 0) return 0; } - debug(DBG_AUTH, "no auth methods worked; (authmask=%#x)\n", c->authmask); + debug(DBG_AUTH, "no auth methods worked; (authmask=%#lux)\n", c->authmask); return -1; } @@ -252,25 +252,52 @@ } /* - * assumes that if you care, you're running under vt - * and therefore these are set. + * clumsy hack -- rather than open the font and fetch + * the real character width and height, we assume that + * LINES and COLS are initially correct and use them to + * derive cwidth, cheight. this is definitely a mistake, + * but i don't care. if you do, fix it. */ int readgeom(int *nrow, int *ncol, int *width, int *height) { + int ret; + static int first=1; static int fd = -1; + static int cwidth, cheight; char buf[64]; + int n; - if(fd < 0 && (fd = open("/dev/wctl", OREAD)) < 0) - return -1; - /* wait for event, but don't care what it says */ - if(read(fd, buf, sizeof buf) < 0) - return -1; - *nrow = intgetenv("LINES", 24); - *ncol = intgetenv("COLS", 80); - *width = intgetenv("XPIXELS", 640); - *height = intgetenv("YPIXELS", 480); - return 0; + ret = 0; + /* defaults */ + *width = 640; + *height = 480; + + if(fd < 0) + fd = open("/dev/wctl", OREAD); + if(fd >= 0){ + n = read(fd, buf, sizeof(buf)); + if(n < 48){ + close(fd); + fd = -1; + ret = -1; + goto Out; + } + } + *width = atoi(&buf[2*12]) - atoi(&buf[0*12]); + *height = atoi(&buf[3*12]) - atoi(&buf[1*12]); + +Out: + *nrow = intgetenv("LINES", 0); + *ncol = intgetenv("COLS", 0); + if(first){ + first = 0; + if(*nrow) + cwidth = *width/(*nrow); + if(*ncol) + cheight = *height/(*ncol); + } + return ret; } void --- /sys/src/cmd/ssh/msg.c Tue Nov 2 14:49:07 2010 +++ /sys/src/cmd/ssh/msg.c Tue Nov 2 14:49:03 2010 @@ -102,7 +102,7 @@ void unrecvmsg(Conn *c, Msg *m) { - debug(DBG_PROTO, "unreceived %s len %d\n", msgnames[m->type], m->ep - m->rp); + debug(DBG_PROTO, "unreceived %s len %ld\n", msgnames[m->type], m->ep - m->rp); free(c->unget); c->unget = m; } @@ -171,7 +171,7 @@ Msg *m; while((m = recvmsg0(c)) != nil){ - debug(DBG_PROTO, "received %s len %d\n", msgnames[m->type], m->ep - m->rp); + debug(DBG_PROTO, "received %s len %ld\n", msgnames[m->type], m->ep - m->rp); if(m->type != SSH_MSG_DEBUG && m->type != SSH_MSG_IGNORE) break; if(m->type == SSH_MSG_DEBUG) @@ -205,7 +205,7 @@ len = datalen + 5; pad = 8 - len%8; - debug(DBG_PROTO, "sending %s len %d\n", msgnames[m->type], datalen); + debug(DBG_PROTO, "sending %s len %lud\n", msgnames[m->type], datalen); p = m->bp; memmove(m->bp+4+pad+1, m->bp, datalen); /* slide data to correct position */ --- /sys/src/cmd/ssh/agent.c Tue Nov 2 14:49:14 2010 +++ /sys/src/cmd/ssh/agent.c Tue Nov 2 14:49:10 2010 @@ -203,7 +203,7 @@ assert(m->type == SSH_MSG_CHANNEL_DATA); debug(DBG_AUTH, "agent data\n"); - debug(DBG_AUTH, "\t%.*H\n", m->ep-m->rp, m->rp); + debug(DBG_AUTH, "\t%.*H\n", (int)(m->ep-m->rp), m->rp); chan = getlong(m); len = getlong(m); if(m->rp+len != m->ep) --- /sys/src/cmd/ssh/authrsa.c Tue Nov 2 14:49:21 2010 +++ /sys/src/cmd/ssh/authrsa.c Tue Nov 2 14:49:17 2010 @@ -41,7 +41,7 @@ m = recvmsg(c, -1); switch(m->type){ case SSH_SMSG_FAILURE: - debug(DBG_AUTH, "\tnot accepted\n", (char*)rpc->arg); + debug(DBG_AUTH, "\tnot accepted %s\n", (char*)rpc->arg); free(m); continue; default: