From 2c7edd9e5b93e3099beab418d5ba3c3a61e1f84b Mon Sep 17 00:00:00 2001 From: Bruno Vavala Date: Wed, 15 Jul 2020 23:49:08 -0700 Subject: [PATCH] linter Signed-off-by: Bruno Vavala --- ecc/enclave/enclave_stub.go | 34 ++++++++++++++++----------------- ecc_enclave/enclave/shim.cpp | 4 ++-- ecc_enclave/enclave/shim.h | 8 ++------ ecc_enclave/sgxcclib/sgxcclib.c | 15 +++++---------- 4 files changed, 26 insertions(+), 35 deletions(-) diff --git a/ecc/enclave/enclave_stub.go b/ecc/enclave/enclave_stub.go index 3ce072046..3614c3b1b 100644 --- a/ecc/enclave/enclave_stub.go +++ b/ecc/enclave/enclave_stub.go @@ -140,27 +140,27 @@ var _logger = func(in string) { //export get_channel_id func get_channel_id(channel_id *C.char, max_channel_id_len C.uint32_t, ctx unsafe.Pointer) { - stubs := registry.Get(*(*int)(ctx)) - channelIdStr := stubs.shimStub.GetChannelID() - if len(channelIdStr) > int(max_channel_id_len) { - panic(fmt.Sprintf("error: insufficient buffer (len=%d) for channel id string (len=%d)", len(channelIdStr), int(max_channel_id_len))) - } - C._cpy_str(channel_id, channelIdStr, max_channel_id_len) + stubs := registry.Get(*(*int)(ctx)) + channelIdStr := stubs.shimStub.GetChannelID() + if len(channelIdStr) > int(max_channel_id_len) { + panic(fmt.Sprintf("error: insufficient buffer (len=%d) for channel id string (len=%d)", len(channelIdStr), int(max_channel_id_len))) + } + C._cpy_str(channel_id, channelIdStr, max_channel_id_len) } //export get_msp_id func get_msp_id(msp_id *C.char, max_msp_id_len C.uint32_t, ctx unsafe.Pointer) { - //stubs := registry.Get(*(*int)(ctx)) - //mspIdStr, err := cid.GetMSPID(stubs.shimStub) - mspIdStr, err := shim.GetMSPID() - if err != nil { - logger.Infof("CORE_PEER_LOCALMSPID env var not set, returning empty mspid") - mspIdStr = "" - } - if len(mspIdStr) > int(max_msp_id_len) { - panic(fmt.Sprintf("error: insufficient buffer (len=%d) for channel id string (len=%d)", len(mspIdStr), int(max_msp_id_len))) - } - C._cpy_str(msp_id, mspIdStr, max_msp_id_len) + //stubs := registry.Get(*(*int)(ctx)) + //mspIdStr, err := cid.GetMSPID(stubs.shimStub) + mspIdStr, err := shim.GetMSPID() + if err != nil { + logger.Infof("CORE_PEER_LOCALMSPID env var not set, returning empty mspid") + mspIdStr = "" + } + if len(mspIdStr) > int(max_msp_id_len) { + panic(fmt.Sprintf("error: insufficient buffer (len=%d) for channel id string (len=%d)", len(mspIdStr), int(max_msp_id_len))) + } + C._cpy_str(msp_id, mspIdStr, max_msp_id_len) } //export get_creator_name diff --git a/ecc_enclave/enclave/shim.cpp b/ecc_enclave/enclave/shim.cpp index ba1313346..b3bc8251c 100644 --- a/ecc_enclave/enclave/shim.cpp +++ b/ecc_enclave/enclave/shim.cpp @@ -263,7 +263,7 @@ void get_public_state_by_partial_composite_key( int get_string_args(std::vector& argss, shim_ctx_ptr_t ctx) { JSON_Value* root = json_parse_string(ctx->json_args); - if(root == NULL) + if (root == NULL) { LOG_ERROR("Shim: Cannot parse json"); return -1; @@ -287,7 +287,7 @@ int get_func_and_params( std::string& func_name, std::vector& params, shim_ctx_ptr_t ctx) { JSON_Value* root = json_parse_string(ctx->json_args); - if(root == NULL) + if (root == NULL) { LOG_ERROR("Shim: Cannot parse json"); return -1; diff --git a/ecc_enclave/enclave/shim.h b/ecc_enclave/enclave/shim.h index 58b7d32a5..2af31bf68 100644 --- a/ecc_enclave/enclave/shim.h +++ b/ecc_enclave/enclave/shim.h @@ -231,17 +231,13 @@ extern int get_random_bytes(uint8_t* buffer, size_t length); // -------------- // returns the channel id string. // The channel id might be truncated if the buffer size is not large enough. -void get_channel_id(char* channel_id, - uint32_t max_msp_id_len, - shim_ctx_ptr_t ctx); +void get_channel_id(char* channel_id, uint32_t max_msp_id_len, shim_ctx_ptr_t ctx); // get_msp_id // -------------- // returns the msp id string. // The msp id might be truncated if the buffer size is not large enough. -void get_msp_id(char* msp_id, - uint32_t max_msp_id_len, - shim_ctx_ptr_t ctx); +void get_msp_id(char* msp_id, uint32_t max_msp_id_len, shim_ctx_ptr_t ctx); // logging //------------------------------------------------- diff --git a/ecc_enclave/sgxcclib/sgxcclib.c b/ecc_enclave/sgxcclib/sgxcclib.c index 4a295deea..23a9cf79e 100644 --- a/ecc_enclave/sgxcclib/sgxcclib.c +++ b/ecc_enclave/sgxcclib/sgxcclib.c @@ -7,8 +7,8 @@ #include "sgxcclib.h" #include "common-sgxcclib.h" //CHECK_SGX_ERROR_AND_RETURN_ON_ERROR macro -#include "sgx_attestation_type.h" #include "enclave_u.h" +#include "sgx_attestation_type.h" #include #include @@ -25,12 +25,10 @@ extern void get_creator_name( const char* msp_id, uint32_t max_msp_id_len, const char* dn, uint32_t max_dn_len, void* ctx); // - channel id -extern void get_channel_id( - const char* channel_id, uint32_t max_channel_id_len, void* ctx); +extern void get_channel_id(const char* channel_id, uint32_t max_channel_id_len, void* ctx); // - msp id -extern void get_msp_id( - const char* msp_id, uint32_t max_msp_id_len, void* ctx); +extern void get_msp_id(const char* msp_id, uint32_t max_msp_id_len, void* ctx); // - for accessing ledger kvs extern void get_state(const char* key, @@ -84,14 +82,12 @@ void ocall_get_creator_name( get_creator_name(msp_id, max_msp_id_len, dn, max_dn_len, ctx); } -void ocall_get_channel_id( - char* channel_id, uint32_t max_channel_id_len, void* ctx) +void ocall_get_channel_id(char* channel_id, uint32_t max_channel_id_len, void* ctx) { get_channel_id(channel_id, max_channel_id_len, ctx); } -void ocall_get_msp_id( - char* msp_id, uint32_t max_msp_id_len, void* ctx) +void ocall_get_msp_id(char* msp_id, uint32_t max_msp_id_len, void* ctx) { get_msp_id(msp_id, max_msp_id_len, ctx); } @@ -126,4 +122,3 @@ void ocall_print_string(const char* str) { golog(str); } -