bfcp: pass va_list by reference to handle recursive calls consistently
This commit is contained in:
parent
b1ae9e88d5
commit
f1e10e7e98
6 changed files with 14 additions and 14 deletions
|
@ -223,7 +223,7 @@ typedef void (bfcp_resp_h)(int err, const struct bfcp_msg *msg, void *arg);
|
|||
|
||||
|
||||
/* attr */
|
||||
int bfcp_attrs_vencode(struct mbuf *mb, unsigned attrc, va_list ap);
|
||||
int bfcp_attrs_vencode(struct mbuf *mb, unsigned attrc, va_list *ap);
|
||||
int bfcp_attrs_encode(struct mbuf *mb, unsigned attrc, ...);
|
||||
struct bfcp_attr *bfcp_attr_subattr(const struct bfcp_attr *attr,
|
||||
enum bfcp_attrib type);
|
||||
|
@ -238,7 +238,7 @@ const char *bfcp_errcode_name(enum bfcp_err code);
|
|||
/* msg */
|
||||
int bfcp_msg_vencode(struct mbuf *mb, uint8_t ver, bool r, enum bfcp_prim prim,
|
||||
uint32_t confid, uint16_t tid, uint16_t userid,
|
||||
unsigned attrc, va_list ap);
|
||||
unsigned attrc, va_list *ap);
|
||||
int bfcp_msg_encode(struct mbuf *mb, uint8_t ver, bool r, enum bfcp_prim prim,
|
||||
uint32_t confid, uint16_t tid, uint16_t userid,
|
||||
unsigned attrc, ...);
|
||||
|
|
|
@ -148,7 +148,7 @@ static int attr_encode(struct mbuf *mb, bool mand, enum bfcp_attrib type,
|
|||
*
|
||||
* @return 0 if success, otherwise errorcode
|
||||
*/
|
||||
int bfcp_attrs_vencode(struct mbuf *mb, unsigned attrc, va_list ap)
|
||||
int bfcp_attrs_vencode(struct mbuf *mb, unsigned attrc, va_list *ap)
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
|
@ -157,9 +157,9 @@ int bfcp_attrs_vencode(struct mbuf *mb, unsigned attrc, va_list ap)
|
|||
|
||||
for (i=0; i<attrc; i++) {
|
||||
|
||||
int type = va_arg(ap, int);
|
||||
unsigned subc = va_arg(ap, unsigned);
|
||||
const void *v = va_arg(ap, const void *);
|
||||
int type = va_arg(*ap, int);
|
||||
unsigned subc = va_arg(*ap, unsigned);
|
||||
const void *v = va_arg(*ap, const void *);
|
||||
size_t start, len;
|
||||
int err;
|
||||
|
||||
|
@ -221,7 +221,7 @@ int bfcp_attrs_encode(struct mbuf *mb, unsigned attrc, ...)
|
|||
int err;
|
||||
|
||||
va_start(ap, attrc);
|
||||
err = bfcp_attrs_vencode(mb, attrc, ap);
|
||||
err = bfcp_attrs_vencode(mb, attrc, &ap);
|
||||
va_end(ap);
|
||||
|
||||
return err;
|
||||
|
|
|
@ -51,4 +51,4 @@ int bfcp_send(struct bfcp_conn *bc, const struct sa *dst, struct mbuf *mb);
|
|||
bool bfcp_handle_response(struct bfcp_conn *bc, const struct bfcp_msg *msg);
|
||||
int bfcp_vrequest(struct bfcp_conn *bc, const struct sa *dst,
|
||||
enum bfcp_prim prim, uint32_t confid, uint16_t userid,
|
||||
bfcp_resp_h *resph, void *arg, uint32_t attrc, va_list ap);
|
||||
bfcp_resp_h *resph, void *arg, uint32_t attrc, va_list *ap);
|
||||
|
|
|
@ -94,7 +94,7 @@ static int hdr_decode(struct bfcp_msg *msg, struct mbuf *mb)
|
|||
*/
|
||||
int bfcp_msg_vencode(struct mbuf *mb, uint8_t ver, bool r, enum bfcp_prim prim,
|
||||
uint32_t confid, uint16_t tid, uint16_t userid,
|
||||
unsigned attrc, va_list ap)
|
||||
unsigned attrc, va_list *ap)
|
||||
{
|
||||
size_t start, len;
|
||||
int err;
|
||||
|
@ -143,7 +143,7 @@ int bfcp_msg_encode(struct mbuf *mb, uint8_t ver, bool r, enum bfcp_prim prim,
|
|||
|
||||
va_start(ap, attrc);
|
||||
err = bfcp_msg_vencode(mb, ver, r, prim, confid, tid, userid,
|
||||
attrc, ap);
|
||||
attrc, &ap);
|
||||
va_end(ap);
|
||||
|
||||
return err;
|
||||
|
|
|
@ -56,7 +56,7 @@ int bfcp_reply(struct bfcp_conn *bc, const struct bfcp_msg *req,
|
|||
|
||||
va_start(ap, attrc);
|
||||
err = bfcp_msg_vencode(bc->mb, BFCP_VER2, true, prim, req->confid,
|
||||
req->tid, req->userid, attrc, ap);
|
||||
req->tid, req->userid, attrc, &ap);
|
||||
va_end(ap);
|
||||
|
||||
if (err)
|
||||
|
|
|
@ -142,7 +142,7 @@ bool bfcp_handle_response(struct bfcp_conn *bc, const struct bfcp_msg *msg)
|
|||
|
||||
int bfcp_vrequest(struct bfcp_conn *bc, const struct sa *dst,
|
||||
enum bfcp_prim prim, uint32_t confid, uint16_t userid,
|
||||
bfcp_resp_h *resph, void *arg, uint32_t attrc, va_list ap)
|
||||
bfcp_resp_h *resph, void *arg, uint32_t attrc, va_list *ap)
|
||||
{
|
||||
struct bfcp_ctrans *ct;
|
||||
int err;
|
||||
|
@ -220,7 +220,7 @@ int bfcp_request(struct bfcp_conn *bc, const struct sa *dst,
|
|||
|
||||
va_start(ap, attrc);
|
||||
err = bfcp_vrequest(bc, dst, prim, confid, userid, resph, arg,
|
||||
attrc, ap);
|
||||
attrc, &ap);
|
||||
va_end(ap);
|
||||
|
||||
return err;
|
||||
|
@ -248,7 +248,7 @@ int bfcp_notify(struct bfcp_conn *bc, const struct sa *dst,
|
|||
|
||||
va_start(ap, attrc);
|
||||
err = bfcp_vrequest(bc, dst, prim, confid, userid, NULL, NULL,
|
||||
attrc, ap);
|
||||
attrc, &ap);
|
||||
va_end(ap);
|
||||
|
||||
return err;
|
||||
|
|
Loading…
Add table
Reference in a new issue