2
0
Эх сурвалжийг харах

Merge pull request #442 from ThomasWaldmann/fix-compiler-warnings

get rid of C compiler warnings, fixes #391
TW 9 жил өмнө
parent
commit
04f081fea7
2 өөрчлөгдсөн 7 нэмэгдсэн , 9 устгасан
  1. 5 7
      borg/_chunker.c
  2. 2 2
      borg/_hashindex.c

+ 5 - 7
borg/_chunker.c

@@ -76,19 +76,18 @@ buzhash_update(uint32_t sum, unsigned char remove, unsigned char add, size_t len
 }
 
 typedef struct {
-    int window_size, chunk_mask, min_size;
-    size_t buf_size;
+    uint32_t chunk_mask;
     uint32_t *table;
     uint8_t *data;
     PyObject *fd;
     int fh;
     int done, eof;
-    size_t remaining, position, last;
+    size_t min_size, buf_size, window_size, remaining, position, last;
     off_t bytes_read, bytes_yielded;
 } Chunker;
 
 static Chunker *
-chunker_init(int window_size, int chunk_mask, int min_size, int max_size, uint32_t seed)
+chunker_init(size_t window_size, uint32_t chunk_mask, size_t min_size, size_t max_size, uint32_t seed)
 {
     Chunker *c = calloc(sizeof(Chunker), 1);
     c->window_size = window_size;
@@ -203,9 +202,8 @@ PyBuffer_FromMemory(void *data, Py_ssize_t len)
 static PyObject *
 chunker_process(Chunker *c)
 {
-    uint32_t sum, chunk_mask = c->chunk_mask, min_size = c->min_size, window_size = c->window_size;
-    int n = 0;
-    int old_last;
+    uint32_t sum, chunk_mask = c->chunk_mask;
+    size_t n = 0, old_last, min_size = c->min_size, window_size = c->window_size;
 
     if(c->done) {
         if(c->bytes_read == c->bytes_yielded)

+ 2 - 2
borg/_hashindex.c

@@ -171,7 +171,7 @@ hashindex_read(const char *path)
         goto fail;
     }
     buckets_length = (off_t)_le32toh(header.num_buckets) * (header.key_size + header.value_size);
-    if(length != sizeof(HashHeader) + buckets_length) {
+    if((size_t) length != sizeof(HashHeader) + buckets_length) {
         EPRINTF_MSG_PATH(path, "Incorrect file length (expected %ju, got %ju)",
                          (uintmax_t) sizeof(HashHeader) + buckets_length, (uintmax_t) length);
         goto fail;
@@ -275,7 +275,7 @@ hashindex_write(HashIndex *index, const char *path)
         EPRINTF_PATH(path, "fwrite header failed");
         ret = 0;
     }
-    if(fwrite(index->buckets, 1, buckets_length, fd) != buckets_length) {
+    if(fwrite(index->buckets, 1, buckets_length, fd) != (size_t) buckets_length) {
         EPRINTF_PATH(path, "fwrite buckets failed");
         ret = 0;
     }