summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
dc325c1)
Re-implement lttng_ust_strerr based on the tools internal
implementation.
* Require a negative error code from enum lttng_ust_error_code or zero
* Don't handle negative error codes as system errors anymore
Change-Id: I89a95f4f6b0c392c8fa7bdb3ad40a8d6ea918acf
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- * Return a human-readable error message for an lttng-ust error code.
- * code must be a positive value (or 0).
+ * lttng_ust_strerror
+ * @code: must be a negative value of enum lttng_ust_error_code (or 0).
+ *
+ * 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);
*/
const char *lttng_ust_strerror(int code);
+ * @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)
{
*/
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)
return ustcomm_readable_code[USTCOMM_CODE_OFFSET(code)];
}
return ustcomm_readable_code[USTCOMM_CODE_OFFSET(code)];
}