Skip to content

headers: Add macro to print error code as string - #366

Open
johnandersen777 wants to merge 1 commit into
intel:mainfrom
johnandersen777:patch-1
Open

headers: Add macro to print error code as string#366
johnandersen777 wants to merge 1 commit into
intel:mainfrom
johnandersen777:patch-1

Conversation

@johnandersen777

Copy link
Copy Markdown
  • Adds a PRINT_SGX_STATUS macro to sgx_error.h which prints
    the sgx_status_t as a string.

* Adds a PRINT_SGX_STATUS macro to sgx_error.h which prints
  the sgx_status_t as a string.
@johnandersen777

johnandersen777 commented Jan 23, 2019

Copy link
Copy Markdown
Author

Generated with:

(
echo -e '#define PRINT_SGX_STATUS(FILE_STRUCT, STATUS_T) \\\n    switch (STATUS_T) {\\';
for error in $(grep -E '=.*SGX_MK_ERROR' /opt/intel/sgxsdk/include/sgx_error.h | awk '{print $1}' | sed 's/=//g'); do
  printf '    case %s:\\\n        fprintf(FILE_STRUCT, "Error: %s\\n");\\\n        break;\\\n' $error $error;
done;
echo -e '    }'
)

@johnandersen777

Copy link
Copy Markdown
Author

maybe this would be better as something similar to perror called sgx_perror or something. Where it acts just as perror does but for sgx_status_t errors

@sergefdrv

Copy link
Copy Markdown

Might be even better to make it similar to strerror, for fine control of output. Think of advanced logging mechanism.

@johnandersen777

Copy link
Copy Markdown
Author

Ya that is probably a better option, I think that's what was started in #346 perhaps that PR should be one PR introducing the strerror and another adding the logging to various places.

@johnandersen777

Copy link
Copy Markdown
Author

@Icaro-Lima

Copy link
Copy Markdown
Contributor

Hello, I was disinclined to continue working on my pull request after the comment from the Intel member himself saying that maybe it did not help much. And I still maintain my position, I think it is very important and avoids many lines of unnecessary codes that will be inserted in each enclave.

@johnandersen777

Copy link
Copy Markdown
Author

I agree. As I posted above something similar was done in the sample enclave code. If its useful there then it is of course useful and instead of duplicating that functionality it should be a part of the SDK.

@taraxacum45e9a

Copy link
Copy Markdown

I believe that it's a really useful patch.
FYI, here's how I did the same thing.

https://pastebin.com/PT4Ds8WQ

@bot-cc1s-branch-sync

Copy link
Copy Markdown
Contributor

Important

🔀 The Intel® SGX SDK codebase has moved

Thank you for your contribution!
The code this pull request modifies now resides in a new repository,1 so, unfortunately, it can no longer be merged here as-is. If your change is still relevant, please re-open it against the SDK repository, where this code is now maintained.

If you have any questions or need assistance migrating, please ask here. As we complete the migration, older pull requests may eventually be closed. No work is lost, though, and you are welcome to re-open your change in the new repository at any time.

Footnotes

  1. The affected sources were migrated from confidential-computing.sgx to the dedicated confidential-computing.sgx.sdk repo. The migration covered the SDK sources (sdk/), shared headers (common/), samples (SampleCode/), and the runtime libraries (psw/urts, psw/enclave_common).

@bot-cc1s-branch-sync bot-cc1s-branch-sync added the repo-migration PR whose files moved to the SGX SDK repo (needs re-targeting) label Aug 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

repo-migration PR whose files moved to the SGX SDK repo (needs re-targeting)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants