Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions tar/ccache/ccache_entry.c
Original file line number Diff line number Diff line change
Expand Up @@ -552,11 +552,19 @@ ccache_entry_writefile(CCACHE_ENTRY * cce, TAPE_W * cookie,
cce->ccr->size = cce->size_new;
cce->ccr->mtime = cce->mtime_new;

/*
* Decide if we want to keep a trailer: We follow the policy provided
* by the caller (record a trailer unless notrailer != 0) unless we're
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was a bit confused by the "unless notrailer != 0" bit in the comment, since that's not part of this "paragraph". If we already have notrailer = 1, then that only applies below on line 567.

For clarity, I'd be tempted to put lines 561-563 inside an

if (notrailer == 0) {
}

OTOH, you might take the view that anybody reading this section should be able to figure it out, so shrug.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I agree it's not the clearest code but I don't want to complicate things by adding another conditional either. I think this is fine.

* spending too much memory keeping track of trailers *and* this file
* is under 10 MB.
*/
if ((cce->cci->trailerusage > cce->cci->chunksusage * 2) &&
(cce->ccr->size < 10 * 1024 * 1024))
notrailer = 1;

/* Ask the multitape layer to inform us about later chunks. */
writetape_setcallback(cookie, callback_addchunk,
((cce->cci->trailerusage > cce->cci->chunksusage * 2) ||
(notrailer != 0)) ? callback_faketrailer : callback_addtrailer,
cce);
notrailer ? callback_faketrailer : callback_addtrailer, cce);

/* Success! */
return (skiplen);
Expand Down