summaryrefslogtreecommitdiff
path: root/src/conf-parser.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/conf-parser.c')
-rw-r--r--src/conf-parser.c66
1 files changed, 33 insertions, 33 deletions
diff --git a/src/conf-parser.c b/src/conf-parser.c
index ac8d9f5ac5..c7dd01aa1d 100644
--- a/src/conf-parser.c
+++ b/src/conf-parser.c
@@ -454,7 +454,7 @@ int config_parse_unsigned(
return 0;
}
-int config_parse_size(
+int config_parse_bytes_size(
const char *filename,
unsigned line,
const char *section,
@@ -465,20 +465,47 @@ int config_parse_size(
void *userdata) {
size_t *sz = data;
- unsigned u;
- int r;
+ off_t o;
assert(filename);
assert(lvalue);
assert(rvalue);
assert(data);
- if ((r = safe_atou(rvalue, &u)) < 0) {
- log_error("[%s:%u] Failed to parse numeric value, ignoring: %s", filename, line, rvalue);
+ if (parse_bytes(rvalue, &o) < 0 || (off_t) (size_t) o != o) {
+ log_error("[%s:%u] Failed to parse byte value, ignoring: %s", filename, line, rvalue);
+ return 0;
+ }
+
+ *sz = (size_t) o;
+ return 0;
+}
+
+
+int config_parse_bytes_off(
+ const char *filename,
+ unsigned line,
+ const char *section,
+ const char *lvalue,
+ int ltype,
+ const char *rvalue,
+ void *data,
+ void *userdata) {
+
+ off_t *bytes = data;
+
+ assert(filename);
+ assert(lvalue);
+ assert(rvalue);
+ assert(data);
+
+ assert_cc(sizeof(off_t) == sizeof(uint64_t));
+
+ if (parse_bytes(rvalue, bytes) < 0) {
+ log_error("[%s:%u] Failed to parse bytes value, ignoring: %s", filename, line, rvalue);
return 0;
}
- *sz = (size_t) u;
return 0;
}
@@ -782,30 +809,3 @@ int config_parse_mode(
*m = (mode_t) l;
return 0;
}
-
-int config_parse_bytes(
- const char *filename,
- unsigned line,
- const char *section,
- const char *lvalue,
- int ltype,
- const char *rvalue,
- void *data,
- void *userdata) {
-
- off_t *bytes = data;
-
- assert(filename);
- assert(lvalue);
- assert(rvalue);
- assert(data);
-
- assert_cc(sizeof(off_t) == sizeof(uint64_t));
-
- if (parse_bytes(rvalue, bytes) < 0) {
- log_error("[%s:%u] Failed to parse bytes value, ignoring: %s", filename, line, rvalue);
- return 0;
- }
-
- return 0;
-}