From 5129845658a1d277c22ca1b194ab59afa2d672f9 Mon Sep 17 00:00:00 2001 From: Jonathan Rajotte Date: Mon, 13 Jan 2020 15:40:15 -0500 Subject: [PATCH] Fix: automatic enum value overwrites existing error code value MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Automatic enum value are generated using the last value and incrementing it. Having backward compat assignation before the LTTNG_ERR_NR would end up overwriting the error string since the LTTNG_ERR_NR value would be LTTNG_ERR_PID_NOT_TRACKED + 1. Signed-off-by: Jonathan Rajotte Change-Id: I4076866a28961fa49eed018e8249d2cd72979a84 Signed-off-by: Jérémie Galarneau --- include/lttng/lttng-error.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/include/lttng/lttng-error.h b/include/lttng/lttng-error.h index bddd39d78..ea2d6eb25 100644 --- a/include/lttng/lttng-error.h +++ b/include/lttng/lttng-error.h @@ -183,11 +183,12 @@ enum lttng_error_code { LTTNG_ERR_USER_NOT_FOUND = 160, /* User not found. */ LTTNG_ERR_GROUP_NOT_FOUND = 161, /* Group not found. */ + /* MUST be last element of the manually-assigned section of the enum */ + LTTNG_ERR_NR, + + /* Backward-compatibility assignments */ LTTNG_ERR_PID_TRACKED = LTTNG_ERR_ID_TRACKED, /* Backward compat alias to LTTNG_ERR_ID_TRACKED */ LTTNG_ERR_PID_NOT_TRACKED = LTTNG_ERR_ID_NOT_TRACKED, /* Backward compat alias to LTTNG_ERR_ID_NOT_TRACKED */ - - /* MUST be last element */ - LTTNG_ERR_NR, /* Last element */ }; /* -- 2.34.1