From: Daan De Meyer Date: Wed, 18 Feb 2026 20:27:45 +0000 (+0100) Subject: vpick: Make suffix a single string again instead of a strv X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=81cef494a6ec8ed0c7a98258fb8a14f1011686a0;p=thirdparty%2Fsystemd.git vpick: Make suffix a single string again instead of a strv This was made a strv to handle either directories or raw images but since we now handle that via multiple PickFilter instances, we don't need suffixes to be a strv anymore. --- diff --git a/src/shared/discover-image.c b/src/shared/discover-image.c index 5bb54746089..8352e5a821b 100644 --- a/src/shared/discover-image.c +++ b/src/shared/discover-image.c @@ -883,7 +883,7 @@ int image_find(RuntimeScope scope, .type_mask = endswith(suffix, ".raw") ? (UINT32_C(1) << DT_REG) | (UINT32_C(1) << DT_BLK) : (UINT32_C(1) << DT_DIR), .basename = name, .architecture = _ARCHITECTURE_INVALID, - .suffix = STRV_MAKE(suffix), + .suffix = suffix, }; _cleanup_(pick_result_done) PickResult result = PICK_RESULT_NULL; @@ -1100,7 +1100,7 @@ int image_discover( .type_mask = endswith(suffix, ".raw") ? (UINT32_C(1) << DT_REG) | (UINT32_C(1) << DT_BLK) : (UINT32_C(1) << DT_DIR), .basename = pretty, .architecture = _ARCHITECTURE_INVALID, - .suffix = STRV_MAKE(suffix), + .suffix = suffix, }; _cleanup_(pick_result_done) PickResult result = PICK_RESULT_NULL; diff --git a/src/shared/vpick.c b/src/shared/vpick.c index f3fd233e17b..69e8be1b166 100644 --- a/src/shared/vpick.c +++ b/src/shared/vpick.c @@ -13,7 +13,6 @@ #include "recurse-dir.h" #include "stat-util.h" #include "string-util.h" -#include "strv.h" #include "vpick.h" void pick_result_done(PickResult *p) { @@ -86,8 +85,6 @@ static int format_fname( if (FLAGS_SET(flags, PICK_TRIES) || !filter->version) /* Underspecified? */ return -ENOEXEC; - if (strv_length(filter->suffix) > 1) /* suffix is not deterministic? */ - return -ENOEXEC; /* The format for names we match goes like this: * @@ -139,8 +136,8 @@ static int format_fname( return -ENOMEM; } - if (!strv_isempty(filter->suffix)) - if (!strextend(&fn, filter->suffix[0])) + if (!isempty(filter->suffix)) + if (!strextend(&fn, filter->suffix)) return -ENOMEM; if (!filename_is_valid(fn)) @@ -407,8 +404,8 @@ static int make_choice( } else e = dname; - if (!strv_isempty(filter->suffix)) { - char *sfx = endswith_strv(e, filter->suffix); + if (!isempty(filter->suffix)) { + char *sfx = endswith(e, filter->suffix); if (!sfx) continue; @@ -511,7 +508,6 @@ static int path_pick_one( PickResult *ret) { _cleanup_free_ char *filter_bname = NULL, *dir = NULL, *parent = NULL, *fname = NULL; - char * const *filter_suffix_strv = NULL; const char *filter_suffix = NULL, *enumeration_path; uint32_t filter_type_mask; int r; @@ -569,11 +565,13 @@ static int path_pick_one( return -ENOMEM; /* Chop off suffix, if specified */ - char *f = endswith_strv(filter_bname, filter->suffix); - if (f) - *f = 0; + if (!isempty(filter->suffix)) { + char *f = endswith(filter_bname, filter->suffix); + if (f) + *f = 0; + } - filter_suffix_strv = filter->suffix; + filter_suffix = filter->suffix; filter_type_mask = filter->type_mask; enumeration_path = path; @@ -633,7 +631,7 @@ static int path_pick_one( .basename = filter_bname, .version = filter->version, .architecture = filter->architecture, - .suffix = filter_suffix_strv ?: STRV_MAKE(filter_suffix), + .suffix = filter_suffix, }, flags, ret); @@ -790,7 +788,7 @@ const PickFilter pick_filter_image_raw[1] = { { .type_mask = (UINT32_C(1) << DT_REG) | (UINT32_C(1) << DT_BLK), .architecture = _ARCHITECTURE_INVALID, - .suffix = STRV_MAKE(".raw"), + .suffix = ".raw", }, }; diff --git a/src/shared/vpick.h b/src/shared/vpick.h index d08dc58b8fb..1ebcd5c8ab6 100644 --- a/src/shared/vpick.h +++ b/src/shared/vpick.h @@ -17,7 +17,7 @@ typedef struct PickFilter { const char *basename; /* Can be overridden by search pattern */ const char *version; Architecture architecture; - char * const *suffix; /* Can be overridden by search pattern */ + const char *suffix; /* Can be overridden by search pattern */ } PickFilter; typedef struct PickResult { diff --git a/src/test/test-vpick.c b/src/test/test-vpick.c index f550b924644..400380b5754 100644 --- a/src/test/test-vpick.c +++ b/src/test/test-vpick.c @@ -44,7 +44,7 @@ TEST(path_pick) { PickFilter filter = { .architecture = _ARCHITECTURE_INVALID, - .suffix = STRV_MAKE(".raw"), + .suffix = ".raw", }; if (IN_SET(native_architecture(), ARCHITECTURE_X86, ARCHITECTURE_X86_64)) { diff --git a/src/vpick/vpick-tool.c b/src/vpick/vpick-tool.c index f4251f5c943..c20994d115d 100644 --- a/src/vpick/vpick-tool.c +++ b/src/vpick/vpick-tool.c @@ -245,7 +245,7 @@ static int run(int argc, char *argv[]) { .basename = arg_filter_basename, .version = arg_filter_version, .architecture = arg_filter_architecture, - .suffix = STRV_MAKE(arg_filter_suffix), + .suffix = arg_filter_suffix, .type_mask = arg_filter_type_mask, }, /* n_filters= */ 1,