Skip to content

Commit 59fd927

Browse files
authored
Merge pull request #662 from Tarsnap/comments
Fix some typos and style in comments, and add some missing comments.
2 parents b17fd3e + da5970d commit 59fd927

File tree

9 files changed

+46
-11
lines changed

9 files changed

+46
-11
lines changed

tar/ccache/ccache.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ CCACHE * ccache_read(const char *);
2222
* the chunkification cache ${cache}, and set ${fullentry} to a non-zero
2323
* value iff the cache can provide at least sb->st_size bytes of the archive
2424
* entry. Return a cookie which can be passed to either ccache_entry_write
25-
* or ccache_entry_start depending upon whether ${fullentry} is zero or not.
25+
* or ccache_entry_writefile depending upon whether ${fullentry} is zero or not.
2626
*/
2727
CCACHE_ENTRY * ccache_entry_lookup(CCACHE *, const char *,
2828
const struct stat *, TAPE_W *, int *);

tar/ccache/ccache_entry.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ callback_faketrailer(void * cookie, const uint8_t * buf, size_t buflen)
199199
* the chunkification cache ${cache}, and set ${fullentry} to a non-zero
200200
* value iff the cache can provide at least sb->st_size bytes of the archive
201201
* entry. Return a cookie which can be passed to either ccache_entry_write
202-
* or ccache_entry_start depending upon whether ${fullentry} is zero or not.
202+
* or ccache_entry_writefile depending upon whether ${fullentry} is zero or not.
203203
*/
204204
CCACHE_ENTRY *
205205
ccache_entry_lookup(CCACHE * cache, const char * path, const struct stat * sb,

tar/glue/tape.c

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212

1313
#include "bsdtar.h"
1414

15-
/*
15+
/**
16+
* tarsnap_mode_d(bsdtar):
1617
* Delete a tape.
1718
*/
1819
void
@@ -60,7 +61,8 @@ tarsnap_mode_d(struct bsdtar *bsdtar)
6061
return;
6162
}
6263

63-
/*
64+
/**
65+
* tarsnap_mode_r(bsdtar):
6466
* Read the tape and write to stdout.
6567
*/
6668
void
@@ -110,7 +112,8 @@ tarsnap_mode_r(struct bsdtar *bsdtar)
110112
return;
111113
}
112114

113-
/*
115+
/**
116+
* tarsnap_mode_print_stats(bsdtar):
114117
* Print statistics relating to an archive or set of archives.
115118
*/
116119
void
@@ -171,7 +174,8 @@ tarsnap_mode_print_stats(struct bsdtar *bsdtar)
171174
return;
172175
}
173176

174-
/*
177+
/**
178+
* tarsnap_mode_list_archives(bsdtar, print_hashes):
175179
* Print the names of all the archives.
176180
*/
177181
void
@@ -231,7 +235,8 @@ tarsnap_mode_list_archives(struct bsdtar *bsdtar, int print_hashes)
231235
return;
232236
}
233237

234-
/*
238+
/**
239+
* tarsnap_mode_fsck(bsdtar, prune, whichkey):
235240
* Archive set consistency check and repair.
236241
*/
237242
void
@@ -265,7 +270,8 @@ tarsnap_mode_fsck(struct bsdtar *bsdtar, int prune, int whichkey)
265270
return;
266271
}
267272

268-
/*
273+
/**
274+
* tarsnap_mode_initialize_cachedir(bsdtar):
269275
* Initialize cache directory.
270276
*/
271277
void
@@ -291,7 +297,8 @@ tarsnap_mode_initialize_cachedir(struct bsdtar *bsdtar)
291297
return;
292298
}
293299

294-
/*
300+
/**
301+
* tarsnap_mode_nuke(bsdtar):
295302
* Nuke all the files belonging to an archive set.
296303
*/
297304
void
@@ -325,7 +332,8 @@ tarsnap_mode_nuke(struct bsdtar *bsdtar)
325332
return;
326333
}
327334

328-
/*
335+
/**
336+
* tarsnap_mode_recover(bsdtar):
329337
* Recover an interrupted archive if one exists.
330338
*/
331339
void

