fix: change error variable names

This commit is contained in:
ngn 2024-07-14 21:01:02 +03:00
parent 7f6942ea7d
commit 9aefa2ebf9
3 changed files with 20 additions and 17 deletions

View File

@ -150,3 +150,6 @@ void lm_error_set(lm_error_t code, ...);
void lm_error_clear(); void lm_error_clear();
lm_error_t lm_error(); lm_error_t lm_error();
char *lm_strerror(); char *lm_strerror();
extern lm_error_t lm_error_code;
extern char *lm_error_str;

View File

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-07-13 16:47+0300\n" "POT-Creation-Date: 2024-07-14 18:02+0300\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"

View File

@ -5,13 +5,13 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
lm_error_t error = LM_ERR_NoError; lm_error_t lm_error_code = LM_ERR_NoError;
char *error_str = NULL; char *lm_error_str = NULL;
void lm_error_clear() { void lm_error_clear() {
free(error_str); free(lm_error_str);
error = LM_ERR_NoError; lm_error_code = LM_ERR_NoError;
error_str = NULL; lm_error_str = NULL;
} }
void lm_error_set(lm_error_t code, ...) { void lm_error_set(lm_error_t code, ...) {
@ -158,16 +158,16 @@ void lm_error_set(lm_error_t code, ...) {
{.code = LM_ERR_InfoNotLoaded, .desc = _("pool info is not loaded") }, {.code = LM_ERR_InfoNotLoaded, .desc = _("pool info is not loaded") },
}; };
char *fmt = NULL; char *fmt = NULL;
error = code; lm_error_code = code;
if (NULL != error_str) { if (NULL != lm_error_str) {
free(error_str); free(lm_error_str);
error_str = NULL; lm_error_str = NULL;
} }
for (int i = 0; i < sizeof(errors) / sizeof(lm_error_desc_t); i++) { for (int i = 0; i < sizeof(errors) / sizeof(lm_error_desc_t); i++) {
if (errors[i].code == error) { if (errors[i].code == lm_error_code) {
fmt = errors[i].desc; fmt = errors[i].desc;
break; break;
} }
@ -180,18 +180,18 @@ void lm_error_set(lm_error_t code, ...) {
va_start(args, code); va_start(args, code);
va_copy(argscp, args); va_copy(argscp, args);
int size = vsnprintf(NULL, 0, fmt, args) + 2; int size = vsnprintf(NULL, 0, fmt, args) + 2;
error_str = malloc(size); lm_error_str = malloc(size);
vsnprintf(error_str, size, fmt, argscp); vsnprintf(lm_error_str, size, fmt, argscp);
va_end(args); va_end(args);
va_end(argscp); va_end(argscp);
} }
char *lm_strerror() { char *lm_strerror() {
return error_str; return lm_error_str;
} }
lm_error_t lm_error() { lm_error_t lm_error() {
return error; return lm_error_code;
} }