diff options
author | Runxi Yu <me@runxiyu.org> | 2025-08-12 11:01:07 +0800 |
---|---|---|
committer | Runxi Yu <me@runxiyu.org> | 2025-09-26 17:25:37 +0800 |
commit | e238ccb06b05e88ec323ca95ad4600bd79743372 (patch) | |
tree | 46f82d4d0f4ec43e94dcde5677de1ba857862638 /git2d/bare.c | |
parent | Remove forge-specific functions from misc (diff) | |
download | forge-e238ccb06b05e88ec323ca95ad4600bd79743372.tar.gz forge-e238ccb06b05e88ec323ca95ad4600bd79743372.tar.zst forge-e238ccb06b05e88ec323ca95ad4600bd79743372.zip |
Diffstat (limited to '')
-rw-r--r-- | git2d/bare.c | 29 |
1 files changed, 7 insertions, 22 deletions
diff --git a/git2d/bare.c b/git2d/bare.c index b580980..2d43015 100644 --- a/git2d/bare.c +++ b/git2d/bare.c @@ -114,8 +114,7 @@ bare_error bare_get_u16(struct bare_reader *ctx, uint16_t *x) bare_error err = ctx->read(ctx->buffer, x, U16SZ); if (err == BARE_ERROR_NONE) { - *x = (uint16_t) ((uint8_t *) x)[0] - | (uint16_t) ((uint8_t *) x)[1] << 8; + *x = (uint16_t) ((uint8_t *) x)[0] | (uint16_t) ((uint8_t *) x)[1] << 8; } return err; @@ -138,10 +137,7 @@ bare_error bare_get_u32(struct bare_reader *ctx, uint32_t *x) bare_error err = ctx->read(ctx->buffer, x, U32SZ); if (err == BARE_ERROR_NONE) { - *x = (uint32_t) (((uint8_t *) x)[0]) - | (uint32_t) (((uint8_t *) x)[1] << 8) - | (uint32_t) (((uint8_t *) x)[2] << 16) - | (uint32_t) (((uint8_t *) x)[3] << 24); + *x = (uint32_t) (((uint8_t *) x)[0]) | (uint32_t) (((uint8_t *) x)[1] << 8) | (uint32_t) (((uint8_t *) x)[2] << 16) | (uint32_t) (((uint8_t *) x)[3] << 24); } return err; @@ -168,14 +164,7 @@ bare_error bare_get_u64(struct bare_reader *ctx, uint64_t *x) bare_error err = ctx->read(ctx->buffer, x, U64SZ); if (err == BARE_ERROR_NONE) { - *x = (uint64_t) ((uint8_t *) x)[0] - | (uint64_t) ((uint8_t *) x)[1] << 8 - | (uint64_t) ((uint8_t *) x)[2] << 16 - | (uint64_t) ((uint8_t *) x)[3] << 24 - | (uint64_t) ((uint8_t *) x)[4] << 32 - | (uint64_t) ((uint8_t *) x)[5] << 40 - | (uint64_t) ((uint8_t *) x)[6] << 48 - | (uint64_t) ((uint8_t *) x)[7] << 56; + *x = (uint64_t) ((uint8_t *) x)[0] | (uint64_t) ((uint8_t *) x)[1] << 8 | (uint64_t) ((uint8_t *) x)[2] << 16 | (uint64_t) ((uint8_t *) x)[3] << 24 | (uint64_t) ((uint8_t *) x)[4] << 32 | (uint64_t) ((uint8_t *) x)[5] << 40 | (uint64_t) ((uint8_t *) x)[6] << 48 | (uint64_t) ((uint8_t *) x)[7] << 56; } return err; @@ -257,20 +246,17 @@ bare_error bare_get_bool(struct bare_reader *ctx, bool *x) return bare_get_u8(ctx, (uint8_t *) x); } -bare_error -bare_put_fixed_data(struct bare_writer *ctx, const uint8_t *src, uint64_t sz) +bare_error bare_put_fixed_data(struct bare_writer *ctx, const uint8_t *src, uint64_t sz) { return ctx->write(ctx->buffer, (void *)src, sz); } -bare_error -bare_get_fixed_data(struct bare_reader *ctx, uint8_t *dst, uint64_t sz) +bare_error bare_get_fixed_data(struct bare_reader *ctx, uint8_t *dst, uint64_t sz) { return ctx->read(ctx->buffer, dst, sz); } -bare_error -bare_put_data(struct bare_writer *ctx, const uint8_t *src, uint64_t sz) +bare_error bare_put_data(struct bare_writer *ctx, const uint8_t *src, uint64_t sz) { bare_error err = BARE_ERROR_NONE; @@ -291,8 +277,7 @@ bare_error bare_get_data(struct bare_reader *ctx, uint8_t *dst, uint64_t sz) err = bare_get_uint(ctx, &ssz); if (err == BARE_ERROR_NONE) { - err = ssz <= sz ? bare_get_fixed_data(ctx, dst, ssz) - : BARE_ERROR_BUFFER_TOO_SMALL; + err = ssz <= sz ? bare_get_fixed_data(ctx, dst, ssz) : BARE_ERROR_BUFFER_TOO_SMALL; } return err; |