X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;ds=sidebyside;f=liblttng-ust-comm%2Flttng-ust-comm.c;h=8141ace369731e3024496f4582e803ebc84c3f9a;hb=d6d2eb792414485fa36c6c473f74235840c678d7;hp=0b6aa293c696516cbaa5a101dd96a983cad3a151;hpb=dc325c1d762bbbdc1866e590f4649078f8600664;p=lttng-ust.git diff --git a/liblttng-ust-comm/lttng-ust-comm.c b/liblttng-ust-comm/lttng-ust-comm.c index 0b6aa293..8141ace3 100644 --- a/liblttng-ust-comm/lttng-ust-comm.c +++ b/liblttng-ust-comm/lttng-ust-comm.c @@ -70,19 +70,18 @@ static const char *ustcomm_readable_code[] = { /* * lttng_ust_strerror + * @code: must be a negative value of enum lttng_ust_error_code (or 0). * - * Receives positive error value. - * Return ptr to string representing a human readable - * error code from the ustcomm_return_code enum. + * Returns a ptr to a string representing a human readable error code from the + * ustcomm_return_code enum. */ const char *lttng_ust_strerror(int code) { - if (code == LTTNG_UST_OK) - return ustcomm_readable_code[USTCOMM_CODE_OFFSET(code)]; - if (code < LTTNG_UST_ERR) - return strerror(code); - if (code >= LTTNG_UST_ERR_NR) + code = -code; + + if (code < LTTNG_UST_OK || code >= LTTNG_UST_ERR_NR) code = LTTNG_UST_ERR; + return ustcomm_readable_code[USTCOMM_CODE_OFFSET(code)]; }