int linelen = brk - b;
if (!outbuf.len)
- strbuf_addf(&outbuf, "%s", PREFIX);
+ strbuf_addstr(&outbuf, PREFIX);
if (linelen > 0) {
strbuf_addf(&outbuf, "%.*s%s%c",
linelen, b, suffix, *brk);
} else {
- strbuf_addf(&outbuf, "%c", *brk);
+ strbuf_addch(&outbuf, *brk);
}
xwrite(2, outbuf.buf, outbuf.len);
strbuf_reset(&outbuf);
}
if (outbuf.len) {
- strbuf_addf(&outbuf, "\n");
+ strbuf_addch(&outbuf, '\n');
xwrite(2, outbuf.buf, outbuf.len);
}
strbuf_release(&outbuf);
* fd is connected to the remote side; send the sideband data
* over multiplexed packet stream.
*/
-ssize_t send_sideband(int fd, int band, const char *data, ssize_t sz, int packet_max)
+void send_sideband(int fd, int band, const char *data, ssize_t sz, int packet_max)
{
- ssize_t ssz = sz;
const char *p = data;
while (sz) {
if (packet_max - 5 < n)
n = packet_max - 5;
if (0 <= band) {
- sprintf(hdr, "%04x", n + 5);
+ xsnprintf(hdr, sizeof(hdr), "%04x", n + 5);
hdr[4] = band;
write_or_die(fd, hdr, 5);
} else {
- sprintf(hdr, "%04x", n + 4);
+ xsnprintf(hdr, sizeof(hdr), "%04x", n + 4);
write_or_die(fd, hdr, 4);
}
write_or_die(fd, p, n);
p += n;
sz -= n;
}
- return ssz;
}