Improve error handling when querying pagesize

This commit is contained in:
Antonio SJ Musumeci
2026-03-24 21:13:34 -04:00
committed by trapexit
parent 164b7f73c9
commit e0a892f0d0
+11 -1
View File
@@ -20,6 +20,8 @@
#include "from_string.hpp"
#include <cassert>
#include <climits>
#include <cctype>
#include <string>
@@ -48,12 +50,20 @@ ConfigPageSize::from_string(const std::string_view s_)
{
int rv;
u64 v;
long tmp;
u64 pagesize;
if(s_.empty())
return -EINVAL;
pagesize = sysconf(_SC_PAGESIZE);
tmp = sysconf(_SC_PAGESIZE);
if(tmp <= 0)
{
perror("mergerfs: pagesize query failed");
std::abort();
}
pagesize = (u64)tmp;
rv = str::from(s_,&v);
if(rv < 0)