]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
tree-wide: never use the off_t unless glibc makes us use it
authorLennart Poettering <lennart@poettering.net>
Thu, 10 Sep 2015 16:16:18 +0000 (18:16 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 10 Sep 2015 16:16:18 +0000 (18:16 +0200)
off_t is a really weird type as it is usually 64bit these days (at least
in sane programs), but could theoretically be 32bit. We don't support
off_t as 32bit builds though, but still constantly deal with safely
converting from off_t to other types and back for no point.

Hence, never use the type anymore. Always use uint64_t instead. This has
various benefits, including that we can expose these values directly as
D-Bus properties, and also that the values parse the same in all cases.

31 files changed:
CODING_STYLE
src/basic/copy.c
src/basic/copy.h
src/basic/util.c
src/basic/util.h
src/cgtop/cgtop.c
src/core/load-fragment.c
src/import/pull-raw.c
src/journal/compress.c
src/journal/compress.h
src/journal/coredump-vacuum.c
src/journal/coredump-vacuum.h
src/journal/coredump.c
src/journal/journal-file.c
src/journal/journalctl.c
src/journal/journald-gperf.gperf
src/journal/test-compress.c
src/journal/test-coredump-vacuum.c
src/libsystemd/sd-bus/busctl.c
src/login/logind-user.c
src/machine/machine-dbus.c
src/machine/machinectl.c
src/nspawn/nspawn.c
src/shared/bus-util.c
src/shared/conf-parser.c
src/shared/conf-parser.h
src/shared/pager.c
src/systemctl/systemctl.c
src/sysusers/sysusers.c
src/test/test-copy.c
src/test/test-util.c

index f13f9becbc0839d246ebffa44c34bcfee6963f72..98d99dcdaa086fad4b5e50e142e8a7ba2dd77bd7 100644 (file)
   always-true expression for an infinite while() loop is our
   recommendation is to simply write it without any such expression by
   using "for (;;)".
+
+- Never use the "off_t" type, and particularly avoid it in public
+  APIs. It's really weirdly defined, as it usually is 64bit and we
+  don't support it any other way, but it could in theory also be
+  32bit. Which one it is depends on a compiler switch chosen by the
+  compiled program, which hence corrupts APIs using it unless they can
+  also follow the program's choice. Moreover, in systemd we should
+  parse values the same way on all architectures and cannot expose
+  off_t values over D-Bus. To avoid any confusion regarding conversion
+  and ABIs, always use simply uint64_t directly.
index cc5faa80a17e24a8714e0c633958067a637a4a20..b8cbe644d443a65e601213d0040f761892070d34 100644 (file)
@@ -29,7 +29,7 @@
 
 #define COPY_BUFFER_SIZE (16*1024)
 
-int copy_bytes(int fdf, int fdt, off_t max_bytes, bool try_reflink) {
+int copy_bytes(int fdf, int fdt, uint64_t max_bytes, bool try_reflink) {
         bool try_sendfile = true, try_splice = true;
         int r;
 
@@ -37,7 +37,7 @@ int copy_bytes(int fdf, int fdt, off_t max_bytes, bool try_reflink) {
         assert(fdt >= 0);
 
         /* Try btrfs reflinks first. */
-        if (try_reflink && max_bytes == (off_t) -1) {
+        if (try_reflink && max_bytes == (uint64_t) -1) {
                 r = btrfs_reflink(fdf, fdt);
                 if (r >= 0)
                         return r;
@@ -47,12 +47,12 @@ int copy_bytes(int fdf, int fdt, off_t max_bytes, bool try_reflink) {
                 size_t m = COPY_BUFFER_SIZE;
                 ssize_t n;
 
-                if (max_bytes != (off_t) -1) {
+                if (max_bytes != (uint64_t) -1) {
 
                         if (max_bytes <= 0)
                                 return -EFBIG;
 
-                        if ((off_t) m > max_bytes)
+                        if ((uint64_t) m > max_bytes)
                                 m = (size_t) max_bytes;
                 }
 
@@ -105,8 +105,8 @@ int copy_bytes(int fdf, int fdt, off_t max_bytes, bool try_reflink) {
                 }
 
         next:
-                if (max_bytes != (off_t) -1) {
-                        assert(max_bytes >= n);
+                if (max_bytes != (uint64_t) -1) {
+                        assert(max_bytes >= (uint64_t) n);
                         max_bytes -= n;
                 }
         }
@@ -152,7 +152,7 @@ static int fd_copy_regular(int df, const char *from, const struct stat *st, int
         if (fdt < 0)
                 return -errno;
 
-        r = copy_bytes(fdf, fdt, (off_t) -1, true);
+        r = copy_bytes(fdf, fdt, (uint64_t) -1, true);
         if (r < 0) {
                 unlinkat(dt, to, 0);
                 return r;
@@ -371,7 +371,7 @@ int copy_file_fd(const char *from, int fdt, bool try_reflink) {
         if (fdf < 0)
                 return -errno;
 
-        r = copy_bytes(fdf, fdt, (off_t) -1, try_reflink);
+        r = copy_bytes(fdf, fdt, (uint64_t) -1, try_reflink);
 
         (void) copy_times(fdf, fdt);
         (void) copy_xattr(fdf, fdt);
index 8de0cfba325e75767862c106e08f53c5c01eca44..ba0890b44249ea764c7eaa850e9542700024b535 100644 (file)
@@ -21,6 +21,7 @@
   along with systemd; If not, see <http://www.gnu.org/licenses/>.
 ***/
 
+#include <inttypes.h>
 #include <stdbool.h>
 #include <sys/types.h>
 
@@ -30,6 +31,6 @@ int copy_file_atomic(const char *from, const char *to, mode_t mode, bool replace
 int copy_tree(const char *from, const char *to, bool merge);
 int copy_tree_at(int fdf, const char *from, int fdt, const char *to, bool merge);
 int copy_directory_fd(int dirfd, const char *to, bool merge);
-int copy_bytes(int fdf, int fdt, off_t max_bytes, bool try_reflink);
+int copy_bytes(int fdf, int fdt, uint64_t max_bytes, bool try_reflink);
 int copy_times(int fdf, int fdt);
 int copy_xattr(int fdf, int fdt);
index f7b2edf88cc35807a51ff7f028285db38f3dd84b..e3b2af8e02f849b8d789535de48aebaa6ba03b96 100644 (file)
@@ -2214,7 +2214,7 @@ int loop_write(int fd, const void *buf, size_t nbytes, bool do_poll) {
         return 0;
 }
 
-int parse_size(const char *t, off_t base, off_t *size) {
+int parse_size(const char *t, uint64_t base, uint64_t *size) {
 
         /* Soo, sometimes we want to parse IEC binary suffixes, and
          * sometimes SI decimal suffixes. This function can parse
@@ -2242,8 +2242,8 @@ int parse_size(const char *t, off_t base, off_t *size) {
                 { "G", 1024ULL*1024ULL*1024ULL },
                 { "M", 1024ULL*1024ULL },
                 { "K", 1024ULL },
-                { "B", 1 },
-                { "", 1 },
+                { "B", 1ULL },
+                { "",  1ULL },
         };
 
         static const struct table si[] = {
@@ -2253,8 +2253,8 @@ int parse_size(const char *t, off_t base, off_t *size) {
                 { "G", 1000ULL*1000ULL*1000ULL },
                 { "M", 1000ULL*1000ULL },
                 { "K", 1000ULL },
-                { "B", 1 },
-                { "", 1 },
+                { "B", 1ULL },
+                { "",  1ULL },
         };
 
         const struct table *table;
@@ -2276,33 +2276,32 @@ int parse_size(const char *t, off_t base, off_t *size) {
 
         p = t;
         do {
-                long long l;
-                unsigned long long l2;
+                unsigned long long l, tmp;
                 double frac = 0;
                 char *e;
                 unsigned i;
 
-                errno = 0;
-                l = strtoll(p, &e, 10);
+                p += strspn(p, WHITESPACE);
+                if (*p == '-')
+                        return -ERANGE;
 
+                errno = 0;
+                l = strtoull(p, &e, 10);
                 if (errno > 0)
                         return -errno;
-
-                if (l < 0)
-                        return -ERANGE;
-
                 if (e == p)
                         return -EINVAL;
 
                 if (*e == '.') {
                         e++;
+
+                        /* strtoull() itself would accept space/+/- */
                         if (*e >= '0' && *e <= '9') {
+                                unsigned long long l2;
                                 char *e2;
 
-                                /* strotoull itself would accept space/+/- */
                                 l2 = strtoull(e, &e2, 10);
-
-                                if (errno == ERANGE)
+                                if (errno > 0)
                                         return -errno;
 
                                 /* Ignore failure. E.g. 10.M is valid */
@@ -2315,27 +2314,27 @@ int parse_size(const char *t, off_t base, off_t *size) {
                 e += strspn(e, WHITESPACE);
 
                 for (i = start_pos; i < n_entries; i++)
-                        if (startswith(e, table[i].suffix)) {
-                                unsigned long long tmp;
-                                if ((unsigned long long) l + (frac > 0) > ULLONG_MAX / table[i].factor)
-                                        return -ERANGE;
-                                tmp = l * table[i].factor + (unsigned long long) (frac * table[i].factor);
-                                if (tmp > ULLONG_MAX - r)
-                                        return -ERANGE;
-
-                                r += tmp;
-                                if ((unsigned long long) (off_t) r != r)
-                                        return -ERANGE;
-
-                                p = e + strlen(table[i].suffix);
-
-                                start_pos = i + 1;
+                        if (startswith(e, table[i].suffix))
                                 break;
-                        }
 
                 if (i >= n_entries)
                         return -EINVAL;
 
+                if (l + (frac > 0) > ULLONG_MAX / table[i].factor)
+                        return -ERANGE;
+
+                tmp = l * table[i].factor + (unsigned long long) (frac * table[i].factor);
+                if (tmp > ULLONG_MAX - r)
+                        return -ERANGE;
+
+                r += tmp;
+                if ((unsigned long long) (uint64_t) r != r)
+                        return -ERANGE;
+
+                p = e + strlen(table[i].suffix);
+
+                start_pos = i + 1;
+
         } while (*p);
 
         *size = r;
@@ -3785,38 +3784,38 @@ int prot_from_flags(int flags) {
         }
 }
 
-char *format_bytes(char *buf, size_t l, off_t t) {
+char *format_bytes(char *buf, size_t l, uint64_t t) {
         unsigned i;
 
         static const struct {
                 const char *suffix;
-                off_t factor;
+                uint64_t factor;
         } table[] = {
-                { "E", 1024ULL*1024ULL*1024ULL*1024ULL*1024ULL*1024ULL },
-                { "P", 1024ULL*1024ULL*1024ULL*1024ULL*1024ULL },
-                { "T", 1024ULL*1024ULL*1024ULL*1024ULL },
-                { "G", 1024ULL*1024ULL*1024ULL },
-                { "M", 1024ULL*1024ULL },
-                { "K", 1024ULL },
+                { "E", UINT64_C(1024)*UINT64_C(1024)*UINT64_C(1024)*UINT64_C(1024)*UINT64_C(1024)*UINT64_C(1024) },
+                { "P", UINT64_C(1024)*UINT64_C(1024)*UINT64_C(1024)*UINT64_C(1024)*UINT64_C(1024) },
+                { "T", UINT64_C(1024)*UINT64_C(1024)*UINT64_C(1024)*UINT64_C(1024) },
+                { "G", UINT64_C(1024)*UINT64_C(1024)*UINT64_C(1024) },
+                { "M", UINT64_C(1024)*UINT64_C(1024) },
+                { "K", UINT64_C(1024) },
         };
 
-        if (t == (off_t) -1)
+        if (t == (uint64_t) -1)
                 return NULL;
 
         for (i = 0; i < ELEMENTSOF(table); i++) {
 
                 if (t >= table[i].factor) {
                         snprintf(buf, l,
-                                 "%llu.%llu%s",
-                                 (unsigned long long) (t / table[i].factor),
-                                 (unsigned long long) (((t*10ULL) / table[i].factor) % 10ULL),
+                                 "%" PRIu64 ".%" PRIu64 "%s",
+                                 t / table[i].factor,
+                                 ((t*UINT64_C(10)) / table[i].factor) % UINT64_C(10),
                                  table[i].suffix);
 
                         goto finish;
                 }
         }
 
-        snprintf(buf, l, "%lluB", (unsigned long long) t);
+        snprintf(buf, l, "%" PRIu64 "B", t);
 
 finish:
         buf[l-1] = 0;
index 5fa44b5cf31c9e86b28ce4a4448f16528f67c2da..c7dff9a86d8a3f3b4f532fda891f17e21c9c907d 100644 (file)
@@ -152,7 +152,7 @@ void close_many(const int fds[], unsigned n_fd);
 int fclose_nointr(FILE *f);
 FILE* safe_fclose(FILE *f);
 
-int parse_size(const char *t, off_t base, off_t *size);
+int parse_size(const char *t, uint64_t base, uint64_t *size);
 
 int parse_boolean(const char *v) _pure_;
 int parse_pid(const char *s, pid_t* ret_pid);
@@ -478,7 +478,7 @@ bool kexec_loaded(void);
 
 int prot_from_flags(int flags) _const_;
 
-char *format_bytes(char *buf, size_t l, off_t t);
+char *format_bytes(char *buf, size_t l, uint64_t t);
 
 int fd_wait_for_event(int fd, int event, usec_t timeout);
 
index 1c94bea31ae3050cffba07b69eb0a8a981857cf7..f26aeb39dfb73211d2f7d856508b0ac9e09ab932 100644 (file)
@@ -100,7 +100,7 @@ static void group_hashmap_free(Hashmap *h) {
         hashmap_free(h);
 }
 
-static const char *maybe_format_bytes(char *buf, size_t l, bool is_valid, off_t t) {
+static const char *maybe_format_bytes(char *buf, size_t l, bool is_valid, uint64_t t) {
         if (!is_valid)
                 return "-";
         if (arg_raw) {
index 3b02cd808542554c77ca5397b37475cdb4eeb36b..00cc6f7373db4eb128b44a02d5c4ae5f720b6a8a 100644 (file)
@@ -2683,7 +2683,7 @@ int config_parse_memory_limit(
                 void *userdata) {
 
         CGroupContext *c = data;
-        off_t bytes;
+        uint64_t bytes;
         int r;
 
         if (isempty(rvalue)) {
@@ -2691,8 +2691,6 @@ int config_parse_memory_limit(
                 return 0;
         }
 
-        assert_cc(sizeof(uint64_t) == sizeof(off_t));
-
         r = parse_size(rvalue, 1024, &bytes);
         if (r < 0) {
                 log_syntax(unit, LOG_ERR, filename, line, EINVAL,
@@ -2700,7 +2698,7 @@ int config_parse_memory_limit(
                 return 0;
         }
 
-        c->memory_limit = (uint64_t) bytes;
+        c->memory_limit = bytes;
         return 0;
 }
 
@@ -2887,7 +2885,7 @@ int config_parse_blockio_bandwidth(
         CGroupBlockIODeviceBandwidth *b;
         CGroupContext *c = data;
         const char *bandwidth;
-        off_t bytes;
+        uint64_t bytes;
         bool read;
         size_t n;
         int r;
@@ -2941,7 +2939,7 @@ int config_parse_blockio_bandwidth(
 
         b->path = path;
         path = NULL;
-        b->bandwidth = (uint64_t) bytes;
+        b->bandwidth = bytes;
         b->read = read;
 
         LIST_PREPEND(device_bandwidths, c->blockio_device_bandwidths, b);
@@ -3614,7 +3612,7 @@ void unit_dump_config_items(FILE *f) {
                 { config_parse_int,                   "INTEGER" },
                 { config_parse_unsigned,              "UNSIGNED" },
                 { config_parse_iec_size,              "SIZE" },
-                { config_parse_iec_off,               "SIZE" },
+                { config_parse_iec_uint64,            "SIZE" },
                 { config_parse_si_size,               "SIZE" },
                 { config_parse_bool,                  "BOOLEAN" },
                 { config_parse_string,                "STRING" },
index 44e029ef98fdf5242f4c0c10690fa75e101e884a..0e77197e34e7048e05ccb5336164426eb4548a53 100644 (file)
@@ -314,7 +314,7 @@ static int raw_pull_make_local_copy(RawPull *i) {
         if (r < 0)
                 log_warning_errno(errno, "Failed to set file attributes on %s: %m", tp);
 
-        r = copy_bytes(i->raw_job->disk_fd, dfd, (off_t) -1, true);
+        r = copy_bytes(i->raw_job->disk_fd, dfd, (uint64_t) -1, true);
         if (r < 0) {
                 unlink(tp);
                 return log_error_errno(r, "Failed to make writable copy of image: %m");
index 383f6a6e9665b84ac280b9d3c57e8f0f847c4f70..c66043e50364d65638d15e0fbcfa1cdbc076383c 100644 (file)
@@ -342,11 +342,10 @@ int decompress_startswith(int compression,
                 return -EBADMSG;
 }
 
-int compress_stream_xz(int fdf, int fdt, off_t max_bytes) {
+int compress_stream_xz(int fdf, int fdt, uint64_t max_bytes) {
 #ifdef HAVE_XZ
         _cleanup_(lzma_end) lzma_stream s = LZMA_STREAM_INIT;
         lzma_ret ret;
-
         uint8_t buf[BUFSIZ], out[BUFSIZ];
         lzma_action action = LZMA_RUN;
 
@@ -364,8 +363,8 @@ int compress_stream_xz(int fdf, int fdt, off_t max_bytes) {
                         size_t m = sizeof(buf);
                         ssize_t n;
 
-                        if (max_bytes != -1 && m > (size_t) max_bytes)
-                                m = max_bytes;
+                        if (max_bytes != (uint64_t) -1 && (uint64_t) m > max_bytes)
+                                m = (size_t) max_bytes;
 
                         n = read(fdf, buf, m);
                         if (n < 0)
@@ -376,8 +375,8 @@ int compress_stream_xz(int fdf, int fdt, off_t max_bytes) {
                                 s.next_in = buf;
                                 s.avail_in = n;
 
-                                if (max_bytes != -1) {
-                                        assert(max_bytes >= n);
+                                if (max_bytes != (uint64_t) -1) {
+                                        assert(max_bytes >= (uint64_t) n);
                                         max_bytes -= n;
                                 }
                         }
@@ -419,7 +418,7 @@ int compress_stream_xz(int fdf, int fdt, off_t max_bytes) {
 
 #define LZ4_BUFSIZE (512*1024)
 
-int compress_stream_lz4(int fdf, int fdt, off_t max_bytes) {
+int compress_stream_lz4(int fdf, int fdt, uint64_t max_bytes) {
 
 #ifdef HAVE_LZ4
 
@@ -445,8 +444,8 @@ int compress_stream_lz4(int fdf, int fdt, off_t max_bytes) {
                 int r;
 
                 m = LZ4_BUFSIZE;
-                if (max_bytes != -1 && m > (size_t) max_bytes - total_in)
-                        m = max_bytes - total_in;
+                if (max_bytes != (uint64_t) -1 && (uint64_t) m > (max_bytes - total_in))
+                        m = (size_t) (max_bytes - total_in);
 
                 n = read(fdf, buf, m);
                 if (n < 0)
@@ -497,7 +496,7 @@ int compress_stream_lz4(int fdf, int fdt, off_t max_bytes) {
 #endif
 }
 
-int decompress_stream_xz(int fdf, int fdt, off_t max_bytes) {
+int decompress_stream_xz(int fdf, int fdt, uint64_t max_bytes) {
 
 #ifdef HAVE_XZ
         _cleanup_(lzma_end) lzma_stream s = LZMA_STREAM_INIT;
@@ -546,8 +545,8 @@ int decompress_stream_xz(int fdf, int fdt, off_t max_bytes) {
 
                         n = sizeof(out) - s.avail_out;
 
-                        if (max_bytes != -1) {
-                                if (max_bytes < n)
+                        if (max_bytes != (uint64_t) -1) {
+                                if (max_bytes < (uint64_t) n)
                                         return -EFBIG;
 
                                 max_bytes -= n;
@@ -572,7 +571,7 @@ int decompress_stream_xz(int fdf, int fdt, off_t max_bytes) {
 #endif
 }
 
-int decompress_stream_lz4(int fdf, int fdt, off_t max_bytes) {
+int decompress_stream_lz4(int fdf, int fdt, uint64_t max_bytes) {
 
 #ifdef HAVE_LZ4
         _cleanup_free_ char *buf = NULL, *out = NULL;
@@ -626,8 +625,8 @@ int decompress_stream_lz4(int fdf, int fdt, off_t max_bytes) {
 
                 total_out += r;
 
-                if (max_bytes != -1 && total_out > (size_t) max_bytes) {
-                        log_debug("Decompressed stream longer than %zd bytes", max_bytes);
+                if (max_bytes != (uint64_t) -1 && (uint64_t) total_out > max_bytes) {
+                        log_debug("Decompressed stream longer than %" PRIu64 " bytes", max_bytes);
                         return -EFBIG;
                 }
 
@@ -647,7 +646,7 @@ int decompress_stream_lz4(int fdf, int fdt, off_t max_bytes) {
 #endif
 }
 
-int decompress_stream(const char *filename, int fdf, int fdt, off_t max_bytes) {
+int decompress_stream(const char *filename, int fdf, int fdt, uint64_t max_bytes) {
 
         if (endswith(filename, ".lz4"))
                 return decompress_stream_lz4(fdf, fdt, max_bytes);
index 6294f16faad8a099f25cf107ba92f18fec46b739..9a065eb763baca54721e9950bb72260518d72a30 100644 (file)
@@ -67,11 +67,11 @@ int decompress_startswith(int compression,
                           const void *prefix, size_t prefix_len,
                           uint8_t extra);
 
-int compress_stream_xz(int fdf, int fdt, off_t max_bytes);
-int compress_stream_lz4(int fdf, int fdt, off_t max_bytes);
+int compress_stream_xz(int fdf, int fdt, uint64_t max_bytes);
+int compress_stream_lz4(int fdf, int fdt, uint64_t max_bytes);
 
-int decompress_stream_xz(int fdf, int fdt, off_t max_size);
-int decompress_stream_lz4(int fdf, int fdt, off_t max_size);
+int decompress_stream_xz(int fdf, int fdt, uint64_t max_size);
+int decompress_stream_lz4(int fdf, int fdt, uint64_t max_size);
 
 #ifdef HAVE_LZ4
 #  define compress_stream compress_stream_lz4
@@ -81,4 +81,4 @@ int decompress_stream_lz4(int fdf, int fdt, off_t max_size);
 #  define COMPRESSED_EXT ".xz"
 #endif
 
-int decompress_stream(const char *filename, int fdf, int fdt, off_t max_bytes);
+int decompress_stream(const char *filename, int fdf, int fdt, uint64_t max_bytes);
index c0347ef5690e4f4ebc7e75139e16b3a55e0c95a5..efe418615a6cd26c9bf5217e65bc4d15c7ecc8cd 100644 (file)
 
 #include "coredump-vacuum.h"
 
-#define DEFAULT_MAX_USE_LOWER (off_t) (1ULL*1024ULL*1024ULL)           /* 1 MiB */
-#define DEFAULT_MAX_USE_UPPER (off_t) (4ULL*1024ULL*1024ULL*1024ULL)   /* 4 GiB */
-#define DEFAULT_KEEP_FREE_UPPER (off_t) (4ULL*1024ULL*1024ULL*1024ULL) /* 4 GiB */
-#define DEFAULT_KEEP_FREE (off_t) (1024ULL*1024ULL)                    /* 1 MB */
+#define DEFAULT_MAX_USE_LOWER (uint64_t) (1ULL*1024ULL*1024ULL)           /* 1 MiB */
+#define DEFAULT_MAX_USE_UPPER (uint64_t) (4ULL*1024ULL*1024ULL*1024ULL)   /* 4 GiB */
+#define DEFAULT_KEEP_FREE_UPPER (uint64_t) (4ULL*1024ULL*1024ULL*1024ULL) /* 4 GiB */
+#define DEFAULT_KEEP_FREE (uint64_t) (1024ULL*1024ULL)                    /* 1 MB */
 
 struct vacuum_candidate {
         unsigned n_files;
@@ -82,8 +82,8 @@ static int uid_from_file_name(const char *filename, uid_t *uid) {
         return parse_uid(u, uid);
 }
 
-static bool vacuum_necessary(int fd, off_t sum, off_t keep_free, off_t max_use) {
-        off_t fs_size = 0, fs_free = (off_t) -1;
+static bool vacuum_necessary(int fd, uint64_t sum, uint64_t keep_free, uint64_t max_use) {
+        uint64_t fs_size = 0, fs_free = (uint64_t) -1;
         struct statvfs sv;
 
         assert(fd >= 0);
@@ -93,7 +93,7 @@ static bool vacuum_necessary(int fd, off_t sum, off_t keep_free, off_t max_use)
                 fs_free = sv.f_frsize * sv.f_bfree;
         }
 
-        if (max_use == (off_t) -1) {
+        if (max_use == (uint64_t) -1) {
 
                 if (fs_size > 0) {
                         max_use = PAGE_ALIGN(fs_size / 10); /* 10% */
@@ -111,7 +111,7 @@ static bool vacuum_necessary(int fd, off_t sum, off_t keep_free, off_t max_use)
         if (max_use > 0 && sum > max_use)
                 return true;
 
-        if (keep_free == (off_t) -1) {
+        if (keep_free == (uint64_t) -1) {
 
                 if (fs_size > 0) {
                         keep_free = PAGE_ALIGN((fs_size * 3) / 20); /* 15% */
@@ -129,7 +129,7 @@ static bool vacuum_necessary(int fd, off_t sum, off_t keep_free, off_t max_use)
         return false;
 }
 
-int coredump_vacuum(int exclude_fd, off_t keep_free, off_t max_use) {
+int coredump_vacuum(int exclude_fd, uint64_t keep_free, uint64_t max_use) {
         _cleanup_closedir_ DIR *d = NULL;
         struct stat exclude_st;
         int r;
@@ -161,7 +161,7 @@ int coredump_vacuum(int exclude_fd, off_t keep_free, off_t max_use) {
                 _cleanup_(vacuum_candidate_hasmap_freep) Hashmap *h = NULL;
                 struct vacuum_candidate *worst = NULL;
                 struct dirent *de;
-                off_t sum = 0;
+                uint64_t sum = 0;
 
                 rewinddir(d);
 
index 7ad4399305372943f92528e634a9f753ffc95a38..7779c975746b940f75630d016a308dba1bd9527d 100644 (file)
@@ -21,6 +21,7 @@
   along with systemd; If not, see <http://www.gnu.org/licenses/>.
 ***/
 
+#include <inttypes.h>
 #include <sys/types.h>
 
-int coredump_vacuum(int exclude_fd, off_t keep_free, off_t max_use);
+int coredump_vacuum(int exclude_fd, uint64_t keep_free, uint64_t max_use);
index 7d94b145c960fd4da24bb5246eac8ed583d53db6..e1e66b982623acdff0e324fc2e2b779ac371ddfa 100644 (file)
@@ -51,7 +51,7 @@
 #include "process-util.h"
 
 /* The maximum size up to which we process coredumps */
-#define PROCESS_SIZE_MAX ((off_t) (2LLU*1024LLU*1024LLU*1024LLU))
+#define PROCESS_SIZE_MAX ((uint64_t) (2LLU*1024LLU*1024LLU*1024LLU))
 
 /* The maximum size up to which we leave the coredump around on
  * disk */
@@ -97,21 +97,21 @@ static DEFINE_CONFIG_PARSE_ENUM(config_parse_coredump_storage, coredump_storage,
 
 static CoredumpStorage arg_storage = COREDUMP_STORAGE_EXTERNAL;
 static bool arg_compress = true;
-static off_t arg_process_size_max = PROCESS_SIZE_MAX;
-static off_t arg_external_size_max = EXTERNAL_SIZE_MAX;
+static uint64_t arg_process_size_max = PROCESS_SIZE_MAX;
+static uint64_t arg_external_size_max = EXTERNAL_SIZE_MAX;
 static size_t arg_journal_size_max = JOURNAL_SIZE_MAX;
-static off_t arg_keep_free = (off_t) -1;
-static off_t arg_max_use = (off_t) -1;
+static uint64_t arg_keep_free = (uint64_t) -1;
+static uint64_t arg_max_use = (uint64_t) -1;
 
 static int parse_config(void) {
         static const ConfigTableItem items[] = {
                 { "Coredump", "Storage",          config_parse_coredump_storage,  0, &arg_storage           },
                 { "Coredump", "Compress",         config_parse_bool,              0, &arg_compress          },
-                { "Coredump", "ProcessSizeMax",   config_parse_iec_off,           0, &arg_process_size_max  },
-                { "Coredump", "ExternalSizeMax",  config_parse_iec_off,           0, &arg_external_size_max },
+                { "Coredump", "ProcessSizeMax",   config_parse_iec_uint64,        0, &arg_process_size_max  },
+                { "Coredump", "ExternalSizeMax",  config_parse_iec_uint64,        0, &arg_external_size_max },
                 { "Coredump", "JournalSizeMax",   config_parse_iec_size,          0, &arg_journal_size_max  },
-                { "Coredump", "KeepFree",         config_parse_iec_off,           0, &arg_keep_free         },
-                { "Coredump", "MaxUse",           config_parse_iec_off,           0, &arg_max_use           },
+                { "Coredump", "KeepFree",         config_parse_iec_uint64,        0, &arg_keep_free         },
+                { "Coredump", "MaxUse",           config_parse_iec_uint64,        0, &arg_max_use           },
                 {}
         };
 
@@ -224,7 +224,7 @@ static int fix_permissions(
         return 0;
 }
 
-static int maybe_remove_external_coredump(const char *filename, off_t size) {
+static int maybe_remove_external_coredump(const char *filename, uint64_t size) {
 
         /* Returns 1 if might remove, 0 if will not remove, < 0 on error. */
 
@@ -285,7 +285,7 @@ static int save_external_coredump(
                 uid_t uid,
                 char **ret_filename,
                 int *ret_fd,
-                off_t *ret_size) {
+                uint64_t *ret_size) {
 
         _cleanup_free_ char *fn = NULL, *tmp = NULL;
         _cleanup_close_ int fd = -1;
@@ -372,9 +372,9 @@ static int save_external_coredump(
                 /* OK, this worked, we can get rid of the uncompressed version now */
                 unlink_noerrno(tmp);
 
-                *ret_filename = fn_compressed;    /* compressed */
-                *ret_fd = fd;                     /* uncompressed */
-                *ret_size = st.st_size;           /* uncompressed */
+                *ret_filename = fn_compressed;     /* compressed */
+                *ret_fd = fd;                      /* uncompressed */
+                *ret_size = (uint64_t) st.st_size; /* uncompressed */
 
                 fn_compressed = NULL;
                 fd = -1;
@@ -393,7 +393,7 @@ uncompressed:
 
         *ret_filename = fn;
         *ret_fd = fd;
-        *ret_size = st.st_size;
+        *ret_size = (uint64_t) st.st_size;
 
         fn = NULL;
         fd = -1;
@@ -544,7 +544,7 @@ int main(int argc, char* argv[]) {
         _cleanup_close_ int coredump_fd = -1;
 
         struct iovec iovec[26];
-        off_t coredump_size;
+        uint64_t coredump_size;
         int r, j = 0;
         uid_t uid, owner_uid;
         gid_t gid;
@@ -840,7 +840,7 @@ log:
 
         /* Optionally store the entire coredump in the journal */
         if (IN_SET(arg_storage, COREDUMP_STORAGE_JOURNAL, COREDUMP_STORAGE_BOTH) &&
-            coredump_size <= (off_t) arg_journal_size_max) {
+            coredump_size <= arg_journal_size_max) {
                 size_t sz = 0;
 
                 /* Store the coredump itself in the journal */
index 4f94799ce74708dbbb6b7536f19336043f1154f4..73d3a4bb9d2307f27a6484551fcb420b24c58f4b 100644 (file)
@@ -2542,7 +2542,7 @@ void journal_file_print_header(JournalFile *f) {
                        le64toh(f->header->n_entry_arrays));
 
         if (fstat(f->fd, &st) >= 0)
-                printf("Disk usage: %s\n", format_bytes(bytes, sizeof(bytes), (off_t) st.st_blocks * 512ULL));
+                printf("Disk usage: %s\n", format_bytes(bytes, sizeof(bytes), (uint64_t) st.st_blocks * 512ULL));
 }
 
 static int journal_file_warn_btrfs(JournalFile *f) {
index 576e4e4d0354c7a2e3709da9c488838332bd216a..9b483413e778fb4489842dc9ca725143bd0f7a6f 100644 (file)
@@ -107,7 +107,7 @@ static bool arg_reverse = false;
 static int arg_journal_type = 0;
 static const char *arg_root = NULL;
 static const char *arg_machine = NULL;
-static off_t arg_vacuum_size = (off_t) -1;
+static uint64_t arg_vacuum_size = (uint64_t) -1;
 static usec_t arg_vacuum_time = USEC_INFINITY;
 
 static enum {
index 74554c1c342f1472a448b28bd8e5ca23a90994b9..bf7c773009ca974a3cebc50012bb479ede328132 100644 (file)
@@ -21,12 +21,12 @@ Journal.Seal,               config_parse_bool,       0, offsetof(Server, seal)
 Journal.SyncIntervalSec,    config_parse_sec,        0, offsetof(Server, sync_interval_usec)
 Journal.RateLimitInterval,  config_parse_sec,        0, offsetof(Server, rate_limit_interval)
 Journal.RateLimitBurst,     config_parse_unsigned,   0, offsetof(Server, rate_limit_burst)
-Journal.SystemMaxUse,       config_parse_iec_off,    0, offsetof(Server, system_metrics.max_use)
-Journal.SystemMaxFileSize,  config_parse_iec_off,    0, offsetof(Server, system_metrics.max_size)
-Journal.SystemKeepFree,     config_parse_iec_off,    0, offsetof(Server, system_metrics.keep_free)
-Journal.RuntimeMaxUse,      config_parse_iec_off,    0, offsetof(Server, runtime_metrics.max_use)
-Journal.RuntimeMaxFileSize, config_parse_iec_off,    0, offsetof(Server, runtime_metrics.max_size)
-Journal.RuntimeKeepFree,    config_parse_iec_off,    0, offsetof(Server, runtime_metrics.keep_free)
+Journal.SystemMaxUse,       config_parse_iec_uint64, 0, offsetof(Server, system_metrics.max_use)
+Journal.SystemMaxFileSize,  config_parse_iec_uint64, 0, offsetof(Server, system_metrics.max_size)
+Journal.SystemKeepFree,     config_parse_iec_uint64, 0, offsetof(Server, system_metrics.keep_free)
+Journal.RuntimeMaxUse,      config_parse_iec_uint64, 0, offsetof(Server, runtime_metrics.max_use)
+Journal.RuntimeMaxFileSize, config_parse_iec_uint64, 0, offsetof(Server, runtime_metrics.max_size)
+Journal.RuntimeKeepFree,    config_parse_iec_uint64, 0, offsetof(Server, runtime_metrics.keep_free)
 Journal.MaxRetentionSec,    config_parse_sec,        0, offsetof(Server, max_retention_usec)
 Journal.MaxFileSec,         config_parse_sec,        0, offsetof(Server, max_file_usec)
 Journal.ForwardToSyslog,    config_parse_bool,       0, offsetof(Server, forward_to_syslog)
index 41a566d7144d44f5514080881749e7f135682857..f17c00e60dc36a08bad306ec14761725b6a0390f 100644 (file)
@@ -44,8 +44,8 @@ typedef int (decompress_sw_t)(const void *src, uint64_t src_size,
                               const void *prefix, size_t prefix_len,
                               uint8_t extra);
 
-typedef int (compress_stream_t)(int fdf, int fdt, off_t max_bytes);
-typedef int (decompress_stream_t)(int fdf, int fdt, off_t max_size);
+typedef int (compress_stream_t)(int fdf, int fdt, uint64_t max_bytes);
+typedef int (decompress_stream_t)(int fdf, int fdt, uint64_t max_size);
 
 static void test_compress_decompress(int compression,
                                      compress_blob_t compress,
index a4dd00125d20f532b4542c65e7984fd644941a1e..514dadc1dc2a980f3009bdf5a18903c7f5276e8c 100644 (file)
@@ -25,7 +25,7 @@
 
 int main(int argc, char *argv[]) {
 
-        if (coredump_vacuum(-1, (off_t) -1, 70 * 1024) < 0)
+        if (coredump_vacuum(-1, (uint64_t) -1, 70 * 1024) < 0)
                 return EXIT_FAILURE;
 
         return EXIT_SUCCESS;
index a1f0f30d6cdc39284e5ec44e208af9bb46424b95..9a6d338231c7b2408fef0996e823db0606587acf 100644 (file)
@@ -1823,20 +1823,20 @@ static int parse_argv(int argc, char *argv[]) {
                         break;
 
                 case ARG_SIZE: {
-                        off_t o;
+                        uint64_t sz;
 
-                        r = parse_size(optarg, 1024, &o);
+                        r = parse_size(optarg, 1024, &sz);
                         if (r < 0) {
                                 log_error("Failed to parse size: %s", optarg);
                                 return r;
                         }
 
-                        if ((off_t) (size_t) o !=  o) {
+                        if ((uint64_t) (size_t) sz !=  sz) {
                                 log_error("Size out of range.");
                                 return -E2BIG;
                         }
 
-                        arg_snaplen = (size_t) o;
+                        arg_snaplen = (size_t) sz;
                         break;
                 }
 
index f2c89e365336f107b0106fc5986d46d3310952b1..47669afdef75ff8e9edd98700217769693f13971 100644 (file)
@@ -879,15 +879,15 @@ int config_parse_tmpfs_size(
 
                 *sz = PAGE_ALIGN((size_t) ((physical_memory() * (uint64_t) ul) / (uint64_t) 100));
         } else {
-                off_t o;
+                uint64_t k;
 
-                r = parse_size(rvalue, 1024, &o);
-                if (r < 0 || (off_t) (size_t) o != o) {
-                        log_syntax(unit, LOG_ERR, filename, line, r < 0 ? -r : ERANGE, "Failed to parse size value, ignoring: %s", rvalue);
+                r = parse_size(rvalue, 1024, &k);
+                if (r < 0 || (uint64_t) (size_t) k != k) {
+                        log_syntax(unit, LOG_ERR, filename, line, r < 0 ? r : ERANGE, "Failed to parse size value, ignoring: %s", rvalue);
                         return 0;
                 }
 
-                *sz = PAGE_ALIGN((size_t) o);
+                *sz = PAGE_ALIGN((size_t) k);
         }
 
         return 0;
index cc3811670455d1bcdcec480559d3963d16b1c109..6aaaa8aa31e990f9b23559fa674b9392e0488f70 100644 (file)
@@ -423,7 +423,7 @@ int bus_machine_method_get_os_release(sd_bus_message *message, void *userdata, s
                                         _exit(EXIT_FAILURE);
                         }
 
-                        r = copy_bytes(fd, pair[1], (off_t) -1, false);
+                        r = copy_bytes(fd, pair[1], (uint64_t) -1, false);
                         if (r < 0)
                                 _exit(EXIT_FAILURE);
 
index 7b8f6d1fabe3deaad7a9fe08c96124967744180d..ab113efb2872b2eb91d7d1885e5b6ca1eba240cf 100644 (file)
@@ -2385,13 +2385,9 @@ static int set_limit(int argc, char *argv[], void *userdata) {
         if (streq(argv[argc-1], "-"))
                 limit = (uint64_t) -1;
         else {
-                off_t off;
-
-                r = parse_size(argv[argc-1], 1024, &off);
+                r = parse_size(argv[argc-1], 1024, &limit);
                 if (r < 0)
                         return log_error("Failed to parse size: %s", argv[argc-1]);
-
-                limit = (uint64_t) off;
         }
 
         if (argc > 2)
index 33943a4b2f0b0847505c56ed23277f707130450a..5702df8ab47c6716ae83afb461803038eec91f3d 100644 (file)
@@ -3601,7 +3601,7 @@ finish:
 
         /* Try to flush whatever is still queued in the pty */
         if (master >= 0)
-                (void) copy_bytes(master, STDOUT_FILENO, (off_t) -1, false);
+                (void) copy_bytes(master, STDOUT_FILENO, (uint64_t) -1, false);
 
         loop_remove(loop_nr, &image_fd);
 
index 36c44227c5fe9cb6fe81f64bf70864597e0c5907..64a810fc8f9daf35acd04fb5e184f152cdf7bd9c 100644 (file)
@@ -1434,7 +1434,7 @@ int bus_append_unit_property_assignment(sd_bus_message *m, const char *assignmen
                 r = sd_bus_message_append(m, "v", "b", r);
 
         } else if (streq(field, "MemoryLimit")) {
-                off_t bytes;
+                uint64_t bytes;
 
                 r = parse_size(eq, 1024, &bytes);
                 if (r < 0) {
@@ -1442,7 +1442,7 @@ int bus_append_unit_property_assignment(sd_bus_message *m, const char *assignmen
                         return -EINVAL;
                 }
 
-                r = sd_bus_message_append(m, "v", "t", (uint64_t) bytes);
+                r = sd_bus_message_append(m, "v", "t", bytes);
 
         } else if (STR_IN_SET(field, "CPUShares", "BlockIOWeight")) {
                 uint64_t u;
@@ -1492,7 +1492,7 @@ int bus_append_unit_property_assignment(sd_bus_message *m, const char *assignmen
                         r = sd_bus_message_append(m, "v", "a(st)", 0);
                 else {
                         const char *path, *bandwidth, *e;
-                        off_t bytes;
+                        uint64_t bytes;
 
                         e = strchr(eq, ' ');
                         if (e) {
@@ -1514,7 +1514,7 @@ int bus_append_unit_property_assignment(sd_bus_message *m, const char *assignmen
                                 return -EINVAL;
                         }
 
-                        r = sd_bus_message_append(m, "v", "a(st)", 1, path, (uint64_t) bytes);
+                        r = sd_bus_message_append(m, "v", "a(st)", 1, path, bytes);
                 }
 
         } else if (streq(field, "BlockIODeviceWeight")) {
index 23512f0d354153c5310c9650a549f9f7664f09df..946eac6823fd99e45e310229fedb41a0bd0f922a 100644 (file)
@@ -469,7 +469,7 @@ int config_parse_iec_size(const char* unit,
                             void *userdata) {
 
         size_t *sz = data;
-        off_t o;
+        uint64_t v;
         int r;
 
         assert(filename);
@@ -477,13 +477,13 @@ int config_parse_iec_size(const char* unit,
         assert(rvalue);
         assert(data);
 
-        r = parse_size(rvalue, 1024, &o);
-        if (r < 0 || (off_t) (size_t) o != o) {
-                log_syntax(unit, LOG_ERR, filename, line, r < 0 ? -r : ERANGE, "Failed to parse size value, ignoring: %s", rvalue);
+        r = parse_size(rvalue, 1024, &v);
+        if (r < 0 || (uint64_t) (size_t) v != v) {
+                log_syntax(unit, LOG_ERR, filename, line, r < 0 ? r : ERANGE, "Failed to parse size value, ignoring: %s", rvalue);
                 return 0;
         }
 
-        *sz = (size_t) o;
+        *sz = (size_t) v;
         return 0;
 }
 
@@ -499,7 +499,7 @@ int config_parse_si_size(const char* unit,
                             void *userdata) {
 
         size_t *sz = data;
-        off_t o;
+        uint64_t v;
         int r;
 
         assert(filename);
@@ -507,17 +507,17 @@ int config_parse_si_size(const char* unit,
         assert(rvalue);
         assert(data);
 
-        r = parse_size(rvalue, 1000, &o);
-        if (r < 0 || (off_t) (size_t) o != o) {
-                log_syntax(unit, LOG_ERR, filename, line, r < 0 ? -r : ERANGE, "Failed to parse size value, ignoring: %s", rvalue);
+        r = parse_size(rvalue, 1000, &v);
+        if (r < 0 || (uint64_t) (size_t) v != v) {
+                log_syntax(unit, LOG_ERR, filename, line, r < 0 ? r : ERANGE, "Failed to parse size value, ignoring: %s", rvalue);
                 return 0;
         }
 
-        *sz = (size_t) o;
+        *sz = (size_t) v;
         return 0;
 }
 
-int config_parse_iec_off(const char* unit,
+int config_parse_iec_uint64(const char* unit,
                            const char *filename,
                            unsigned line,
                            const char *section,
@@ -528,7 +528,7 @@ int config_parse_iec_off(const char* unit,
                            void *data,
                            void *userdata) {
 
-        off_t *bytes = data;
+        uint64_t *bytes = data;
         int r;
 
         assert(filename);
@@ -536,11 +536,9 @@ int config_parse_iec_off(const char* unit,
         assert(rvalue);
         assert(data);
 
-        assert_cc(sizeof(off_t) == sizeof(uint64_t));
-
         r = parse_size(rvalue, 1024, bytes);
         if (r < 0)
-                log_syntax(unit, LOG_ERR, filename, line, -r, "Failed to parse size value, ignoring: %s", rvalue);
+                log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse size value, ignoring: %s", rvalue);
 
         return 0;
 }
index 34e3815782d0786d8d15e88562ca1de9e1ea0fe1..4efed138c9f69a11d96d3611f89c5965a4eb83b4 100644 (file)
@@ -109,7 +109,7 @@ int config_parse_uint64(const char *unit, const char *filename, unsigned line, c
 int config_parse_double(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line,  const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
 int config_parse_iec_size(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
 int config_parse_si_size(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
-int config_parse_iec_off(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
+int config_parse_iec_uint64(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
 int config_parse_bool(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
 int config_parse_tristate(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
 int config_parse_string(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
index 479a9d5e8dc56fd51db3667c8c36782c3232f53a..41da820938bed34b7c1d417a6fc4ca1563b86694 100644 (file)
@@ -38,7 +38,7 @@ static pid_t pager_pid = 0;
 noreturn static void pager_fallback(void) {
         int r;
 
-        r = copy_bytes(STDIN_FILENO, STDOUT_FILENO, (off_t) -1, false);
+        r = copy_bytes(STDIN_FILENO, STDOUT_FILENO, (uint64_t) -1, false);
         if (r < 0) {
                 log_error_errno(r, "Internal pager failed: %m");
                 _exit(EXIT_FAILURE);
index 74d7fc2b3bfd1b4454e23935c9417578e10dbccc..ce94dc9edf7fc3e169b15455cf53fcd25f75bb31 100644 (file)
@@ -4623,7 +4623,7 @@ static int cat_file(const char *filename, bool newline) {
                ansi_highlight_off());
         fflush(stdout);
 
-        return copy_bytes(fd, STDOUT_FILENO, (off_t) -1, false);
+        return copy_bytes(fd, STDOUT_FILENO, (uint64_t) -1, false);
 }
 
 static int cat(sd_bus *bus, char **args) {
index b5e09cad26d91e460baa80ee70644c55d17ad5b0..aaa33354f490ce0f0021cb8a98b4940f775b5c8d 100644 (file)
@@ -207,7 +207,7 @@ static int make_backup(const char *target, const char *x) {
         if (r < 0)
                 return r;
 
-        r = copy_bytes(src, fileno(dst), (off_t) -1, true);
+        r = copy_bytes(src, fileno(dst), (uint64_t) -1, true);
         if (r < 0)
                 goto fail;
 
index b73c958ec5755893e637fc1f1de0b4ec2bcdb2a2..a03a68bd43778353cdd52580b4813f9a536dfee3 100644 (file)
@@ -146,7 +146,7 @@ static void test_copy_bytes(void) {
 
         assert_se(pipe2(pipefd, O_CLOEXEC) == 0);
 
-        r = copy_bytes(infd, pipefd[1], (off_t) -1, false);
+        r = copy_bytes(infd, pipefd[1], (uint64_t) -1, false);
         assert_se(r == 0);
 
         r = read(pipefd[0], buf, sizeof(buf));
index 8ceb71f22a9fea63a7c6c712e1f7e6b0f30f8c3d..7935442dbb6966788a7543bfe6a445b419fad781 100644 (file)
@@ -893,7 +893,7 @@ static void test_protect_errno(void) {
 }
 
 static void test_parse_size(void) {
-        off_t bytes;
+        uint64_t bytes;
 
         assert_se(parse_size("111", 1024, &bytes) == 0);
         assert_se(bytes == 111);
@@ -960,12 +960,12 @@ static void test_parse_size(void) {
         assert_se(parse_size("-10B 20K", 1024, &bytes) == -ERANGE);
 }
 
-static void test_config_parse_iec_off(void) {
-        off_t offset = 0;
-        assert_se(config_parse_iec_off(NULL, "/this/file", 11, "Section", 22, "Size", 0, "4M", &offset, NULL) == 0);
+static void test_config_parse_iec_uint64(void) {
+        uint64_t offset = 0;
+        assert_se(config_parse_iec_uint64(NULL, "/this/file", 11, "Section", 22, "Size", 0, "4M", &offset, NULL) == 0);
         assert_se(offset == 4 * 1024 * 1024);
 
-        assert_se(config_parse_iec_off(NULL, "/this/file", 11, "Section", 22, "Size", 0, "4.5M", &offset, NULL) == 0);
+        assert_se(config_parse_iec_uint64(NULL, "/this/file", 11, "Section", 22, "Size", 0, "4.5M", &offset, NULL) == 0);
 }
 
 static void test_strextend(void) {
@@ -2250,7 +2250,7 @@ int main(int argc, char *argv[]) {
         test_u64log2();
         test_protect_errno();
         test_parse_size();
-        test_config_parse_iec_off();
+        test_config_parse_iec_uint64();
         test_strextend();
         test_strrep();
         test_split_pair();