[Bug] Coverity issue 835432
Documentation of nftw() function says that the result can be -1,
which is not valid error code for system_error constructor. To
resolve such problem, the -1 value is translated to IOError code.
[Verification] Code compiles without errors.
TCT passrate of filesystem module is 100%.
Change-Id: I92805294270b4969fd545a413c03c565fdef7afd
Signed-off-by: Piotr Kosko <p.kosko@samsung.com>
128, FTW_DEPTH | FTW_PHYS);
if (res) {
+ if (-1 == res) {
+ // -1 can be returned by nftw() function, to prevent invalid translation of error in
+ // std::system_error constructor, such situation will be treated as generic IOError
+ res = EIO;
+ }
throw std::system_error{res, std::generic_category(),
"Failed to remove directory recursively: "s + std::strerror(res)};
}