From e79984592eb916652cfd670f1a86b2ee366ca93f Mon Sep 17 00:00:00 2001 From: zzy <2450266535@qq.com> Date: Fri, 27 Feb 2026 17:25:56 +0800 Subject: [PATCH] =?UTF-8?q?fix(argparse):=20=E4=BF=AE=E5=A4=8D=E4=BD=8D?= =?UTF-8?q?=E7=BD=AE=E5=8F=82=E6=95=B0=E5=A4=84=E7=90=86=E4=B8=AD=E7=9A=84?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E8=BD=AC=E6=8D=A2=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在处理位置参数时,将 scc_vec_size 的返回值显式转换为 int, 以避免潜在的类型不匹配问题。 fix(pproc): 修复宏展开中的类型转换问题 在多个位置将 scc_vec_size 的返回值显式转换为 int, 确保比较操作的类型一致性。 fix(pproc): 修复头文件包含深度检查的类型转换 将文件栈大小检查中的 scc_vec_size 返回值转换为 int, 保持类型一致性。 fix(sstream): 修复位置日志中未使用的变量警告 更新未使用变量的声明方式,将逗号分隔改为分号分隔, 更好地抑制编译器警告。 --- libs/argparse/src/argparse.c | 2 +- libs/pproc/src/pproc_expand.c | 12 +++++++----- libs/pproc/src/pproc_include.c | 2 +- libs/sstream/src/scc_pos_log.c | 2 +- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/libs/argparse/src/argparse.c b/libs/argparse/src/argparse.c index dc3f22e..c85d309 100644 --- a/libs/argparse/src/argparse.c +++ b/libs/argparse/src/argparse.c @@ -221,7 +221,7 @@ static int handle_positional_arg(scc_argparse_context_t *ctx, return SCC_ARGPARSE_ERR_NONE; } - if (ctx->positional_index < scc_vec_size(ctx->current_cmd->args)) { + if (ctx->positional_index < (int)scc_vec_size(ctx->current_cmd->args)) { scc_argparse_arg_t *arg = &scc_vec_at(ctx->current_cmd->args, ctx->positional_index); *arg->spec.store.str_store = ctx->result.value; diff --git a/libs/pproc/src/pproc_expand.c b/libs/pproc/src/pproc_expand.c index 913869a..2746e7e 100644 --- a/libs/pproc/src/pproc_expand.c +++ b/libs/pproc/src/pproc_expand.c @@ -146,7 +146,8 @@ split_arguments(scc_pproc_macro_extened_params_t *splited_params, depth--; } if (depth != 0 || raw_arg->type != SCC_TOK_COMMA || - (is_variadic && scc_vec_size(*splited_params) == named_count - 1)) { + (is_variadic && + (int)scc_vec_size(*splited_params) == named_count - 1)) { if (scc_vec_size(arg) == 0 && raw_arg->type == SCC_TOK_BLANK) { scc_lexer_tok_drop(raw_arg); } else { @@ -169,7 +170,7 @@ split_arguments(scc_pproc_macro_extened_params_t *splited_params, } scc_vec_push(*splited_params, arg); - if (is_variadic && scc_vec_size(*splited_params) == named_count - 1) { + if (is_variadic && (int)scc_vec_size(*splited_params) == named_count - 1) { scc_vec_init(arg); scc_vec_push(*splited_params, arg); } @@ -318,10 +319,11 @@ static inline void expand_function_macro(scc_pproc_expand_t *expand_ctx, int left_idx = got_left_non_blank(i, ¯o->replaces); int right_idx = got_right_non_blank(i, ¯o->replaces); - if (left_idx < 0 || right_idx >= (int)macro->replaces.size) { + if (left_idx < 0 || + right_idx >= (int)scc_vec_size(macro->replaces)) { LOG_FATAL("Invalid ## operator"); } - while (i++ < right_idx) { + while ((int)i++ < right_idx) { scc_lexer_tok_drop(&scc_vec_pop(tok_buffer)); } @@ -448,7 +450,7 @@ static inline void expand_object_macro(scc_pproc_expand_t *expand_ctx, scc_lexer_tok_t *right = &scc_vec_at(macro->replaces, right_idx); scc_lexer_tok_t concate_tok = concatenate_tokens(left, right); - while (i++ < right_idx) { + while ((int)i++ < right_idx) { scc_lexer_tok_drop(&scc_vec_pop(tok_buffer)); } if (concate_tok.type == SCC_TOK_UNKNOWN) { diff --git a/libs/pproc/src/pproc_include.c b/libs/pproc/src/pproc_include.c index 6831245..3a9f6ae 100644 --- a/libs/pproc/src/pproc_include.c +++ b/libs/pproc/src/pproc_include.c @@ -36,7 +36,7 @@ static int switch_file_stack(scc_pproc_t *pp, scc_cstring_t *fname, SCC_ERROR(*pos, "include file '%s' not found", scc_cstring_as_cstr(fname)); return -1; FOPEN: - if (scc_vec_size(pp->file_stack) >= pp->config.max_include_depth) { + if ((int)scc_vec_size(pp->file_stack) >= pp->config.max_include_depth) { SCC_FATAL(*pos, "include depth exceeds maximum (%d)", pp->config.max_include_depth); LOG_FATAL("Include depth is too deep..."); diff --git a/libs/sstream/src/scc_pos_log.c b/libs/sstream/src/scc_pos_log.c index 38941e1..044f395 100644 --- a/libs/sstream/src/scc_pos_log.c +++ b/libs/sstream/src/scc_pos_log.c @@ -5,7 +5,7 @@ static int user_log_handler(logger_t *module, log_level_t level, const char *fmt, ...) { /* clang-format off */ - (void)file; (void)line; (void)func; // 不再使用 + (void) module, (void)file, (void)line, (void)func; // 不再使用 const char *level_str = null; switch (level) {