Move everything to negative errno return types (#1499)
Some checks failed
CodeQL / Analyze (push) Has been cancelled
mkdocs / deploy (push) Has been cancelled

This commit is contained in:
trapexit 2025-07-25 17:53:48 -05:00 • committed by GitHub
parent 2b500f194a
commit e8cd74cab0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
177 changed files with 5952 additions and 5843 deletions

View file

@ -14,6 +14,8 @@
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include "policy_msplus.hpp"
#include "errno.hpp"
#include "fs_exists.hpp"
#include "fs_info.hpp"
@ -28,73 +30,70 @@
#include <string>
namespace msplus
static
Branch*
_create_1(const Branches::Ptr &branches_,
const std::string &fusepath_,
int *err_)
{
static
Branch*
create_1(const Branches::Ptr &branches_,
const std::string &fusepath_,
int *err_)
{
int rv;
uint64_t lus;
fs::info_t info;
Branch *obranch;
int rv;
uint64_t lus;
fs::info_t info;
Branch *obranch;
obranch = nullptr;
lus = std::numeric_limits<uint64_t>::max();
for(auto &branch : *branches_)
{
if(branch.ro_or_nc())
error_and_continue(*err_,EROFS);
if(!fs::exists(branch.path,fusepath_))
error_and_continue(*err_,ENOENT);
rv = fs::info(branch.path,&info);
if(rv == -1)
error_and_continue(*err_,ENOENT);
if(info.readonly)
error_and_continue(*err_,EROFS);
if(info.spaceavail < branch.minfreespace())
error_and_continue(*err_,ENOSPC);
if(info.spaceused >= lus)
continue;
obranch = nullptr;
lus = std::numeric_limits<uint64_t>::max();
for(auto &branch : *branches_)
{
if(branch.ro_or_nc())
error_and_continue(*err_,-EROFS);
if(!fs::exists(branch.path,fusepath_))
error_and_continue(*err_,-ENOENT);
rv = fs::info(branch.path,&info);
if(rv < 0)
error_and_continue(*err_,-ENOENT);
if(info.readonly)
error_and_continue(*err_,-EROFS);
if(info.spaceavail < branch.minfreespace())
error_and_continue(*err_,-ENOSPC);
if(info.spaceused >= lus)
continue;
lus = info.spaceused;
obranch = &branch;
}
lus = info.spaceused;
obranch = &branch;
}
return obranch;
}
return obranch;
}
static
int
create(const Branches::Ptr &branches_,
const char *fusepath_,
std::vector<Branch*> &paths_)
{
int error;
Branch *branch;
std::string fusepath;
static
int
_create(const Branches::Ptr &branches_,
const char *fusepath_,
std::vector<Branch*> &paths_)
{
int err;
Branch *branch;
std::string fusepath;
error = ENOENT;
fusepath = fusepath_;
for(;;)
{
branch = msplus::create_1(branches_,fusepath,&error);
if(branch)
break;
if(fusepath == "/")
break;
fusepath = fs::path::dirname(fusepath);
}
err = -ENOENT;
fusepath = fusepath_;
for(;;)
{
branch = ::_create_1(branches_,fusepath,&err);
if(branch)
break;
if(fusepath == "/")
break;
fusepath = fs::path::dirname(fusepath);
}
if(!branch)
return (errno=error,-1);
if(!branch)
return err;
paths_.emplace_back(branch);
paths_.emplace_back(branch);
return 0;
}
return 0;
}
int
@ -110,7 +109,7 @@ Policy::MSPLUS::Create::operator()(const Branches::Ptr &branches_,
const char *fusepath_,
std::vector<Branch*> &paths_) const
{
return ::msplus::create(branches_,fusepath_,paths_);
return ::_create(branches_,fusepath_,paths_);
}
int