Skip to content

Commit

Permalink
Merge pull request #1144 from morrone/flux_request_decode_raw_fix
Browse files Browse the repository at this point in the history
Change void * to void ** in flux_msg_get_payload
  • Loading branch information
grondo authored Aug 10, 2017
2 parents 0abcd67 + 45f5341 commit 1665912
Show file tree
Hide file tree
Showing 27 changed files with 40 additions and 34 deletions.
2 changes: 1 addition & 1 deletion doc/man3/flux_content_load.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ SYNOPSIS
int flags);

int flux_content_load_get (flux_future_t *f,
void *buf,
void **buf,
size_t *len);


Expand Down
2 changes: 1 addition & 1 deletion doc/man3/flux_mrpc.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ int flux_mrpc_get (flux_mrpc_t *mrpc, const char **json_str);
int flux_mrpc_getf (flux_mrpc_t *mrpc, const char *fmt, ...);
int flux_mrpc_get_raw (flux_mrpc_t *mrpc, void *data, int *len);
int flux_mrpc_get_raw (flux_mrpc_t *mrpc, void **data, int *len);
int flux_mrpc_get_nodeid (flux_mrpc_t *mrpc, uint32_t *nodeid);
Expand Down
2 changes: 1 addition & 1 deletion doc/man3/flux_request_decode.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ SYNOPSIS

int flux_request_decode_raw (const flux_msg_t *msg,
const char **topic,
void *data, int *len);
void **data, int *len);

DESCRIPTION
-----------
Expand Down
5 changes: 3 additions & 2 deletions doc/man3/flux_request_encode.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ SYNOPSIS
const char *json_str);

flux_msg_t *flux_request_encode_raw (const char *topic,
void *data, int *len);
void *data, int len);

DESCRIPTION
-----------
Expand All @@ -26,7 +26,8 @@ _topic_ and optional JSON payload _json_str_. The newly constructed
message that is returned must be destroyed with `flux_msg_destroy()`.
`flux_request_encode_raw()` encodes a request message with topic
string _topic_. If _data_ is non-NULL assign the raw payload.
string _topic_. If _data_ is non-NULL its contents will be used
as the message payload, and the payload type set to raw.
RETURN VALUE
Expand Down
2 changes: 1 addition & 1 deletion doc/man3/flux_response_decode.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ SYNOPSIS

int flux_response_decode_raw (const flux_msg_t *msg,
const char **topic,
void *data, int *len);
void **data, int *len);

DESCRIPTION
-----------
Expand Down
2 changes: 1 addition & 1 deletion doc/man3/flux_rpc.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ SYNOPSIS

int flux_rpc_get_unpack (flux_future_t *f, const char *fmt, ...);

int flux_rpc_get_raw (flux_future_t *f, void *data, int *len);
int flux_rpc_get_raw (flux_future_t *f, void **data, int *len);


DESCRIPTION
Expand Down
3 changes: 2 additions & 1 deletion src/broker/content-cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,8 @@ void content_load_request (flux_t *h, flux_msg_handler_t *w,
int saved_errno = 0;
int rc = -1;

if (flux_request_decode_raw (msg, NULL, &blobref, &blobref_size) < 0) {
if (flux_request_decode_raw (msg, NULL, (void **)&blobref,
&blobref_size) < 0) {
saved_errno = errno;
goto done;
}
Expand Down
2 changes: 1 addition & 1 deletion src/broker/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ static void append_request_cb (flux_t *h, flux_msg_handler_t *w,
log_msg ("%s: malformed log request", __FUNCTION__);
return;
}
if (flux_request_decode_raw (msg, NULL, &buf, &len) < 0)
if (flux_request_decode_raw (msg, NULL, (void **)&buf, &len) < 0)
goto error;
if (logbuf_append (logbuf, buf, len) < 0)
goto error;
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/builtin/content.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ static int internal_content_load (optparse_t *p, int ac, char *av[])
flags |= CONTENT_FLAG_CACHE_BYPASS;
if (!(f = flux_content_load (h, ref, flags)))
log_err_exit ("flux_content_load");
if (flux_content_load_get (f, &data, &size) < 0)
if (flux_content_load_get (f, (void **)&data, &size) < 0)
log_err_exit ("flux_content_load_get");
if (write_all (STDOUT_FILENO, data, size) < 0)
log_err_exit ("write");
Expand Down
4 changes: 2 additions & 2 deletions src/common/libflux/content.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ flux_future_t *flux_content_load (flux_t *h, const char *blobref, int flags)
return flux_rpc_raw (h, topic, blobref, strlen (blobref) + 1, rank, 0);
}

int flux_content_load_get (flux_future_t *f, void *buf, int *len)
int flux_content_load_get (flux_future_t *f, void **buf, int *len)
{
return flux_rpc_get_raw (f, buf, len);
}
Expand All @@ -76,7 +76,7 @@ int flux_content_store_get (flux_future_t *f, const char **blobref)
int ref_size;
const char *ref;

if (flux_rpc_get_raw (f, &ref, &ref_size) < 0)
if (flux_rpc_get_raw (f, (void **)&ref, &ref_size) < 0)
return -1;
if (!ref || ref[ref_size - 1] != '\0' || blobref_validate (ref) < 0) {
errno = EPROTO;
Expand Down
2 changes: 1 addition & 1 deletion src/common/libflux/content.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ flux_future_t *flux_content_load (flux_t *h,
* Storage for 'buf' belongs to 'f' and is valid until 'f' is destroyed.
* Returns 0 on success, -1 on failure with errno set.
*/
int flux_content_load_get (flux_future_t *f, void *buf, int *len);
int flux_content_load_get (flux_future_t *f, void **buf, int *len);

/* Send request to store blob.
*/
Expand Down
4 changes: 2 additions & 2 deletions src/common/libflux/message.c
Original file line number Diff line number Diff line change
Expand Up @@ -1061,7 +1061,7 @@ int flux_msg_pack (flux_msg_t *msg, const char *fmt, ...)
return rc;
}

int flux_msg_get_payload (const flux_msg_t *msg, int *flags, void *buf, int *size)
int flux_msg_get_payload (const flux_msg_t *msg, int *flags, void **buf, int *size)
{
zframe_t *zf;
uint8_t msgflags;
Expand Down Expand Up @@ -1090,7 +1090,7 @@ int flux_msg_get_payload (const flux_msg_t *msg, int *flags, void *buf, int *siz
if (flags)
*flags = msgflags & FLUX_MSGFLAG_JSON;
if (buf)
*(void **)buf = zframe_data (zf);
*buf = zframe_data (zf);
if (size)
*size = zframe_size (zf);
return 0;
Expand Down
2 changes: 1 addition & 1 deletion src/common/libflux/message.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ int flux_msg_get_topic (const flux_msg_t *msg, const char **topic);
* Flags can be 0 or FLUX_MSGFLAG_JSON (hint for decoding).
*/
int flux_msg_get_payload (const flux_msg_t *msg, int *flags,
void *buf, int *size);
void **buf, int *size);
int flux_msg_set_payload (flux_msg_t *msg, int flags,
const void *buf, int size);
bool flux_msg_has_payload (const flux_msg_t *msg);
Expand Down
2 changes: 1 addition & 1 deletion src/common/libflux/mrpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ int flux_mrpc_get (flux_mrpc_t *mrpc, const char **json_str)
return rc;
}

int flux_mrpc_get_raw (flux_mrpc_t *mrpc, void *data, int *len)
int flux_mrpc_get_raw (flux_mrpc_t *mrpc, void **data, int *len)
{
int rc = -1;

Expand Down
2 changes: 1 addition & 1 deletion src/common/libflux/mrpc.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ int flux_mrpc_get_nodeid (flux_mrpc_t *mrpc, uint32_t *nodeid);
* or flux_mrpc_next().
* Returns 0 on success, or -1 on failure with errno set.
*/
int flux_mrpc_get_raw (flux_mrpc_t *mrpc, void *data, int *len);
int flux_mrpc_get_raw (flux_mrpc_t *mrpc, void **data, int *len);

/* Arrange for reactor to handle response and call 'cb' continuation function
* when a response is received. The function should call flux_mrpc_get().
Expand Down
4 changes: 2 additions & 2 deletions src/common/libflux/request.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ int flux_request_decode (const flux_msg_t *msg, const char **topic,
}

int flux_request_decode_raw (const flux_msg_t *msg, const char **topic,
void *data, int *len)
void **data, int *len)
{
const char *ts;
void *d = NULL;
Expand All @@ -95,7 +95,7 @@ int flux_request_decode_raw (const flux_msg_t *msg, const char **topic,
}
if (topic)
*topic = ts;
*(void **)data = d;
*data = d;
*len = l;
rc = 0;
done:
Expand Down
2 changes: 1 addition & 1 deletion src/common/libflux/request.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ int flux_request_unpack (const flux_msg_t *msg, const char **topic,
* Returns 0 on success, or -1 on failure with errno set.
*/
int flux_request_decode_raw (const flux_msg_t *msg, const char **topic,
void *data, int *len);
void **data, int *len);

/* Encode a request message.
* If json_str is non-NULL, assign the json payload.
Expand Down
4 changes: 2 additions & 2 deletions src/common/libflux/response.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ int flux_response_decode (const flux_msg_t *msg, const char **topic,
}

int flux_response_decode_raw (const flux_msg_t *msg, const char **topic,
void *data, int *len)
void **data, int *len)
{
const char *ts;
void *d = NULL;
Expand All @@ -106,7 +106,7 @@ int flux_response_decode_raw (const flux_msg_t *msg, const char **topic,
}
if (topic)
*topic = ts;
*(void **)data = d;
*data = d;
*len = l;
rc = 0;
done:
Expand Down
2 changes: 1 addition & 1 deletion src/common/libflux/response.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ int flux_response_decode (const flux_msg_t *msg, const char **topic,
* Returns 0 on success, or -1 on failure with errno set.
*/
int flux_response_decode_raw (const flux_msg_t *msg, const char **topic,
void *data, int *len);
void **data, int *len);

flux_msg_t *flux_response_encode (const char *topic, int errnum,
const char *json_str);
Expand Down
2 changes: 1 addition & 1 deletion src/common/libflux/rpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ int flux_rpc_get (flux_future_t *f, const char **json_str)
return rc;
}

int flux_rpc_get_raw (flux_future_t *f, void *data, int *len)
int flux_rpc_get_raw (flux_future_t *f, void **data, int *len)
{
const flux_msg_t *msg;
int rc = -1;
Expand Down
2 changes: 1 addition & 1 deletion src/common/libflux/rpc.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ int flux_rpc_get (flux_future_t *f, const char **json_str);

int flux_rpc_get_unpack (flux_future_t *f, const char *fmt, ...);

int flux_rpc_get_raw (flux_future_t *f, void *data, int *len);
int flux_rpc_get_raw (flux_future_t *f, void **data, int *len);


#endif /* !_FLUX_CORE_RPC_H */
Expand Down
2 changes: 1 addition & 1 deletion src/common/libflux/test/message.c
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ void check_copy (void)
const char *topic;
int cpylen, flags;
char buf[] = "xxxxxxxxxxxxxxxxxx";
char *cpybuf;
void *cpybuf;

ok ((msg = flux_msg_create (FLUX_MSGTYPE_KEEPALIVE)) != NULL,
"created no-payload keepalive");
Expand Down
3 changes: 2 additions & 1 deletion src/common/libflux/test/request.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ int main (int argc, char *argv[])
flux_msg_t *msg;
const char *topic, *s;
const char *json_str = "{\"a\":42}";
char *d, data[] = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
void *d;
char data[] = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
int i, l, len = strlen (data);

plan (NO_PLAN);
Expand Down
3 changes: 2 additions & 1 deletion src/common/libflux/test/response.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ int main (int argc, char *argv[])
flux_msg_t *msg;
const char *topic, *s;
const char *json_str = "{\"a\":42}";
char *d, data[] = "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb";
void *d;
char data[] = "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb";
int l, len = strlen (data);

plan (NO_PLAN);
Expand Down
5 changes: 3 additions & 2 deletions src/modules/content-sqlite/content-sqlite.c
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,8 @@ void load_cb (flux_t *h, flux_msg_handler_t *w,
int uncompressed_size;
int rc = -1;

if (flux_request_decode_raw (msg, NULL, &blobref, &blobref_size) < 0) {
if (flux_request_decode_raw (msg, NULL, (void **)&blobref,
&blobref_size) < 0) {
flux_log_error (h, "load: request decode failed");
goto done;
}
Expand Down Expand Up @@ -480,7 +481,7 @@ void shutdown_cb (flux_t *h, flux_msg_handler_t *w,
flux_log_error (h, "shutdown: store");
continue;
}
if (flux_rpc_get_raw (f, &blobref, &blobref_size) < 0) {
if (flux_rpc_get_raw (f, (void **)&blobref, &blobref_size) < 0) {
flux_log_error (h, "shutdown: store");
flux_future_destroy (f);
continue;
Expand Down
4 changes: 2 additions & 2 deletions src/modules/kvs/kvs.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ static int content_load_get (flux_future_t *f, void *arg)
{
kvs_ctx_t *ctx = arg;
json_t *o;
const void *data;
void *data;
int size;
const char *blobref;
struct cache_entry *hp;
Expand Down Expand Up @@ -332,7 +332,7 @@ static int content_store_get (flux_future_t *f, void *arg)
int rc = -1;
int saved_errno, ret;

if (flux_rpc_get_raw (f, &blobref, &blobref_size) < 0) {
if (flux_rpc_get_raw (f, (void **)&blobref, &blobref_size) < 0) {
saved_errno = errno;
flux_log_error (ctx->h, "%s: flux_rpc_get_raw", __FUNCTION__);
goto done;
Expand Down
3 changes: 2 additions & 1 deletion t/rpc/rpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,8 @@ void test_encoding (flux_t *h)
flux_future_destroy (r);

/* working with-payload RPC (raw) */
char *d, data[] = "aaaaaaaaaaaaaaaaaaaa";
void *d;
char data[] = "aaaaaaaaaaaaaaaaaaaa";
int l, len = strlen (data);
ok ((r = flux_rpc_raw (h, "rpctest.rawecho", data, len,
FLUX_NODEID_ANY, 0)) != NULL,
Expand Down

0 comments on commit 1665912

Please sign in to comment.