From: Zbigniew Jędrzejewski-Szmek Date: Wed, 10 Mar 2021 12:35:26 +0000 (+0100) Subject: shared/fstab-util: immediately drop empty options again X-Git-Tag: v248-rc3~2^2~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5fa2da125157a1beca508792ee5d9be833c2c0cb;p=thirdparty%2Fsystemd.git shared/fstab-util: immediately drop empty options again In the conversion from strv_split() to strv_split_full() done in 7bb553bb98a57b4e03804f8192bdc5a534325582, EXTRACT_DONT_COALESCE_SEPARATORS was added. I think this was just by mistake… We never look for "empty options", so whether we immediately ignore the extra separator or store the empty string in strv, should make no difference. --- diff --git a/src/shared/fstab-util.c b/src/shared/fstab-util.c index 292b97cd692..1ddcd371cfc 100644 --- a/src/shared/fstab-util.c +++ b/src/shared/fstab-util.c @@ -140,7 +140,7 @@ int fstab_filter_options(const char *opts, const char *names, break; } } else { - r = strv_split_full(&stor, opts, ",", EXTRACT_DONT_COALESCE_SEPARATORS | EXTRACT_UNESCAPE_SEPARATORS); + r = strv_split_full(&stor, opts, ",", EXTRACT_UNESCAPE_SEPARATORS); if (r < 0) return r; diff --git a/src/test/test-fstab-util.c b/src/test/test-fstab-util.c index 222ffbb2a75..ebbdd05ca62 100644 --- a/src/test/test-fstab-util.c +++ b/src/test/test-fstab-util.c @@ -91,9 +91,13 @@ static void test_fstab_filter_options(void) { do_fstab_filter_options("opt =0", "x-opt\0opt\0noopt\0x-noopt\0", 0, NULL, NULL, NULL); do_fstab_filter_options(" opt ", "opt\0x-opt\0", 0, NULL, NULL, NULL); - /* check function will NULL args */ + /* check function with NULL args */ do_fstab_filter_options(NULL, "opt\0", 0, NULL, NULL, ""); do_fstab_filter_options("", "opt\0", 0, NULL, NULL, ""); + + /* unnecessary comma separators */ + do_fstab_filter_options("opt=x,,,,", "opt\0", 1, "opt", "x", ""); + do_fstab_filter_options(",,,opt=x,,,,", "opt\0", 1, "opt", "x", ""); } static void test_fstab_find_pri(void) {