-
Notifications
You must be signed in to change notification settings - Fork 10.6k
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
Getting files C++ compilable #12499
Getting files C++ compilable #12499
Conversation
Jenkins: test this please |
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.
In general, check if the things that you are typecasting have already been typecast the desired way.
@@ -130,9 +130,9 @@ static void fd_global_shutdown(void); | |||
* Pollset Declarations | |||
*/ | |||
|
|||
typedef enum { UNKICKED, KICKED, DESIGNATED_POLLER } kick_state; | |||
typedef enum { UNKICKED, KICKED, DESIGNATED_POLLER } kick_state_t; |
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.
Just curious, what was the motivation for going from kick_state to kick_state_t ? Is this a style guide rule?
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.
And likewise with the other places where _t
is getting appended to struct or enum names.
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.
C++ does not allow same type and variable names. There were cases such as :
kick_state kick_state;
Adding a _t seemed like the easiest way to solve them.
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.
Very neat.
src/core/lib/iomgr/polling_entity.h
Outdated
@@ -22,6 +22,8 @@ | |||
#include "src/core/lib/iomgr/pollset.h" | |||
#include "src/core/lib/iomgr/pollset_set.h" | |||
|
|||
typedef enum pops_tag { POPS_NONE, POPS_POLLSET, POPS_POLLSET_SET } pops_tag; |
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.
Hmm, this abbreviation isn't obvious to me. I think stylistically, non-obvious abbrevations shouldn't be 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've just brought it outside the struct, since C++ does not allow using enum which are inside a struct.
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.
Ah, ok, this is uglier then. Since this is in a header and lives outside of a struct, it is polluting the global namespace. (FWIW, this was probably true even before since C doesn't have the concept of local names afaik, but we didn't particularly notice it for some reason.) Anything in the global namespace needs to be prefixed grpc_
. But I meant that the enum names are ugly. And even these enums should be prefixed GRPC_ .
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.
The grpc_ prefix is for functions as per https://github.com/grpc/grpc/blob/master/doc/c-style-guide.md. But it might make sense ti add I guess we can substitute it with
typedef enum pollset_tag {POLLS_NONE, POLLS_POLLSET, POLLS_POLLSET_SET} pollset_tag;
or
typedef enum grpc_pollset_tag {GRPC_POLLS_NONE, GRPC_POLLS_POLLSET, GRPC_POLLS_POLLSET_SET} grpc_pollset_tag;
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.
Then this is a defect in our C style guide. In practice, all the structs/enums declared in header files have the typename prefixed with grpc_
and all the enum names are also prefixed with GRPC_
. You should go ahead and fix this as typedef enum grpc_pollset_tag ....
etc (your 2nd option above)
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'll fix the style guide.
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.
Thanks Vijay! Done
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 have sent in PR #12519 to fix the style guide (as well as a few places where we weren't actually following the rules)
src/core/lib/surface/call.c
Outdated
@@ -549,8 +549,8 @@ static void destroy_call(grpc_exec_ctx *exec_ctx, void *call, | |||
GRPC_CQ_INTERNAL_UNREF(exec_ctx, c->cq, "bind"); | |||
} | |||
|
|||
get_final_status(call, set_status_value_directly, &c->final_info.final_status, | |||
NULL); | |||
get_final_status((grpc_call *)call, set_status_value_directly, |
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.
Wait, this has already been typecasted to a call as c
above (in line 527)
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.
Yes. Good eye!
src/core/lib/surface/call.c
Outdated
@@ -1474,7 +1475,7 @@ static void receiving_stream_ready(grpc_exec_ctx *exec_ctx, void *bctlp, | |||
* acq_load is in receiving_initial_metadata_ready() */ | |||
if (error != GRPC_ERROR_NONE || call->receiving_stream == NULL || | |||
!gpr_atm_rel_cas(&call->recv_state, RECV_NONE, (gpr_atm)bctlp)) { | |||
process_data_after_md(exec_ctx, bctlp); | |||
process_data_after_md(exec_ctx, (batch_control *)bctlp); |
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.
bctl , right?
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.
Yup
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.
Please address the comments in my previous review...
|
|
BTW, what are the strange commits at the top of this PR? There seem to be commits from Mark and others that are unrelated. Looks to me like your branch base is questionable; can you rebase this to master? |
…o avoid C++ compilation issues
I was trying out git rebase -i. So it intermingled some of the merges. Fixed it. |
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.
LGTM
|
|
Known issues : #11737, (also the fixed INT_MAX issue in flow_control.c) |
_t names are reserved for the language and system libraries afaik... Can we change this to use something else? |
Can change it to explicitly use _type or _enum or something else. What do you suggest? |
_type or _enum would be fine: my expectation is that we'll rename these
again once we start c++-ifying the codebase, but until then we should stay
within spec and the existing style guide.
…On Wed, Sep 13, 2017 at 8:44 AM Yash Tibrewal ***@***.***> wrote:
Can change it to explicitly use _type or _enum or something else. What do
you suggest?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#12499 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AJpudcX8fz_qqvXt-oO0q9cPdftgT2xVks5sh_hMgaJpZM4PT8Wd>
.
|
Created PR #12545 to change _t to _type |
Getting files C++ compilable - Adding pointer conversions, changing variable and type names.