-
Notifications
You must be signed in to change notification settings - Fork 51
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
Flux request decode raw fix #1144
Flux request decode raw fix #1144
Conversation
Fix the type of the "data" parameter in the flux_request_decode_raw(). In all uses, "data" is a the address of a pointer, so "void **data" is the correct type. This makes it fairly clear that the buffer will be provided by flux_request_decode_raw() rather than by the caller.
Fix the documentation of the "len" paramter in the flux_request_encode_raw() function. It is an int, not a pointer. Also expand the explanation a little bit.
@@ -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); | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think you meant to change flux_request_encode_raw
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh whoops, nevermind. This is a typo fix, not a change related to the other stuff.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, just along for the ride, sorry. :)
LGTM, nice catch. |
I brought up this issue with @garlick awhile back. Looking through old e-mails we never came to a conclusion. I believe it was initially programmed this way to avoid |
@@ -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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I may be so very wrong about wanting to do this, but it was quite on purpose, and the reason the result parameter is defined as a void *
instead of a void **
is so that the user doesn't have to do something like
const char *data;
int len;
flux_request_decode_raw (msg, NULL, (void **)&data, &len);
in virtually every place this function is used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I should temper that comment with the observation that now it doesn't seem all that wonderful an idea. What do others think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For me, when I first looked at:
int flux_request_decode_raw (const flux_msg_t *msg, const char **topic,
void *data, int *len);
and compared it to
flux_msg_t *flux_request_encode_raw (const char *topic,
const void *data, int len);
My thought was "how come topic & len are in & out parameters, but not data?" You would think it should be a void **
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the cast to (void **)
is not so bad for increased clarity in the prototype.
If it becomes too onerous a user can create a wrapper function so at most we'd see the case once per file/module.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, sounds like @grondo already acked so let's fix this. Want to go ahead and also fix:
int flux_msg_get_payload (const flux_msg_t *msg, int *flags,
void *buf, int *size);
int flux_mrpc_get_raw (flux_mrpc_t *mrpc, void *data, int *len);
int flux_rpc_get_raw (flux_future_t *f, void *data, int *len);
int flux_response_decode_raw (const flux_msg_t *msg, const char **topic,
void *data, int *len);
for consistency?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 forgot about those.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I can work on those others.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@chu11: just changed prototypes for treeobj_decode_val()
and flux_kvs_lookup_get_raw()
in the branch we're working on and pushed.
Some checks in Travis failed and I'm restarting them. I saw another case of |
As discussed in flux-framework#1144, function result parameters like the one in treeobj_decode_val() should probably be void ** not void *.
As discussed in flux-framework#1144, function result parameters like the one in flux_kvs_lookup_get_raw() should probably be void ** not void *.
The function want to return a pointer to a buffer in one of its parameters, so that parameter should be a void ** rather than a void *.
Codecov Report
@@ Coverage Diff @@
## master #1144 +/- ##
==========================================
+ Coverage 77.61% 77.63% +0.02%
==========================================
Files 157 157
Lines 28679 28680 +1
==========================================
+ Hits 22260 22267 +7
+ Misses 6419 6413 -6
|
OK, I added a couple of commits to this pull requires to address these five functions: flux_msg_get_payload |
doc/man3/tmrpc_then
Outdated
@@ -0,0 +1,228 @@ | |||
#! /bin/bash |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you accidentally git add this file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doh. Fixed.
The functions want to return a pointer to a buffer in one of its parameters, so that parameter should be a void ** rather than a void *. The following functions are converted: flux_rpc_get_raw flux_response_decode_raw flux_content_load_get flux_mrpc_get_raw
restarted travis since it failed to update status of the PR and GitHub wouldn't let me press the button. |
As discussed in flux-framework#1144, function result parameters like the one in treeobj_decode_val() should probably be void ** not void *.
As discussed in flux-framework#1144, function result parameters like the one in flux_kvs_lookup_get_raw() should probably be void ** not void *.
In flux_future_get, convert void * parameter to void ** parameter, consistent to fixes done in flux-framework#1144 and flux-framework#1212. Fixes flux-framework#1602
In flux_future_get, convert void * parameter to void ** parameter, consistent to fixes done in flux-framework#1144 and flux-framework#1212. Fixes flux-framework#1602
No description provided.