Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename error ids #25

Merged
merged 1 commit into from
Dec 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions include/ttt-impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ TTT_INTERN int ttt_log_(ttt_log_type_t type, int error_no, const char *fmt,
* @brief Wrapper macro around the ttt_log_() function.
*
* @param type Log type.
* @param error_no Error number or id (e.g., TTT_INVALID_USER_INPUT).
* @param error_no Error number or id (e.g., TTT_ERROR_INVALID_INPUT).
* @param ... printf() like format string for the log message and relevant
* arguments (if any).
*/
Expand Down Expand Up @@ -183,7 +183,7 @@ TTT_INTERN int ttt_log_finalize(void);
*/
#define ttt_check_ptr(ptr) \
{ \
ttt_error(ptr == NULL, TTT_INVALID_USER_INPUT, \
ttt_error(ptr == NULL, TTT_ERROR_INVALID_INPUT, \
"Pointer passed to ttt API call is NULL"); \
}

Expand All @@ -197,7 +197,7 @@ TTT_INTERN int ttt_log_finalize(void);
#define ttt_check_ptr2(ptr) \
{ \
ttt_error( \
*ptr == NULL, TTT_INVALID_USER_INPUT, \
*ptr == NULL, TTT_ERROR_INVALID_INPUT, \
"Double pointer passed to ttt API call is NULL when dereferenced"); \
}

Expand Down
4 changes: 2 additions & 2 deletions include/ttt.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@
* @brief Error index provided to ttt_error_get_id() or ttt_error_get_str()
* is invalid.
*/
#define TTT_INVALID_ERROR_INDEX (-1)
#define TTT_ERROR_INVALID_INDEX (-1)

/**
* @ingroup ttt_error_codes
*
* @brief User input provided to ttt API is invalid.
*/
#define TTT_INVALID_USER_INPUT (-128)
#define TTT_ERROR_INVALID_INPUT (-2)

/**
* @defgroup ttt_user_api_macros User API macros
Expand Down
4 changes: 2 additions & 2 deletions src/ttt-impl.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ static ttt_err_log_t **ttt_log_errs = NULL;
* Users must use ttt_log() macro instead of directly calling ttt_log_().
*
* @param type Log type.
* @param error_id Error number or id (e.g., TTT_INVALID_USER_INPUT).
* @param error_id Error number or id (e.g., TTT_ERROR_INVALID_INPUT).
* @param fmt_ Format string for the log message.
* @param ... printf() arguments: file name, line number and other optional
* arguments if any.
Expand Down Expand Up @@ -127,7 +127,7 @@ int ttt_log_(const ttt_log_type_t type, const int error_id, const char *fmt_,
static int ttt_check_error_index(const int index) {
if (index == 0 || ttt_log_size == 0) return TTT_SUCCESS;

ttt_error(index < 0 || index > (int)ttt_log_size, TTT_INVALID_ERROR_INDEX,
ttt_error(index < 0 || index > (int)ttt_log_size, TTT_ERROR_INVALID_INDEX,
"Error index (%d) passed to ttt_get_error_id() is out of range.",
index);
return TTT_SUCCESS;
Expand Down
2 changes: 1 addition & 1 deletion src/ttt.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ static int ttt_parse_opts(ttt_t ttt, int *argc, char ***argv_) {
case TTT_INPUT_VERBOSE:
// NOLINTNEXTLINE
verbose_temp = strtol(optarg, &end, 10);
ttt_error(!end || *end != '\0' || optarg == end, TTT_INVALID_USER_INPUT,
ttt_error(!end || *end != '\0' || optarg == end, TTT_ERROR_INVALID_INPUT,
"Invalid string for verbose level: %s\n", optarg);
ttt->verbose = verbose_temp;
break;
Expand Down
2 changes: 1 addition & 1 deletion tests/ttt-000-init.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ int main(int argc, char **argv) {

int error_id = 0;
ttt_test_check(ttt_get_error_id(&error_id, status), err);
ttt_test_assert(error_id == TTT_INVALID_USER_INPUT, err);
ttt_test_assert(error_id == TTT_ERROR_INVALID_INPUT, err);

return err;
}
Loading