Some variable name cleanup
authorJonathan Dieter <jdieter@gmail.com>
Mon, 11 Jun 2018 18:45:44 +0000 (21:45 +0300)
committerJonathan Dieter <jdieter@gmail.com>
Mon, 11 Jun 2018 18:52:27 +0000 (21:52 +0300)
Signed-off-by: Jonathan Dieter <jdieter@gmail.com>
src/lib/dl/range.c
src/lib/index/index_create.c

index 4f618dba3911050d130c98dae122e506c419e6be..5b25eb62a523eab9f41ddf18e8552611b168c8e5 100644 (file)
@@ -88,8 +88,8 @@ static void range_merge_combined(zckRange *info) {
     }
 }
 
-static int range_add(zckRange *info, zckChunk *idx, zckCtx *zck) {
-    if(info == NULL || idx == NULL) {
+static int range_add(zckRange *info, zckChunk *chk, zckCtx *zck) {
+    if(info == NULL || chk == NULL) {
         zck_log(ZCK_LOG_ERROR, "zckRange or zckChunk not allocated\n");
         return False;
     }
@@ -100,8 +100,8 @@ static int range_add(zckRange *info, zckChunk *idx, zckCtx *zck) {
         add_index = True;
     }
 
-    size_t start = idx->start + header_len;
-    size_t end = idx->start + header_len + idx->comp_length - 1;
+    size_t start = chk->start + header_len;
+    size_t end = chk->start + header_len + chk->comp_length - 1;
     zckRangeItem *prev = info->first;
     for(zckRangeItem *ptr=info->first; ptr;) {
         prev = ptr;
@@ -109,8 +109,7 @@ static int range_add(zckRange *info, zckChunk *idx, zckCtx *zck) {
             ptr = ptr->next;
             continue;
         } else if(start < ptr->start) {
-
-            if(range_insert_new(ptr->prev, ptr, start, end, info, idx,
+            if(range_insert_new(ptr->prev, ptr, start, end, info, chk,
                                 add_index) == NULL)
                 return False;
             if(info->first == ptr) {
@@ -128,7 +127,7 @@ static int range_add(zckRange *info, zckChunk *idx, zckCtx *zck) {
         }
     }
     /* We've only reached here if we should be last item */
-    zckRangeItem *new = range_insert_new(prev, NULL, start, end, info, idx,
+    zckRangeItem *new = range_insert_new(prev, NULL, start, end, info, chk,
                                          add_index);
     if(new == NULL)
         return False;
@@ -204,19 +203,16 @@ zckRange PUBLIC *zck_get_dl_range(zckCtx *zck, int max_ranges) {
                 sizeof(zckRange));
         return NULL;
     }
-    zckChunk *idx = zck->index.first;
-    while(idx) {
-        if(idx->valid) {
-            idx = idx->next;
+    for(zckChunk *chk = zck->index.first; chk; chk = chk->next) {
+        if(chk->valid)
             continue;
-        }
-        if(!range_add(range, idx, zck)) {
+
+        if(!range_add(range, chk, zck)) {
             zck_range_free(&range);
             return NULL;
         }
         if(max_ranges >= 0 && range->count >= max_ranges)
             break;
-        idx = idx->next;
     }
     return range;
 }
index bb431fc711f7738279b3b13db623c777a54934a9..a845b0a988d9e393c071a80ba684130d3043c64f 100644 (file)
@@ -149,16 +149,16 @@ int index_new_chunk(zckIndex *index, char *digest, int digest_size,
         zck_log(ZCK_LOG_ERROR, "Digest size 0 too small\n");
         return False;
     }
-    zckChunk *idx = zmalloc(sizeof(zckChunk));
-    if(idx == NULL) {
+    zckChunk *chk = zmalloc(sizeof(zckChunk));
+    if(chk == NULL) {
         zck_log(ZCK_LOG_ERROR, "Unable to allocate %lu bytes\n",
                 sizeof(zckChunk));
         return False;
     }
     index->digest_size = digest_size;
-    idx->comp_length = comp_size;
-    idx->length = orig_size;
-    return finish_chunk(index, idx, digest, finished, zck);
+    chk->comp_length = comp_size;
+    chk->length = orig_size;
+    return finish_chunk(index, chk, digest, finished, zck);
 }
 
 int index_add_to_chunk(zckCtx *zck, char *data, size_t comp_size,