Fix types when printing
authorJonathan Dieter <jdieter@gmail.com>
Sat, 5 Feb 2022 16:26:08 +0000 (16:26 +0000)
committerJonathan Dieter <jdieter@gmail.com>
Sat, 5 Feb 2022 17:03:38 +0000 (17:03 +0000)
Signed-off-by: Jonathan Dieter <jdieter@gmail.com>
21 files changed:
src/lib/comp/comp.c
src/lib/comp/zstd/zstd.c
src/lib/dl/dl.c
src/lib/dl/multipart.c
src/lib/dl/range.c
src/lib/hash/hash.c
src/lib/header.c
src/lib/index/index_create.c
src/lib/index/index_read.c
src/lib/io.c
src/lib/zck.c
src/unzck.c
src/zck.c
src/zck_delta_size.c
src/zck_dl.c
src/zck_gen_zdict.c
src/zck_read_header.c
test/empty.c
test/optelems.c
test/read_single_chunk.c
test/read_single_comp_chunk.c

index b2b5384a23c2f99e50e54b02f6e8a73d16983579..1fb1db46f6620624ff7d7722775bf14e076acf80 100644 (file)
@@ -104,8 +104,8 @@ static size_t comp_read_from_dc(zckCtx *zck, zckComp *comp, char *dst,
     memcpy(dst, comp->dc_data+comp->dc_data_loc, dl_size);
     comp->dc_data_loc += dl_size;
     if(dl_size > 0)
-        zck_log(ZCK_LOG_DEBUG, "Reading %lu bytes from decompressed buffer",
-                dl_size);
+        zck_log(ZCK_LOG_DEBUG, "Reading %llu bytes from decompressed buffer",
+                (long long unsigned) dl_size);
     return dl_size;
 }
 
@@ -120,8 +120,8 @@ static bool comp_add_to_data(zckCtx *zck, zckComp *comp, const char *src,
         zck_log(ZCK_LOG_ERROR, "OOM in %s", __func__);
         return false;
     }
-    zck_log(ZCK_LOG_DEBUG, "Adding %lu bytes to compressed buffer",
-        src_size);
+    zck_log(ZCK_LOG_DEBUG, "Adding %llu bytes to compressed buffer",
+        (long long unsigned) src_size);
     memcpy(comp->data + comp->data_size, src, src_size);
     comp->data_size += src_size;
     comp->data_loc += src_size;
