Skip to content

Commit

Permalink
linter
Browse files Browse the repository at this point in the history
Signed-off-by: Bruno Vavala <bruno.vavala@intel.com>
  • Loading branch information
bvavala committed Jul 16, 2020
1 parent 7f7f3d0 commit 2c7edd9
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 35 deletions.
34 changes: 17 additions & 17 deletions ecc/enclave/enclave_stub.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions ecc_enclave/enclave/shim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ void get_public_state_by_partial_composite_key(
int get_string_args(std::vector<std::string>& 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;
Expand All @@ -287,7 +287,7 @@ int get_func_and_params(
std::string& func_name, std::vector<std::string>& 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;
Expand Down
8 changes: 2 additions & 6 deletions ecc_enclave/enclave/shim.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
//-------------------------------------------------
Expand Down
15 changes: 5 additions & 10 deletions ecc_enclave/sgxcclib/sgxcclib.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 <stdbool.h>
#include <string.h>
Expand All @@ -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,
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -126,4 +122,3 @@ void ocall_print_string(const char* str)
{
golog(str);
}

0 comments on commit 2c7edd9

Please sign in to comment.