Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API: flux_msg_get_payload() should return const payload pointer #1211

Closed
garlick opened this issue Sep 27, 2017 · 0 comments
Closed

API: flux_msg_get_payload() should return const payload pointer #1211

garlick opened this issue Sep 27, 2017 · 0 comments
Assignees

Comments

@garlick
Copy link
Member

garlick commented Sep 27, 2017

Since payload is the property of const flux_msg_t *, buf should also be const:

int flux_msg_get_payload (const flux_msg_t *msg, int *flags, void **buf, int *size)

Functions based on this one also need const payload arguments:

int flux_request_decode_raw (const flux_msg_t *msg, const char **topic,
                             void **data, int *len);
int flux_response_decode_raw (const flux_msg_t *msg, const char **topic,
                              void **data, int *len);
int flux_rpc_get_raw (flux_future_t *f, void **data, int *len);
int flux_mrpc_get_raw (flux_mrpc_t *mrpc, void **data, int *len);
int flux_content_load_get (flux_future_t *f, void **buf, void **buf, int *len);
@garlick garlick self-assigned this Sep 27, 2017
garlick added a commit to garlick/flux-core that referenced this issue Sep 27, 2017
Problem: flux_msg_get_payload() accepts a a void **
argument that is set to point to the message payload,
but the payload belongs to the const flux_msg_t passed
in as another argument.

Make the payload pointer 'const'.

The following functions, based on the above, are
similarly updated:

flux_request_decode_raw()
flux_response_decode_raw()
flux_rpc_get_raw()
flux_mrpc_get_raw()
flux_content_load_get()

Finally, all users of the above functions are updated.

And a libutil function writeall() parameter was changed
to const as well, since flux-content was using it on
payload returned from flux_content_load_get(), and
anyway it was appropriate there.

Fixes flux-framework#1211
garlick added a commit to garlick/flux-core that referenced this issue Sep 27, 2017
Problem: flux_msg_get_payload() accepts a void **
argument that is set to point to the message payload,
but the payload belongs to the const flux_msg_t *
passed in as another argument.

Make the payload pointer 'const'.

The following functions, based on the above, are
similarly updated:

flux_request_decode_raw()
flux_response_decode_raw()
flux_rpc_get_raw()
flux_mrpc_get_raw()
flux_content_load_get()

Finally, all users of the above functions are updated.

And a libutil function writeall() parameter was changed
to const as well, since flux-content was using it on
payload returned from flux_content_load_get(), and
anyway it was appropriate there.

Fixes flux-framework#1211
@chu11 chu11 closed this as completed in dbea1e0 Sep 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant