diff --git a/src/shared/discover-image.c b/src/shared/discover-image.c index 5bb5474608..8352e5a821 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 f3fd233e17..69e8be1b16 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 d08dc58b8f..1ebcd5c8ab 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 f550b92464..400380b575 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 f4251f5c94..c20994d115 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,