Skip to content

Commit

Permalink
Merge pull request #152 from robert-scheck/c99-for-loop
Browse files Browse the repository at this point in the history
Change C99 for loop init to C89 for compatibility
  • Loading branch information
Thomas-Tsai authored Jan 6, 2021
2 parents f71db53 + 58e56e3 commit 378158f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/torrent_helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,15 @@ void torrent_update(torrent_generator *torrent, void *buffer, size_t length)
unsigned long long buffer_offset = 0;

int tinfo = torrent->tinfo;
int x = 0;

while (buffer_remain_length > 0) {
sha_remain_length = BT_PIECE_SIZE - sha_length;
if (sha_remain_length <= 0) {
// finish a piece
SHA1_Final(torrent->hash, &torrent->ctx);
dprintf(tinfo, "sha1: ");
for (int x = 0; x < SHA_DIGEST_LENGTH; x++) {
for (x = 0; x < SHA_DIGEST_LENGTH; x++) {
dprintf(tinfo, "%02x", torrent->hash[x]);
}
dprintf(tinfo, "\n");
Expand Down Expand Up @@ -67,10 +68,12 @@ void torrent_update(torrent_generator *torrent, void *buffer, size_t length)

void torrent_final(torrent_generator *torrent)
{
int x = 0;

if (torrent->length) {
SHA1_Final(torrent->hash, &torrent->ctx);
dprintf(torrent->tinfo, "sha1: ");
for (int x = 0; x < SHA_DIGEST_LENGTH; x++) {
for (x = 0; x < SHA_DIGEST_LENGTH; x++) {
dprintf(torrent->tinfo, "%02x", torrent->hash[x]);
}
dprintf(torrent->tinfo, "\n");
Expand Down

0 comments on commit 378158f

Please sign in to comment.