Add helper function for mnt_table_parse_{stream,mtab}
This wraps a few common steps. It is defined as inline function instead of in a .c file to avoid having a .c file. With a .c file, we would have three choices: - either link it into libshared, but then then libshared would have to be linked to libmount. - or compile the .c file into each target separately. This has the disdvantage that configuration of every target has to be updated and stuff will be compiled multiple times anyway, which is not too different from keeping this in the header file. - or create a new convenience library just for this. This also has the disadvantage that the every target would have to be updated, and a separate library for a 10 line function seems overkill. By keeping everything in a header file, we compile this a few times, but otherwise it's the least painful option. The compiler can optimize most of the function away, because it knows if 'source' is set or not.
This commit is contained in:
@@ -21,13 +21,10 @@ static void test_libmount_unescaping_one(
|
||||
_cleanup_(mnt_free_iterp) struct libmnt_iter *iter = NULL;
|
||||
_cleanup_fclose_ FILE *f = NULL;
|
||||
|
||||
assert_se(table = mnt_new_table());
|
||||
assert_se(iter = mnt_new_iter(MNT_ITER_FORWARD));
|
||||
|
||||
f = fmemopen((char*) string, strlen(string), "re");
|
||||
assert_se(f);
|
||||
|
||||
assert_se(mnt_table_parse_stream(table, f, title) >= 0);
|
||||
assert_se(libmount_parse(title, f, &table, &iter) >= 0);
|
||||
|
||||
struct libmnt_fs *fs;
|
||||
const char *source, *target;
|
||||
|
||||
Reference in New Issue
Block a user