From: Luca BRUNO Date: Mon, 24 Oct 2022 12:49:32 +0000 (+0000) Subject: test-string-util: remove several strdupa() calls X-Git-Tag: v252-rc3~5 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=88f8bd753a5e87ba440d2c72a684888be90fd819;p=thirdparty%2Fsystemd.git test-string-util: remove several strdupa() calls This performs the same semantic transformation as the Coccinelle script 'strdupa.cocci'. Somehow the existing semantic patch is not properly triggering on this 'string_replace_char' test. --- diff --git a/src/test/test-string-util.c b/src/test/test-string-util.c index 25ddceb799a..d0a2272794c 100644 --- a/src/test/test-string-util.c +++ b/src/test/test-string-util.c @@ -1125,11 +1125,11 @@ TEST(strextendf) { } TEST(string_replace_char) { - assert_se(streq(string_replace_char(strdupa(""), 'a', 'b'), "")); - assert_se(streq(string_replace_char(strdupa("abc"), 'a', 'b'), "bbc")); - assert_se(streq(string_replace_char(strdupa("hoge"), 'a', 'b'), "hoge")); - assert_se(streq(string_replace_char(strdupa("aaaa"), 'a', 'b'), "bbbb")); - assert_se(streq(string_replace_char(strdupa("aaaa"), 'a', '\t'), "\t\t\t\t")); + assert_se(streq(string_replace_char(strdupa_safe(""), 'a', 'b'), "")); + assert_se(streq(string_replace_char(strdupa_safe("abc"), 'a', 'b'), "bbc")); + assert_se(streq(string_replace_char(strdupa_safe("hoge"), 'a', 'b'), "hoge")); + assert_se(streq(string_replace_char(strdupa_safe("aaaa"), 'a', 'b'), "bbbb")); + assert_se(streq(string_replace_char(strdupa_safe("aaaa"), 'a', '\t'), "\t\t\t\t")); } TEST(strspn_from_end) {