tar/multitape/multitape_fsck.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ phase1(uint64_t machinenum, STORAGE_D * SD, STORAGE_R * SR,
176176
if ((mdat = malloc(sizeof(struct tapemetadata))) == NULL)
177177
goto err2;
178178

179+
/* Get the next metadata file. */
179180
switch (multitape_metadata_get_byhash(SR, NULL, mdat,
180181
&flist[file * 32], 1)) {
181182
case -1:

tar/multitape/multitape_metadata.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,9 +506,12 @@ multitape_metadata_delete(STORAGE_D * S, CHUNKS_D * C,
506506
{
507507
uint8_t hbuf[32];
508508

509+
/* Compute the hash of the tape name. */
509510
if (crypto_hash_data(CRYPTO_KEY_HMAC_NAME,
510511
(uint8_t *)mdat->name, strlen(mdat->name), hbuf))
511512
goto err0;
513+
514+
/* Delete the file and update the stats. */
512515
if (storage_delete_file(S, 'm', hbuf))
513516
goto err0;
514517
chunks_delete_extrastats(C, mdat->metadatalen);

tar/multitape/multitape_metaindex.c

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,10 @@ multitape_metaindex_fragname(const uint8_t namehash[32], uint32_t fragnum,
3838
{
3939
uint8_t fragnum_le[4];
4040

41+
/* Use a platform-agnostic format for fragnum. */
4142
le32enc(fragnum_le, fragnum);
43+
44+
/* SHA256(namehash || fragnum). */
4245
if (crypto_hash_data_2(CRYPTO_KEY_HMAC_SHA256, namehash, 32,
4346
fragnum_le, 4, fraghash)) {
4447
warn0("Programmer error: "
@@ -90,19 +93,21 @@ multitape_metaindex_put(STORAGE_W * S, CHUNKS_W * C,
9093
if ((p = buf = malloc(buflen)) == NULL)
9194
goto err0;
9295

93-
/* Copy values into buffer. */
96+
/* Copy the header index into the buffer. */
9497
le32enc(p, (uint32_t)mind->hindexlen);
9598
p += 4;
9699
if (mind->hindexlen > 0)
97100
memcpy(p, mind->hindex, mind->hindexlen);
98101
p += mind->hindexlen;
99102

103+
/* Copy the chunk index into the buffer. */
100104
le32enc(p, (uint32_t)mind->cindexlen);
101105
p += 4;
102106
if (mind->cindexlen > 0)
103107
memcpy(p, mind->cindex, mind->cindexlen);
104108
p += mind->cindexlen;
105109

110+
/* Copy the trailer index into the buffer. */
106111
le32enc(p, (uint32_t)mind->tindexlen);
107112
p += 4;
108113
if (mind->tindexlen > 0)
@@ -231,8 +236,11 @@ multitape_metaindex_get(STORAGE_R * S, CHUNKS_S * C,
231236
buf += 4;
232237
buflen -= 4;
233238

239+
/* Sanity check. */
234240
if (buflen < mind->hindexlen)
235241
goto corrupt0;
242+
243+
/* Copy the header index into a new buffer. */
236244
if (((mind->hindex = malloc(mind->hindexlen)) == NULL) &&
237245
(mind->hindexlen > 0))
238246
goto err1;
@@ -248,8 +256,11 @@ multitape_metaindex_get(STORAGE_R * S, CHUNKS_S * C,
248256
buf += 4;
249257
buflen -= 4;
250258

259+
/* Sanity check. */
251260
if (buflen < mind->cindexlen)
252261
goto corrupt1;
262+
263+
/* Copy the chunk index into a new buffer. */
253264
if (((mind->cindex = malloc(mind->cindexlen)) == NULL) &&
254265
(mind->cindexlen > 0))
255266
goto err2;
@@ -265,8 +276,11 @@ multitape_metaindex_get(STORAGE_R * S, CHUNKS_S * C,
265276
buf += 4;
266277
buflen -= 4;
267278

279+
/* Sanity check. */
268280
if (buflen < mind->tindexlen)
269281
goto corrupt2;
282+
283+
/* Copy the trailer index into a new buffer. */
270284
if (((mind->tindex = malloc(mind->tindexlen)) == NULL) &&
271285
(mind->tindexlen > 0))
272286
goto err3;
@@ -275,6 +289,7 @@ multitape_metaindex_get(STORAGE_R * S, CHUNKS_S * C,
275289
buf += mind->tindexlen;
276290
buflen -= mind->tindexlen;
277291

292+
/* Sanity check. */
278293
if (buflen != 0)
279294
goto corrupt3;
280295

@@ -331,6 +346,7 @@ multitape_metaindex_free(struct tapemetaindex * mind)
331346
if (mind == NULL)
332347
return;
333348

349+
/* Clean up. */
334350
free(mind->tindex);
335351
free(mind->cindex);
336352
free(mind->hindex);
@@ -351,6 +367,7 @@ multitape_metaindex_delete(STORAGE_D * S, CHUNKS_D * C,
351367
size_t fraglen;
352368
uint8_t fraghash[32];
353369

370+
/* Compute the hash of the tape name. */
354371
if (crypto_hash_data(CRYPTO_KEY_HMAC_NAME,
355372
(uint8_t *)mdat->name, strlen(mdat->name), hbuf))
356373
goto err0;

tar/multitape/multitape_read.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,12 @@ stream_get_chunk(struct stream * S, const uint8_t ** buf, size_t * clen,
127127

128128
/* Skip part of the current chunk if appropriate. */
129129
if (S->skiplen) {
130+
/* How many bytes should we skip? */
130131
skip = (off_t)(S->chunklen - S->chunkpos);
131132
if (skip > S->skiplen)
132133
skip = S->skiplen;
133134

135+
/* Skip bytes. */
134136
S->skiplen -= skip;
135137
S->chunkpos += (size_t)skip;
136138
}
@@ -377,11 +379,13 @@ readtape_read(TAPE_R * d, const void ** buffer)
377379
continue;
378380
}
379381

382+
/* Read data. */
380383
if (stream_get_chunk(readstream, buf, &clen, d->C))
381384
goto err0;
382385
if ((off_t)clen > *readmaxlen)
383386
clen = (size_t)(*readmaxlen);
384387

388+
/* Update position and length. */
385389
readstream->chunkpos += clen;
386390
*readmaxlen -= clen;
387391

tar/multitape/multitape_stats.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,7 @@ statstape_print(TAPE_S * d, const char * tapename, const char * csv_filename,
401401
goto err0;
402402
}
403403

404+
/* Compute statistics. */
404405
if (multitape_chunkiter_tmd(d->SR, d->C, &tmd,
405406
callback_print, d->C, 0))
406407
goto err2;

tar/multitape/multitape_write.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,6 +1054,7 @@ writetape_free(TAPE_W * d)
10541054
if (d == NULL)
10551055
return;
10561056

1057+
/* Clean up. */
10571058
chunks_write_free(d->C);
10581059
storage_write_free(d->S);
10591060
if ((d->lockfd != -1) && close(d->lockfd))

0 commit comments

Comments
 (0)