change: reduce printed noise, rework some code

laumann
Aug 26, 2022, 8:30 PM
WMFNGOYTKIZ7L25V3KMJPSWK23DTN6G3ESP6M55YIH6UTHFKL2XAC

Dependencies

  • [2] VKLGQREY change: add base32 decode, initial deconstruction of hashed
  • [3] OBKF6SII change: decompress the hashed section too
  • [4] RIWSVVAS change: decompress the 'contents' with zstd_seekable
  • [5] KDJUAAAL change: prefix function names with change_
  • [*] Q7TKZCJP Add initial support for reading the offsets from a (fixed) change

Change contents

  • edit in change.c at line 29
    [3.238]
    [3.238]
    }
    static int
    cmp_hash(uint8_t *h1, uint8_t *h2)
    {
    size_t i;
    for (i = 0; i < BLAKE3_OUT_LEN; i++)
    if (h1[i] != h2[i])
    return 1;
    return 0;
  • replacement in change.c at line 110
    [3.1577][3.1577:1631]()
    dump_buf("compressed", compressed, compressed_read);
    [3.1577]
    [3.1631]
    /* dump_buf("compressed", compressed, compressed_read); */
  • replacement in change.c at line 154
    [3.1083][2.775:871]()
    change_decode_hashed(int fd, size_t comp_hashed_len, size_t hashed_len, uint8_t *expected_hash)
    [3.1083]
    [3.1155]
    change_decode_hashed(int fd, size_t comp_hashed_len, size_t hashed_len,
    uint8_t *expected_hash)
  • replacement in change.c at line 160
    [2.917][2.917:950]()
    uint8_t output[BLAKE3_OUT_LEN];
    [2.917]
    [2.950]
    uint8_t computed_hash[BLAKE3_OUT_LEN];
  • edit in change.c at line 162
    [2.961]
    [3.2591]
    int err = 0;
  • edit in change.c at line 169
    [3.1335][3.1335:1373]()
    dump_buf("hashed", buf, hashed_len);
  • edit in change.c at line 170
    [2.963][2.963:1004]()
    /* TODO Decode into 'struct hashed' */
  • replacement in change.c at line 174
    [2.1133][2.1133:1190]()
    blake3_hasher_finalize(&b3sum, output, BLAKE3_OUT_LEN);
    [2.1133]
    [2.1190]
    blake3_hasher_finalize(&b3sum, computed_hash, BLAKE3_OUT_LEN);
  • edit in change.c at line 176
    [2.1191][2.1191:1274]()
    for (i = 0; i < BLAKE3_OUT_LEN; i++)
    printf("%02x", output[i]);
    printf("\n");
  • replacement in change.c at line 177
    [2.1304][2.1304:1396]()
    for (i = 0; i < BLAKE3_OUT_LEN; i++)
    printf("%02x", expected_hash[i]);
    printf("\n");
    [2.1304]
    [2.1396]
    err = cmp_hash(computed_hash, expected_hash);
    if (err) {
    fprintf(stderr, "error: change hash mismatch, claimed \n");
    for (i = 0; i < BLAKE3_OUT_LEN; i++)
    fprintf(stderr, "%02x", expected_hash[i]);
    fprintf(stderr, ", computed ");
    for (i = 0; i < BLAKE3_OUT_LEN; i++)
    fprintf(stderr, "%02x", expected_hash[i]);
    fprintf(stderr, "\n");
    }
  • edit in change.c at line 188
    [2.1399]
    [2.1399]
    /* TODO Decode into 'struct hashed' */
  • replacement in change.c at line 192
    [3.1386][3.1386:1397]()
    return 0;
    [3.1386]
    [3.1397]
    return err;
  • replacement in change.c at line 264
    [3.188][3.188:239]()
    dump_buf("contents", contents, off.contents_len);
    [3.188]
    [3.239]
    /* dump_buf("contents", contents, off.contents_len); */