From d6d0a675bfe27420d14394ef6b0da5247ea63d87 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Tue, 24 May 2022 18:29:32 +0300 Subject: libcamera: yaml_parser: Switch from FILE to File THe FILE object isn't very user-friendly as it requires manual close. Replace it with File to provide RAII-style resource management in the YamlParser API. Signed-off-by: Laurent Pinchart Reviewed-by: Paul Elder --- test/yaml-parser.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'test') diff --git a/test/yaml-parser.cpp b/test/yaml-parser.cpp index c5b4ddbb..e75f8fe8 100644 --- a/test/yaml-parser.cpp +++ b/test/yaml-parser.cpp @@ -9,6 +9,8 @@ #include #include +#include + #include "libcamera/internal/yaml_parser.h" #include "test.h" @@ -69,29 +71,27 @@ protected: int run() { /* Test invalid YAML file */ - FILE *fh = fopen(invalidYamlFile_.c_str(), "r"); - if (!fh) { + File file{ invalidYamlFile_ }; + if (!file.open(File::OpenModeFlag::ReadOnly)) { cerr << "Fail to open invalid YAML file" << std::endl; return TestFail; } - std::unique_ptr root = YamlParser::parse(fh); - fclose(fh); - + std::unique_ptr root = YamlParser::parse(file); if (root) { cerr << "Invalid YAML file parse successfully" << std::endl; return TestFail; } /* Test YAML file */ - fh = fopen(testYamlFile_.c_str(), "r"); - if (!fh) { + file.close(); + file.setFileName(testYamlFile_); + if (!file.open(File::OpenModeFlag::ReadOnly)) { cerr << "Fail to open test YAML file" << std::endl; return TestFail; } - root = YamlParser::parse(fh); - fclose(fh); + root = YamlParser::parse(file); if (!root) { cerr << "Fail to parse test YAML file: " << std::endl; -- cgit v1.2.1