-
Notifications
You must be signed in to change notification settings - Fork 16
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
[ovsp4rt] Update C++ API functions to return absl::Status #734
Conversation
- Renamed the functions in the internal C++ API from ConfigEntry to DoConfigEntry, to keep them from being confused with ConfigTableEntry functions. The conventions are: - A PrepareTableEntry function populates the fields of a TableEntry. - A ConfigTableEntry function initializes a WriteRequest, prepares the TableEntry, and sends the request to the P4Runtime server. - A GetTableEntry function initializes a ReadRequest, prepares the TableEntry, sends the request to the P4Runtime server, and returns the response. - A DoConfigEntry function implements the core logic of an ovsp4rt_table_entry C API. It may make one or more ConfigTableEntry or GetTableEntry calls. Signed-off-by: Derek Foster <[email protected]>
Signed-off-by: Derek Foster <[email protected]>
Signed-off-by: Derek Foster <[email protected]>
- Modified the functions in the internal C++ API to return absl::Status. Explicitly ignored return status in the C API wrappers. Status is currently for use in testing. Note that issue #618 proposes that public APIs should return status. - Moved ovsp4rt_str_to_tunnel_type() to a separate source file for C api functions that are not wrappers. Signed-off-by: Derek Foster <[email protected]>
ee1d642
to
1317ec2
Compare
Signed-off-by: Derek Foster <[email protected]>
// Ignore errors (why?) | ||
} | ||
// Ignore errors (why?) | ||
(void)ConfigFdbTunnelTableEntry(client, learn_info, p4info, insert_entry); |
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.
Is the (void)
addition to suppress compiler warnings?
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. It is also a way of telling the reader that we are ignoring the value returned by the function.
The comment is shorthand for "the original developer did this, and it's probably a defect; but we don't know that for sure, and we either don't have the time or are too scared to change it right now. We will, however, leave this comment as a sort of a 'danger, thin ice' warning, for the benefit of future developers." It's kind of like inserting [sic] into a document you're editing.🙄
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
absl::Status
, allowing test programs to verify whether the function encountered an error.void
return type.These changes only apply when BUILD_CLIENT is enabled.
Note
Issue #618 proposes that the public APIs should return status. The Status returned by the core APIs will give them the means to do so, should we decide to implement this change.