diff --git a/Platform/user/rpc/rpc_common.c b/Platform/user/rpc/rpc_common.c index 93d406512..8e6c85d69 100755 --- a/Platform/user/rpc/rpc_common.c +++ b/Platform/user/rpc/rpc_common.c @@ -29,12 +29,16 @@ static int comp_num(const void *lhr, const void *rhr) { } const char* rpc_code_format(const ret_code code) { - struct ec key, *res; - key.code = code; - res = bsearch(&key, err_codes, nr_of_err, sizeof(struct ec), comp_num); - if (res) { - return res->name; - } + struct ec key = {0}; + int i = 0; + + key.code = code; + for(i = 0; i < nr_of_err; i++){ + if(comp_num(&key, &err_codes[i]) == 0){ + return err_codes[i].name; + } + } + return NULL; }