There were still struct fields and defines conditionally enabled.

Change return from ggml_last_error_msg to be const.

Cast returning error msg buffer to avoid a compiler warning.
This commit is contained in:
KerfuffleV2 2023-05-07 02:25:32 -06:00
parent 7523107877
commit 30b2b3d655
2 changed files with 4 additions and 6 deletions

6
ggml.c
View file

@ -4245,10 +4245,8 @@ struct ggml_context {
struct ggml_scratch scratch;
struct ggml_scratch scratch_save;
#ifdef GGML_RECOVERABLE_ERRORS
enum ggml_errcode last_error_code;
char last_error_msg[GGML_ERROR_BUFFER_LEN];
#endif
};
struct ggml_context_container {
@ -4638,8 +4636,8 @@ enum ggml_errcode ggml_last_error_code(struct ggml_context * ctx) {
return ctx->last_error_code;
}
char * ggml_last_error_msg(struct ggml_context * ctx) {
return ctx->last_error_code == GGML_ERRCODE_SUCCESS ? "Success" : &ctx->last_error_msg;
const char * ggml_last_error_msg(struct ggml_context * ctx) {
return ctx->last_error_code == GGML_ERRCODE_SUCCESS ? "Success" : (const char *)&ctx->last_error_msg;
}
////////////////////////////////////////////////////////////////////////////////

4
ggml.h
View file

@ -206,6 +206,7 @@
} while (0)
#define GGML_RECOVERABLE_ERRORS
#define GGML_ERROR_BUFFER_LEN 256
#ifndef GGML_RECOVERABLE_ERRORS
#define GGML_RECOVERABLE_ASSERT(_ctx, _code, x, ...) \
do { \
@ -217,7 +218,6 @@
} while (0)
#else
#define GGML_ERROR_BUFFER_LEN 256
#define GGML_RECOVERABLE_ASSERT(ctx, errcode, x, ...) \
do { \
if ((ctx)->last_error_code != GGML_ERRCODE_SUCCESS) { \
@ -468,7 +468,7 @@ extern "C" {
// struct ggml_context * ctx);
GGML_API enum ggml_errcode ggml_last_error_code(
struct ggml_context * ctx);
GGML_API char * ggml_last_error_msg(
GGML_API const char * ggml_last_error_msg(
struct ggml_context * ctx);
GGML_API struct ggml_tensor * ggml_new_tensor(