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

loader: Introduce error code for initialization #617

Merged
merged 1 commit into from
Dec 22, 2021
Merged

Conversation

chfast
Copy link
Member

@chfast chfast commented Dec 20, 2021

Introduce special loader error code EVMC_LOADER_UNSPECIFIED_ERROR
for initializing evmc_loader_error_code objects. This allows defensive
usage pattern where user init error code to a value other than
EVMC_LOADER_SUCCESS what protects against a misbehaving loader
implementation.

Go and Java bindings use new value. Rust bindings do not have EVMC loader support.

@codecov
Copy link

codecov bot commented Dec 20, 2021

Codecov Report

Merging #617 (427a300) into master (0ef6371) will not change coverage.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master     #617   +/-   ##
=======================================
  Coverage   95.73%   95.73%           
=======================================
  Files          24       24           
  Lines        3986     3986           
=======================================
  Hits         3816     3816           
  Misses        170      170           

Introduce special loader error code EVMC_LOADER_UNSPECIFIED_ERROR
for initializing evmc_loader_error_code objects. This allows defensive
usage pattern where user init error code to a value other than
EVMC_LOADER_SUCCESS what protects against a misbehaving loader
implementation.
@@ -21,7 +21,10 @@ extern "C" {
/** The function pointer type for EVMC create functions. */
typedef struct evmc_vm* (*evmc_create_fn)(void);

/** Error codes for the EVMC loader. */
/// Error codes for the EVMC loader.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/// for comments are not used anywhere else in this file

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed, but I wanted to use // everywhere since we enabled C99.

@gumb0
Copy link
Member

gumb0 commented Dec 22, 2021

This allows defensive usage pattern where user init error code to a value other than EVMC_LOADER_SUCCESS what protects against a misbehaving loader implementation.

So as I understand this allows to distinguish "loader did nothing" from "loader returned success".

@chfast
Copy link
Member Author

chfast commented Dec 22, 2021

So as I understand this allows to distinguish "loader did nothing" from "loader returned success".

Yes. This seems better than ec = EVMC_SUCCESS.

@chfast chfast merged commit 9f9d4d8 into master Dec 22, 2021
@chfast chfast deleted the loader_error branch December 22, 2021 19:28
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

Successfully merging this pull request may close these issues.

3 participants