From: Daniel Bevenius Date: Fri, 6 Jun 2025 16:58:10 +0000 (+0200) Subject: sam : add default case for unsupported prompt types (#1263) X-Git-Url: https://git.djapps.eu/?a=commitdiff_plain;h=a1761cd64ce4a75a9770a954a013422c7910db8b;p=pkg%2Fggml%2Fsources%2Fggml sam : add default case for unsupported prompt types (#1263) This commit adds a default case in the `embed_prompt_sparse` lambda function. The motivation for this change is that currently the following warning is generated when compiling: ```console /ggml/examples/sam/sam.cpp: In lambda function: /ggml/examples/sam/sam.cpp:1499:5: warning: control reaches end of non-void function [-Wreturn-type] 1499 | }(); | ^ ``` --- diff --git a/examples/sam/sam.cpp b/examples/sam/sam.cpp index 299318f5..92c7971f 100644 --- a/examples/sam/sam.cpp +++ b/examples/sam/sam.cpp @@ -1460,7 +1460,7 @@ prompt_encoder_result sam_encode_prompt( ggml_set_name(inp, "prompt_input"); ggml_set_input(inp); - auto * embd_prompt_sparse = [&]() { + auto * embd_prompt_sparse = [&]() -> struct ggml_tensor * { switch (prompt.prompt_type) { case SAM_PROMPT_TYPE_POINT: { // PromptEncoder._embed_points @@ -1495,6 +1495,10 @@ prompt_encoder_result sam_encode_prompt( return corner_embd; } break; + default: { + fprintf(stderr, "%s: unsupported prompt type %d\n", __func__, prompt.prompt_type); + return nullptr; + } break; } }();