@@ -189,31 +189,31 @@ bool comp_init(zckCtx *zck) {
     if(zck->mode == ZCK_MODE_WRITE) {
         if(zck->chunk_min_size == 0) {
             zck->chunk_min_size = CHUNK_DEFAULT_MIN;
-            zck_log(ZCK_LOG_DEBUG, "Using default minimum chunk size of %lu",
-                    zck->chunk_min_size);
+            zck_log(ZCK_LOG_DEBUG, "Using default minimum chunk size of %llu",
+                    (long long unsigned) zck->chunk_min_size);
         }
         if(zck->chunk_max_size == 0) {
             zck->chunk_max_size = CHUNK_DEFAULT_MAX;
-            zck_log(ZCK_LOG_DEBUG, "Using default maximum chunk size of %lu",
-                    zck->chunk_max_size);
+            zck_log(ZCK_LOG_DEBUG, "Using default maximum chunk size of %llu",
+                    (long long unsigned) zck->chunk_max_size);
         }
         if(zck->manual_chunk == 0) {
             zck_log(ZCK_LOG_DEBUG, "Using buzhash algorithm for chunking");
             zck->buzhash_width = DEFAULT_BUZHASH_WIDTH;
             zck->buzhash_match_bits = DEFAULT_BUZHASH_BITS;
             update_buzhash_bits(zck);
-            zck_log(ZCK_LOG_DEBUG, "Setting average chunk size to %lu",
-                    zck->buzhash_bitmask + 1);
+            zck_log(ZCK_LOG_DEBUG, "Setting average chunk size to %llu",
+                    (long long unsigned) zck->buzhash_bitmask + 1);
             zck->chunk_auto_min = (zck->buzhash_bitmask + 1) / 4;
             if(zck->chunk_auto_min < zck->chunk_min_size)
                 zck->chunk_auto_min = zck->chunk_min_size;
-            zck_log(ZCK_LOG_DEBUG, "Setting automatic minimum chunk size to %lu",
-                    zck->chunk_auto_min);
+            zck_log(ZCK_LOG_DEBUG, "Setting automatic minimum chunk size to %llu",
+                    (long long unsigned) zck->chunk_auto_min);
             zck->chunk_auto_max = (zck->buzhash_bitmask + 1) * 4;
             if(zck->chunk_auto_max > zck->chunk_max_size)
                 zck->chunk_auto_max = zck->chunk_max_size;
-            zck_log(ZCK_LOG_DEBUG, "Setting automatic maximum chunk size to %lu",
-                    zck->chunk_auto_max);
+            zck_log(ZCK_LOG_DEBUG, "Setting automatic maximum chunk size to %llu",
+                    (long long unsigned) zck->chunk_auto_max);
         }
     }
 
@@ -338,7 +338,7 @@ bool comp_ioption(zckCtx *zck, zck_ioption option, ssize_t value) {
             return false;
         }
         zck->chunk_min_size = value;
-        zck_log(ZCK_LOG_DEBUG, "Setting minimum chunk size to %li", value);
+        zck_log(ZCK_LOG_DEBUG, "Setting minimum chunk size to %lli", (long long) value);
         return true;
 
     /* Maximum chunk size */
@@ -353,7 +353,7 @@ bool comp_ioption(zckCtx *zck, zck_ioption option, ssize_t value) {
             return false;
         }
         zck->chunk_max_size = value;
-        zck_log(ZCK_LOG_DEBUG, "Setting maximum chunk size to %li", value);
+        zck_log(ZCK_LOG_DEBUG, "Setting maximum chunk size to %lli", (long long) value);
         return true;
 
     } else {
@@ -378,7 +378,7 @@ bool comp_soption(zckCtx *zck, zck_soption option, const void *value,
         return false;
     }
     if(option == ZCK_COMP_DICT) {
-        zck_log(ZCK_LOG_DEBUG, "Adding dictionary of size %li", length);
+        zck_log(ZCK_LOG_DEBUG, "Adding dictionary of size %lli", (long long) length);
         zck->comp.dict = (char *)value;
         zck->comp.dict_size = length;
     } else {
@@ -404,10 +404,10 @@ bool comp_add_to_dc(zckCtx *zck, zckComp *comp, const char *src,
         return false;
     }
     if(comp->dc_data_loc != 0)
-        zck_log(ZCK_LOG_DEBUG, "Freeing %lu bytes from decompressed buffer",
-                comp->dc_data_loc);
-    zck_log(ZCK_LOG_DEBUG, "Adding %lu bytes to decompressed buffer",
-            src_size);
+        zck_log(ZCK_LOG_DEBUG, "Freeing %llu bytes from decompressed buffer",
+                (long long unsigned) comp->dc_data_loc);
+    zck_log(ZCK_LOG_DEBUG, "Adding %llu bytes to decompressed buffer",
+            (long long unsigned) src_size);
     memcpy(temp, comp->dc_data + comp->dc_data_loc,
            comp->dc_data_size - comp->dc_data_loc);
     free(comp->dc_data);
@@ -445,7 +445,7 @@ ssize_t comp_read(zckCtx *zck, char *dst, size_t dst_size, bool use_dict) {
     }
     bool finished_rd = false;
     bool finished_dc = false;
-    zck_log(ZCK_LOG_DEBUG, "Trying to read %lu bytes", dst_size);
+    zck_log(ZCK_LOG_DEBUG, "Trying to read %llu bytes", (long long unsigned) dst_size);
     while(dc < dst_size) {
         /* Get bytes from decompressed buffer */
         ssize_t rb = comp_read_from_dc(zck, &(zck->comp), dst+dc, dst_size-dc);
@@ -652,7 +652,7 @@ ssize_t ZCK_PUBLIC_API zck_end_chunk(zckCtx *zck) {
         free(dst);
         return -1;
     }
-    zck_log(ZCK_LOG_DDEBUG, "Finished chunk size: %lu", data_size);
+    zck_log(ZCK_LOG_DDEBUG, "Finished chunk size: %llu", (long long unsigned) data_size);
     free(dst);
     return data_size;
 }
index 74a43fc0e41eea2f69c79f66e7c61e97b17bcdd9..a12ddfec5e77ccab7cdbd1f8b0c22701727d743b 100644 (file)
@@ -218,8 +218,10 @@ static bool end_dchunk(zckCtx *zck, zckComp *comp, const bool use_dict,
         return false;
     }
     size_t retval = 0;
-    zck_log(ZCK_LOG_DEBUG, "Decompressing %lu bytes to %lu bytes", src_size,
-            fd_size);
+    zck_log(ZCK_LOG_DEBUG, "Decompressing %llu bytes to %llu bytes",
+            (long long unsigned) src_size,
+            (long long unsigned) fd_size
+    );
     if(use_dict && comp->ddict_ctx) {
         zck_log(ZCK_LOG_DEBUG, "Running decompression using dict");
         retval = ZSTD_decompress_usingDDict(comp->dctx, dst, fd_size, src,
index 635fc02eb70be524f07c58ef8619082d22ae51cc..5d4b3593f51c7af155a7f000ed02a0a21e4c4ad4 100644 (file)
@@ -108,7 +108,7 @@ static int dl_write(zckDL *dl, const char *at, size_t length) {
         dl->write_in_chunk -= wb;
         if(!hash_update(dl->zck, &(dl->zck->check_chunk_hash), at, wb))
             return -1;
-        zck_log(ZCK_LOG_DEBUG, "Writing %lu bytes", wb);
+        zck_log(ZCK_LOG_DEBUG, "Writing %llu bytes", (long long unsigned) wb);
         dl->dl_chunk_data += wb;
     }
     return wb;
@@ -158,8 +158,10 @@ static bool write_and_verify_chunk(zckCtx *src, zckCtx *tgt,
         tgt_idx->valid = -1;
     } else {
         tgt_idx->valid = 1;
-        zck_log(ZCK_LOG_DEBUG, "Wrote %lu bytes at %lu",
-                tgt_idx->comp_length, tgt_idx->start);
+        zck_log(ZCK_LOG_DEBUG, "Wrote %llu bytes at %llu",
+                (long long unsigned) tgt_idx->comp_length,
+                (long long unsigned) tgt_idx->start
+        );
     }
     free(digest);
     return true;
@@ -429,7 +431,10 @@ size_t ZCK_PUBLIC_API zck_write_zck_header_cb(void *ptr, size_t l, size_t c,
     size_t wb = 0;
     dl->dl += l*c;
     size_t loc = tell_data(dl->zck);
-    zck_log(ZCK_LOG_DEBUG, "Downloading %lu bytes to position %lu", l*c, loc);
+    zck_log(ZCK_LOG_DEBUG, "Downloading %llu bytes to position %llu",
+            (long long unsigned) l*c,
+            (long long unsigned) loc
+    );
     wb = write(dl->zck->fd, ptr, l*c);
     if(dl->write_cb)
         return dl->write_cb(ptr, l, c, dl->write_data);
index 678683589bf7b0f9bb6ddc36f6b2d5e388e18fb2..d0cbd5a39409f8054103e6118a7e6495c7433259 100644 (file)
@@ -216,7 +216,10 @@ size_t multipart_extract(zckDL *dl, char *b, size_t l) {
             rend = rend*10 + (size_t)(c[0] - 48);
 
         i = j;
-        zck_log(ZCK_LOG_DEBUG, "Download range: %lu-%lu", rstart, rend);
+        zck_log(ZCK_LOG_DEBUG, "Download range: %llu-%llu",
+                (long long unsigned) rstart,
+                (long long unsigned) rend
+        );
         mp->length = rend-rstart+1;
         mp->state = 1;
     }
index d35076c2afef8ea36c037e3fbcf96a7df3e2737e..d4f74269a51e4b8ede38ef7c253838d7ede87596 100644 (file)
@@ -163,9 +163,10 @@ char ZCK_PUBLIC_API *zck_get_range_char(zckCtx *zck, zckRange *range) {
     int count = 0;
     zckRangeItem *ri = range->first;
     while(ri) {
-        int length = snprintf(output+loc, buf_size-loc, "%lu-%lu,",
-                              (long unsigned)ri->start,
-                              (long unsigned)ri->end);
+        int length = snprintf(output+loc, buf_size-loc, "%llu-%llu,",
+                              (long long unsigned)ri->start,
+                              (long long unsigned)ri->end
+        );
         if(length < 0) {
             set_fatal_error(zck, "Unable to get range: %s", strerror(errno));
             free(output);
index 01a10596db8124db8b0062277eff317bf5f14af4..967051a4da5ba295caf874c28ced44b2e61fbbcc 100644 (file)
@@ -256,7 +256,9 @@ bool hash_update(zckCtx *zck, zckHash *hash, const char *message,
         return true;
     if(message == NULL) {
         set_error(zck,
-                  "Hash data is supposed to have %lu bytes, but is NULL", size);
+                  "Hash data is supposed to have %llu bytes, but is NULL",
+                  (long long unsigned) size
+        );
         return false;
     }
     if(size == 0) {
index da52e61e3261a189ca478c37e8139d44e463cd66..5b8393bd465a10d30c443a278d6e163c92cc78cf 100644 (file)
@@ -81,8 +81,8 @@ static bool read_header_from_file(zckCtx *zck) {
         loaded = zck->header_size - zck->lead_size;
 
     /* Read header from file */
-    zck_log(ZCK_LOG_DEBUG, "Reading the rest of the header: %lu bytes",
-            zck->header_length);
+    zck_log(ZCK_LOG_DEBUG, "Reading the rest of the header: %llu bytes",
+            (long long unsigned) zck->header_length);
     if(loaded < zck->header_length) {
         if(!read_data(zck, header + loaded, zck->header_length - loaded))
             return false;
@@ -233,7 +233,7 @@ static bool read_sig(zckCtx *zck) {
 
     if(zck->header_size >
        zck->lead_size + zck->preface_size + zck->index_size + length)
-        zck_log(ZCK_LOG_WARNING, "There are %lu unused bytes in the header");
+        zck_log(ZCK_LOG_WARNING, "There are unused bytes in the header");
 
     zck->sig_size = length;
     zck->sig_string = header;
@@ -280,7 +280,11 @@ static bool preface_create(zckCtx *zck) {
 
     zck->preface_string = header;
     zck->preface_size = length;
-    zck_log(ZCK_LOG_DEBUG, "Generated preface: %lu bytes", zck->preface_size);
+    zck_log(
+        ZCK_LOG_DEBUG,
+        "Generated preface: %llu bytes",
+        (long long unsigned) zck->preface_size
+    );
     return true;
 }
 
@@ -304,7 +308,11 @@ static bool sig_create(zckCtx *zck) {
     }
     zck->sig_string = header;
     zck->sig_size = length;
-    zck_log(ZCK_LOG_DEBUG, "Generated signatures: %lu bytes", zck->sig_size);
+    zck_log(
+        ZCK_LOG_DEBUG,
+        "Generated signatures: %llu bytes",
+        (long long unsigned) zck->sig_size
+    );
     return true;
 }
 
@@ -336,7 +344,11 @@ static bool lead_create(zckCtx *zck) {
 
     zck->lead_string = header;
     zck->lead_size = length;
-    zck_log(ZCK_LOG_DEBUG, "Generated lead: %lu bytes", zck->lead_size);
+    zck_log(
+        ZCK_LOG_DEBUG,
+        "Generated lead: %llu bytes",
+        (long long unsigned) zck->lead_size
+    );
     return true;
 }
 
@@ -370,8 +382,11 @@ bool header_create(zckCtx *zck) {
                        zck->index_size + zck->sig_size;
 
     /* Merge everything into one large string */
-    zck_log(ZCK_LOG_DEBUG, "Merging into header: %lu bytes",
-            zck->data_offset);
+    zck_log(
+        ZCK_LOG_DEBUG,
+        "Merging into header: %llu bytes",
+        (long long unsigned) zck->data_offset
+    );
     zck->header = zmalloc(zck->data_offset);
     if (!zck->header) {
            zck_log(ZCK_LOG_ERROR, "OOM in %s", __func__);
@@ -423,8 +438,11 @@ bool header_create(zckCtx *zck) {
 bool write_header(zckCtx *zck) {
     VALIDATE_WRITE_BOOL(zck);
 
-    zck_log(ZCK_LOG_DEBUG, "Writing header: %lu bytes",
-            zck->lead_size);
+    zck_log(
+        ZCK_LOG_DEBUG,
+        "Writing header: %llu bytes",
+        (long long unsigned) zck->lead_size
+    );
     if(!write_data(zck, zck->fd, zck->header, zck->header_size))
         return false;
     return true;
@@ -538,10 +556,12 @@ static bool read_lead(zckCtx *zck) {
         hash_reset(&(zck->hash_type));
         free(zck->header_digest);
         zck->header_digest = NULL;
-        set_error(zck,
-                  "Header length (%lu) doesn't match requested header length "
-                  "(%lu)", zck->header_length + length,
-                  zck->prep_hdr_size);
+        set_error(
+            zck,
+            "Header length (%llu) doesn't match requested header length (%llu)",
+            (long long unsigned) zck->header_length + length,
+            (long long unsigned) zck->prep_hdr_size
+        );
         return false;
     }
     /* Store pre-header */
@@ -549,7 +569,11 @@ static bool read_lead(zckCtx *zck) {
     zck->header_size = lead;
     zck->lead_string = header;
     zck->lead_size = length;
-    zck_log(ZCK_LOG_DEBUG, "Parsed lead: %lu bytes", length);
+    zck_log(
+        ZCK_LOG_DEBUG,
+        "Parsed lead: %llu bytes",
+        (long long unsigned) length
+    );
     return true;
 }
 
index 956d11c6005dbd3b54e5fcec37a0977b6d52a349..1a23517690950c0e51131ef721b7aa0a471b8c90 100644 (file)
@@ -153,7 +153,11 @@ bool index_create(zckCtx *zck) {
     }
     zck->index_string = index;
     zck->index_size = index_size;
-    zck_log(ZCK_LOG_DEBUG, "Generated index: %lu bytes", zck->index_size);
+    zck_log(
+        ZCK_LOG_DEBUG,
+        "Generated index: %llu bytes",
+        (long long unsigned) zck->index_size
+    );
     return true;
 }
 
index 22593b0eb8f5446576c681abc90f43d473171e96..6ec0a8dde1ae69148c0d6fdb407369472cdbb825 100644 (file)
@@ -164,7 +164,11 @@ zckChunk ZCK_PUBLIC_API *zck_get_chunk(zckCtx *zck, size_t number) {
         if(idx->number == number)
             return idx;
     }
-    zck_log(ZCK_LOG_WARNING, "Chunk %lu not found", number);
+    zck_log(
+        ZCK_LOG_WARNING,
+        "Chunk %llu not found",
+        (long long unsigned) number
+    );
     return NULL;
 }
 
index 6e5ebc7db9d0c33c13264db483fe72877af43532..67586c13ef753e4fa2d8516ef441e06e1d0c5551 100644 (file)
@@ -94,8 +94,13 @@ int seek_data(zckCtx *zck, off_t offset, int whence) {
         } else {
             wh_str = "using unknown measurement";
         }
-        set_error(zck, "Unable to seek to %lu %s: %s", offset, wh_str,
-                  strerror(errno));
+        set_error(
+            zck,
+            "Unable to seek to %llu %s: %s",
+            (long long unsigned) offset,
+            wh_str,
+            strerror(errno)
+        );
         return false;
     }
     return true;
index eec127b71ee143da80dfa094f6deabd795dda716..15a672e66a6a628bf22ca7c69b8afb2343c0753e 100644 (file)
@@ -272,10 +272,13 @@ bool ZCK_PUBLIC_API zck_set_soption(zckCtx *zck, zck_soption option, const char
         }
         if(chk_type.digest_size*2 != length) {
             free(data);
-            set_fatal_error(zck, "Hash digest size mismatch for header "
-                                 "validation\n"
-                                 "Expected: %i\nProvided: %lu",
-                                 chk_type.digest_size*2, length);
+            set_fatal_error(
+                zck,
+                "Hash digest size mismatch for header validation\n"
+                "Expected: %i\nProvided: %llu",
+                chk_type.digest_size*2,
+                (long long unsigned) length
+            );
             return false;
         }
         zck_log(ZCK_LOG_DEBUG, "Setting expected hash to (%s)%.*s",
@@ -316,8 +319,8 @@ bool ZCK_PUBLIC_API zck_set_ioption(zckCtx *zck, zck_ioption option, ssize_t val
     } else if(option == ZCK_VAL_HEADER_HASH_TYPE) {
         VALIDATE_READ_BOOL(zck);
         if(value < 0) {
-            set_error(zck, "Header hash type can't be less than zero: %li",
-                      value);
+            set_error(zck, "Header hash type can't be less than zero: %lli",
+                      (long long) value);
             return false;
         }
         /* Make sure that header hash type is set before the header digest,
@@ -332,8 +335,8 @@ bool ZCK_PUBLIC_API zck_set_ioption(zckCtx *zck, zck_ioption option, ssize_t val
         VALIDATE_READ_BOOL(zck);
         if(value < 0) {
             set_error(zck,
-                      "Header size validation can't be less than zero: %li",
-                      value);
+                      "Header size validation can't be less than zero: %lli",
+                      (long long) value);
             return false;
         }
         zck->prep_hdr_size = value;
@@ -343,7 +346,11 @@ bool ZCK_PUBLIC_API zck_set_ioption(zckCtx *zck, zck_ioption option, ssize_t val
     /* Hash options */
     } else if(option < 100) {
         /* Currently no hash options other than setting hash type, so bail */
-        set_error(zck, "Unknown option %lu", value);
+        set_error(
+            zck,
+            "Unknown option %llu",
+            (long long unsigned) value
+        );
         return false;
 
     /* Compression options */
index 23921398771cc13868db5d83b7353fb349962cd8..2b6ad9663303f1f9c3c8614c2115502b6d845304 100644 (file)
@@ -188,8 +188,8 @@ int main (int argc, char *argv[]) {
                 LOG_ERROR("%s", zck_get_error(zck));
             else
                 LOG_ERROR(
-                        "Dict size doesn't match expected size: %li != %li\n",
-                        read_size, dict_size);
+                        "Dict size doesn't match expected size: %lli != %lli\n",
+                        (long long) read_size, (long long) dict_size);
             goto error2;
         }
         if(write(dst_fd, data, dict_size) != dict_size) {
@@ -238,7 +238,10 @@ int main (int argc, char *argv[]) {
         goto error2;
     }
     if(arguments.log_level <= ZCK_LOG_INFO)
-        LOG_ERROR("Decompressed %lu bytes\n", (unsigned long)total);
+        LOG_ERROR(
+            "Decompressed %llu bytes\n",
+            (long long unsigned) total
+        );
     good_exit = true;
 error2:
     free(data);
index 87c0811d8a0b02dfb89e50e27318a4cbfdd0cb39..da7a1fb4825a625a2417fbe11e17b2fe965c428c 100644 (file)
--- a/src/zck.c
+++ b/src/zck.c
@@ -344,10 +344,11 @@ int main (int argc, char *argv[]) {
         exit(1);
     }
     if(arguments.log_level <= ZCK_LOG_INFO) {
-        LOG_ERROR("Wrote %lu bytes in %lu chunks\n",
-                (unsigned long)(zck_get_data_length(zck) +
-                                zck_get_header_length(zck)),
-                (long)zck_get_chunk_count(zck));
+        LOG_ERROR(
+            "Wrote %llu bytes in %llu chunks\n",
+            (long long unsigned) (zck_get_data_length(zck) + zck_get_header_length(zck)),
+            (long long unsigned) zck_get_chunk_count(zck)
+        );
     }
 
     zck_free(&zck);
index 65f3c8d319734c1f8690eac752383a9ef5c1f0be..0f267cafc6d2e1619ada4301c0ecb5b0d04873d7 100644 (file)
@@ -191,10 +191,10 @@ int main (int argc, char *argv[]) {
         }
         total_size += zck_get_chunk_comp_size(tgt_idx);
     }
-    printf("Would download %li of %li bytes\n", (long)dl_size,
-           (long)total_size);
-    printf("Matched %li of %lu chunks\n", (long)matched_chunks,
-           (long unsigned)zck_get_chunk_count(zck_tgt));
+    printf("Would download %lli of %lli bytes\n", (long long) dl_size,
+           (long long) total_size);
+    printf("Matched %lli of %llu chunks\n", (long long) matched_chunks,
+           (long long unsigned) zck_get_chunk_count(zck_tgt));
     zck_free(&zck_tgt);
     zck_free(&zck_src);
 }
index 432c2574bc6409f61ac59f09234c8a1d3f9315dd..7b2f77006913b3659276402718564b93dcd1cd54 100644 (file)
@@ -228,13 +228,18 @@ int dl_bytes(dlCtx *dl_ctx, char *url, size_t bytes, size_t start,
             return retval;
 
         if(log_level <= ZCK_LOG_DEBUG)
-            LOG_ERROR("Downloading %lu bytes at position %lu\n",
-                      (unsigned long)start+bytes-*buffer_len,
-                      (unsigned long)*buffer_len);
+            LOG_ERROR(
+                "Downloading %llu bytes at position %llu\n",
+                (long long unsigned) start+bytes-*buffer_len,
+                (long long unsigned) *buffer_len
+            );
         *buffer_len += start + bytes - *buffer_len;
         if(lseek(fd, start, SEEK_SET) == -1) {
-            LOG_ERROR("Seek to byte %lu of temporary file failed: %s\n",
-                      (unsigned long)start, strerror(errno));
+            LOG_ERROR(
+                "Seek to byte %llu of temporary file failed: %s\n",
+                (long long unsigned) start,
+                strerror(errno)
+            );
             return 0;
         }
     }
@@ -310,8 +315,10 @@ int main (int argc, char *argv[]) {
 
     CURL *curl_ctx = curl_easy_init();
     if(!curl_ctx) {
-        LOG_ERROR("Unable to allocate %lu bytes for curl context\n",
-                  (unsigned long)sizeof(CURL));
+        LOG_ERROR(
+            "Unable to allocate %llu bytes for curl context\n",
+            (long long unsigned)sizeof(CURL)
+        );
         exit(10);
     }
 
@@ -386,8 +393,10 @@ int main (int argc, char *argv[]) {
         }
         if(retval == 1) {
             printf("Missing chunks: 0\n");
-            printf("Downloaded %lu bytes\n",
-                (long unsigned)zck_dl_get_bytes_downloaded(dl));
+            printf(
+                "Downloaded %llu bytes\n",
+                (long long unsigned) zck_dl_get_bytes_downloaded(dl)
+            );
             if(ftruncate(dst_fd, zck_get_length(zck_tgt)) < 0) {
                 perror(NULL);
                 exit_val = 10;
@@ -444,8 +453,8 @@ int main (int argc, char *argv[]) {
             }
         }
     }
-    printf("Downloaded %lu bytes\n",
-           (long unsigned)zck_dl_get_bytes_downloaded(dl));
+    printf("Downloaded %llu bytes\n",
+           (long long unsigned) zck_dl_get_bytes_downloaded(dl));
     if(ftruncate(dst_fd, zck_get_length(zck_tgt)) < 0) {
         perror(NULL);
         exit_val = 10;
index afa4dfef69cf11e91067c0aa43f55b45e73ac12a..f8e87d971c23c427e1177776cd7a58d144a1a689 100644 (file)
@@ -261,15 +261,18 @@ int main (int argc, char *argv[]) {
                 LOG_ERROR("%s", zck_get_error(zck));
             else
                 LOG_ERROR(
-                        "Chunk %li size doesn't match expected size: %li != %li\n",
-                        zck_get_chunk_number(idx), read_size, chunk_size);
+                        "Chunk %lli size doesn't match expected size: %lli != %lli\n",
+                        (long long) zck_get_chunk_number(idx),
+                        (long long) read_size,
+                        (long long) chunk_size
+                );
             goto error2;
         }
 
         char *dict_block = calloc(strlen(dir) + strlen(out_name) + 12, 1);
         assert(dict_block);
-        snprintf(dict_block, strlen(dir) + strlen(out_name) + 12, "%s/%s.%li",
-                 dir, out_name, zck_get_chunk_number(idx));
+        snprintf(dict_block, strlen(dir) + strlen(out_name) + 12, "%s/%s.%lli",
+                 dir, out_name, (long long) zck_get_chunk_number(idx));
         int dst_fd = open(dict_block, O_TRUNC | O_WRONLY | O_CREAT | O_BINARY, 0666);
         if(dst_fd < 0) {
             LOG_ERROR("Unable to open %s", dict_block);
index c439205a45e8bb33eaa8e78ab3133aa1c87bb34f..8654af1cb67a5b651c72f52ac7902b11f6117fea 100644 (file)
@@ -155,15 +155,15 @@ int main (int argc, char *argv[]) {
     if(!arguments.quiet) {
         printf("Overall checksum type: %s\n",
                zck_hash_name_from_type(zck_get_full_hash_type(zck)));
-        printf("Header size: %lu\n", zck_get_header_length(zck));
+        printf("Header size: %llu\n", (long long unsigned) zck_get_header_length(zck));
         char *digest = zck_get_header_digest(zck);
         printf("Header checksum: %s\n", digest);
-        free(digest);
-        printf("Data size: %lu\n", zck_get_data_length(zck));
+        free(digest); 
+        printf("Data size: %llu\n", (long long unsigned) zck_get_data_length(zck));
         digest = zck_get_data_digest(zck);
         printf("Data checksum: %s\n", digest);
         free(digest);
-        printf("Chunk count: %lu\n", (long unsigned)zck_get_chunk_count(zck));
+        printf("Chunk count: %llu\n", (long long unsigned) zck_get_chunk_count(zck));
         printf("Chunk checksum type: %s\n", zck_hash_name_from_type(zck_get_chunk_hash_type(zck)));
     }
     if(!arguments.quiet && arguments.show_chunks)
@@ -191,13 +191,13 @@ int main (int argc, char *argv[]) {
                               (((int)zck_get_chunk_digest_size(zck) * 2) - (int)strlen("Checksum")), ' ');
 
             }
-            printf("%12lu %s %s %12lu %12lu %12lu",
-                   (long unsigned)zck_get_chunk_number(chk),
+            printf("%12llu %s %s %12llu %12llu %12llu",
+                   (long long unsigned)zck_get_chunk_number(chk),
                    digest,
                    digest_uncompressed,
-                   (long unsigned)zck_get_chunk_start(chk),
-                   (long unsigned)zck_get_chunk_comp_size(chk),
-                   (long unsigned)zck_get_chunk_size(chk));
+                   (long long unsigned)zck_get_chunk_start(chk),
+                   (long long unsigned)zck_get_chunk_comp_size(chk),
+                   (long long unsigned)zck_get_chunk_size(chk));
             if(arguments.verify) {
                 if(zck_get_chunk_valid(chk) == 1)
                     printf("  +");
index 3b6794047d2f5aa570597865ddfb4ca4322ada5d..d32fff01e393114375e32e3e76d9eba4d4ba1369 100644 (file)
@@ -99,7 +99,7 @@ int main (int argc, char *argv[]) {
     memset(data, 0, 1000);
     len = zck_read(zck, data, 1000);
     if(len > 0) {
-        printf("%li bytes read, but file should be empty\n", (long)len);
+        printf("%lli bytes read, but file should be empty\n", (long long) len);
         exit(1);
     }
     if(!zck_close(zck))
index f6d53167a13e3f6795bdce317a95a3cae18dcadf..a61b8f77b834aba1d40e4094a265b17bb72ec668 100644 (file)
@@ -62,7 +62,7 @@ int main (int argc, char *argv[]) {
     memset(data, 0, 1000);
     ssize_t len = zck_read(zck, data, 1000);
     if(len > 0) {
-        printf("%li bytes read, but file should be empty\n", (long)len);
+        printf("%lli bytes read, but file should be empty\n", (long long) len);
         exit(1);
     }
     if(!zck_close(zck))
index 6d19799caa65854ccfe921b961ae3123f921a73c..0e63d8cdc7a7aa1ca9b9d41ecb7650dabbfbad13 100644 (file)
@@ -79,19 +79,19 @@ int main (int argc, char *argv[]) {
         zck_free(&zck);
         exit(1);
     }
-    ssize_t chunk_size = zck_get_chunk_size(chunk);
+    long long chunk_size = (long long) zck_get_chunk_size(chunk);
     if(chunk_size < 0) {
         printf("%s", zck_get_error(zck));
         zck_free(&zck);
         exit(1);
     }
     char *data = calloc(chunk_size, 1);
-    ssize_t read_size = zck_get_chunk_data(chunk, data, chunk_size);
+    long long read_size = (long long) zck_get_chunk_data(chunk, data, chunk_size);
     if(read_size != chunk_size) {
         if(read_size < 0)
             printf("%s", zck_get_error(zck));
         else
-            printf("chunk size didn't match expected size: %li != %li\n",
+            printf("chunk size didn't match expected size: %lli != %lli\n",
                    read_size, chunk_size);
         free(data);
         zck_free(&zck);
index 61ecedc4756aa108f43130eac8195c4810b3bc43..21701ed233bc5de0798ac0cfda7f44e600e9ad98 100644 (file)
@@ -68,19 +68,19 @@ int main (int argc, char *argv[]) {
         zck_free(&zck);
         exit(1);
     }
-    ssize_t chunk_size = zck_get_chunk_comp_size(chunk);
+    long long chunk_size = (long long) zck_get_chunk_comp_size(chunk);
     if(chunk_size < 0) {
         printf("%s", zck_get_error(zck));
         zck_free(&zck);
         exit(1);
     }
     char *data = calloc(chunk_size, 1);
-    ssize_t read_size = zck_get_chunk_comp_data(chunk, data, chunk_size);
+    long long read_size = (long long) zck_get_chunk_comp_data(chunk, data, chunk_size);
     if(read_size != chunk_size) {
         if(read_size < 0)
             printf("%s", zck_get_error(zck));
         else
-            printf("chunk size didn't match expected size: %li != %li\n",
+            printf("chunk size didn't match expected size: %lli != %lli\n",
                    read_size, chunk_size);
         free(data);
         zck_free(&zck);