]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test-compress-benchmark: fix argument parsing on 32bit
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sat, 2 Apr 2016 21:46:49 +0000 (17:46 -0400)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sat, 2 Apr 2016 22:58:21 +0000 (18:58 -0400)
The patch is not minimal, but a function to parse size_t is probably
going to come in handy in other places, so I think it's nicer to define
a proper parsing function than to open-code the cast.

src/basic/copy.c
src/basic/parse-util.h
src/journal/test-compress-benchmark.c

index 41dc8ca79a60314362fb9ebc0c6d19ead654f991..10c03a8b52f80eb0b2d7beade046f64b41195c01 100644 (file)
@@ -71,7 +71,7 @@ static ssize_t try_copy_file_range(int fd_in, loff_t *off_in,
 int copy_bytes(int fdf, int fdt, uint64_t max_bytes, bool try_reflink) {
         bool try_cfr = true, try_sendfile = true, try_splice = true;
         int r;
-        size_t m = SSIZE_MAX; /* that the maximum that sendfile and c_f_r accept */
+        size_t m = SSIZE_MAX; /* that is the maximum that sendfile and c_f_r accept */
 
         assert(fdf >= 0);
         assert(fdt >= 0);
index d8dc26a36e97625804cdf926d00ca5117dc0dc22..c407263e166eb447acffc845467f8d9be5313a8f 100644 (file)
@@ -90,6 +90,18 @@ static inline int safe_atoli(const char *s, long int *ret_u) {
 }
 #endif
 
+#if SIZE_MAX == UINT_MAX
+static inline int safe_atozu(const char *s, size_t *ret_u) {
+        assert_cc(sizeof(size_t) == sizeof(unsigned));
+        return safe_atou(s, ret_u);
+}
+#else
+static inline int safe_atozu(const char *s, size_t *ret_u) {
+        assert_cc(sizeof(size_t) == sizeof(long unsigned));
+        return safe_atolu(s, ret_u);
+}
+#endif
+
 int safe_atod(const char *s, double *ret_d);
 
 int parse_fractional_part_u(const char **s, size_t digits, unsigned *res);
index 0ef6d36a507b577922e4815d2ccba27738a71da9..6f6d71435d21419d51e7a29f1ba8b18ec6a6ff4f 100644 (file)
@@ -164,7 +164,7 @@ int main(int argc, char *argv[]) {
                 arg_duration = x * USEC_PER_SEC;
         }
         if (argc == 3)
-                (void) safe_atolu(argv[2], &arg_start);
+                (void) safe_atozu(argv[2], &arg_start);
         else
                 arg_start = getpid();