Commit 20c8aafb authored by Dridi Boukelmoune's avatar Dridi Boukelmoune

Swap the VSB_tofile() arguments

Automated with Coccinelle, so the semantic patch could be reused in the
vtest project.

Closes #3238
parent 7862b138
......@@ -208,7 +208,7 @@ vsmw_append_record(struct vsmw *vsmw, struct vsmwseg *seg, char act)
VSB_clear(vsmw->vsb);
vsmw_fmt_index(vsmw, seg, act);
AZ(VSB_finish(vsmw->vsb));
XXXAZ(VSB_tofile(fd, vsmw->vsb)); // XXX handle ENOSPC? #2764
XXXAZ(VSB_tofile(vsmw->vsb, fd)); // XXX handle ENOSPC? #2764
closefd(&fd);
}
......@@ -255,7 +255,7 @@ vsmw_delseg(struct vsmw *vsmw, struct vsmwseg *seg)
VTAILQ_FOREACH(s2, &vsmw->segs, list)
vsmw_fmt_index(vsmw, s2, '+');
AZ(VSB_finish(vsmw->vsb));
XXXAZ(VSB_tofile(fd, vsmw->vsb)); // XXX handle ENOSPC? #2764
XXXAZ(VSB_tofile(vsmw->vsb, fd)); // XXX handle ENOSPC? #2764
closefd(&fd);
AZ(renameat(vsmw->vdirfd, t, vsmw->vdirfd, vsmw->idx));
REPLACE(t, NULL);
......
......@@ -147,7 +147,7 @@ mcf_askchild(struct cli *cli, const char * const *av, void *priv)
}
VSB_putc(cli_buf, '\n');
AZ(VSB_finish(cli_buf));
if (VSB_tofile(cli_o, cli_buf)) {
if (VSB_tofile(cli_buf, cli_o)) {
VCLI_SetResult(cli, CLIS_COMMS);
VCLI_Out(cli, "CLI communication error");
MCH_Cli_Fail();
......@@ -196,7 +196,7 @@ mgt_cli_askchild(unsigned *status, char **resp, const char *fmt, ...)
AZ(VSB_finish(cli_buf));
i = VSB_len(cli_buf);
assert(i > 0 && VSB_data(cli_buf)[i - 1] == '\n');
if (VSB_tofile(cli_o, cli_buf)) {
if (VSB_tofile(cli_buf, cli_o)) {
*status = CLIS_COMMS;
if (resp != NULL)
*resp = strdup("CLI communication error");
......
......@@ -229,7 +229,7 @@ cmd_haproxy_cli_send(CMD_ARGS)
}
vtc_dump(hc->vl, 4, "CLI send", VSB_data(vsb), -1);
if (VSB_tofile(hc->sock, vsb))
if (VSB_tofile(vsb, hc->sock))
vtc_fatal(hc->vl,
"CLI fd %d send error %s", hc->sock, strerror(errno));
......
......@@ -217,7 +217,7 @@ http_write(const struct http *hp, int lvl, const char *pfx)
AZ(VSB_finish(hp->vsb));
vtc_dump(hp->vl, lvl, pfx, VSB_data(hp->vsb), VSB_len(hp->vsb));
if (VSB_tofile(hp->fd, hp->vsb))
if (VSB_tofile(hp->vsb, hp->fd))
vtc_log(hp->vl, hp->fatal, "Write failed: %s",
strerror(errno));
}
......@@ -1381,7 +1381,7 @@ cmd_http_sendhex(CMD_ARGS)
vsb = vtc_hex_to_bin(hp->vl, av[1]);
assert(VSB_len(vsb) >= 0);
vtc_hexdump(hp->vl, 4, "sendhex", VSB_data(vsb), VSB_len(vsb));
if (VSB_tofile(hp->fd, vsb))
if (VSB_tofile(vsb, hp->fd))
vtc_log(hp->vl, hp->fatal, "Write failed: %s",
strerror(errno));
VSB_destroy(&vsb);
......
......@@ -803,7 +803,7 @@ process_write_hex(const struct process *p, const char *text)
vsb = vtc_hex_to_bin(p->vl, text);
assert(VSB_len(vsb) >= 0);
vtc_hexdump(p->vl, 4, "sendhex", VSB_data(vsb), VSB_len(vsb));
AZ(VSB_tofile(p->fd_term, vsb));
AZ(VSB_tofile(vsb, p->fd_term));
VSB_destroy(&vsb);
}
......
......@@ -128,7 +128,7 @@ vtc_send_proxy(int fd, int version, const struct suckaddr *sac,
WRONG("Wrong proxy version");
AZ(VSB_finish(vsb));
i = VSB_tofile(fd, vsb);
i = VSB_tofile(vsb, fd);
VSB_delete(vsb);
return (i);
}
......@@ -89,7 +89,7 @@ void VSB_quote_pfx(struct vsb *, const char*, const void *,
int len, int how);
void VSB_quote(struct vsb *, const void *, int len, int how);
void VSB_indent(struct vsb *, int);
int VSB_tofile(int fd, const struct vsb *);
int VSB_tofile(const struct vsb *, int fd);
#ifdef __cplusplus
};
#endif
......
......@@ -658,7 +658,7 @@ VSB_indent(struct vsb *s, int i)
}
int
VSB_tofile(int fd, const struct vsb *s)
VSB_tofile(const struct vsb *s, int fd)
{
int sz;
......
......@@ -110,7 +110,7 @@ TLWriteVSB(struct vcc *tl, const char *fn, const struct vsb *vsb,
what, fn, strerror(errno));
return (-1);
}
i = VSB_tofile(fo, vsb);
i = VSB_tofile(vsb, fo);
if (i) {
VSB_printf(tl->sb,
"Could not write %s to %s: %s\n",
......
/*
* This patch fixes the order of VSB_tofile arguments.
*/
@@
idexpression struct vsb *vsb;
idexpression int fd;
@@
- VSB_tofile(fd, vsb)
+ VSB_tofile(vsb, fd)
@@
idexpression struct vsb[] vsb;
idexpression int fd;
@@
- VSB_tofile(fd, vsb)
+ VSB_tofile(vsb, fd)
@@
idexpression struct vsb *vsb;
expression fd;
@@
- VSB_tofile(fd, vsb)
+ VSB_tofile(vsb, fd)
/* Opportunistic fallback */
@@
idexpression int fd;
expression vsb;
@@
- VSB_tofile(fd, vsb)
+ VSB_tofile(vsb, fd)
/* Opportunistic last resort */
@@
expression fd, other;
@@
- VSB_tofile(fd, other->vsb)
+ VSB_tofile(other->vsb, fd)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment