From 30b2b3d65569a71794c6a542d1ea09d1dcc5e653 Mon Sep 17 00:00:00 2001 From: KerfuffleV2 Date: Sun, 7 May 2023 02:25:32 -0600 Subject: [PATCH] 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. --- ggml.c | 6 ++---- ggml.h | 4 ++-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/ggml.c b/ggml.c index 4eb569946..400152fdc 100644 --- a/ggml.c +++ b/ggml.c @@ -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; } //////////////////////////////////////////////////////////////////////////////// diff --git a/ggml.h b/ggml.h index 017b0c379..83167f962 100644 --- a/ggml.h +++ b/ggml.h @@ -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(