Skip to content

Commit

Permalink
fixup! lib: Add a lighter weight internal checksum wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
cgwalters committed Oct 10, 2017
1 parent a44c042 commit 36c8169
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/libostree/ostree-repo-commit.c
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,7 @@ write_metadata_object (OstreeRepo *self,
gsize len;
const guint8*bufdata = g_bytes_get_data (buf, &len);
ot_checksum_update (&checksum, bufdata, len);
ot_checksum_get_hexdigest (&checksum, actual_checksum, sizeof(actual_checksum));
ot_checksum_get_hexdigest (&checksum, actual_checksum, sizeof (actual_checksum));
gboolean have_obj;
if (!_ostree_repo_has_loose_object (self, actual_checksum, objtype, &have_obj,
cancellable, error))
Expand Down
2 changes: 1 addition & 1 deletion src/libostree/ostree-sysroot-deploy.c
Original file line number Diff line number Diff line change
Expand Up @@ -1028,7 +1028,7 @@ get_kernel_from_tree_usrlib_modules (int deployment_dfd,
}

char hexdigest[OSTREE_SHA256_STRING_LEN+1];
ot_checksum_get_hexdigest (&checksum, hexdigest, sizeof(hexdigest));
ot_checksum_get_hexdigest (&checksum, hexdigest, sizeof (hexdigest));
ret_layout->bootcsum = g_strdup (hexdigest);

*out_layout = g_steal_pointer (&ret_layout);
Expand Down
6 changes: 3 additions & 3 deletions src/libotutil/ot-checksum-utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ typedef struct {
guint digest_len;
} OtRealChecksum;

G_STATIC_ASSERT (sizeof(OtChecksum) >= sizeof(OtRealChecksum));
G_STATIC_ASSERT (sizeof (OtChecksum) >= sizeof (OtRealChecksum));

void
ot_checksum_init (OtChecksum *checksum)
Expand Down Expand Up @@ -210,7 +210,7 @@ ot_gio_splice_update_checksum (GOutputStream *out,
char buf[4096];
do
{
if (!g_input_stream_read_all (in, buf, sizeof(buf), &bytes_read, cancellable, error))
if (!g_input_stream_read_all (in, buf, sizeof (buf), &bytes_read, cancellable, error))
return FALSE;
if (!ot_gio_write_update_checksum (out, buf, bytes_read, &bytes_written, checksum,
cancellable, error))
Expand Down Expand Up @@ -244,7 +244,7 @@ ot_gio_splice_get_checksum (GOutputStream *out,
return FALSE;

guint8 digest[_OSTREE_SHA256_DIGEST_LEN];
ot_checksum_get_digest (&checksum, digest, sizeof(digest));
ot_checksum_get_digest (&checksum, digest, sizeof (digest));
g_autofree guchar *ret_csum = g_malloc (sizeof (digest));
memcpy (ret_csum, digest, sizeof (digest));
ot_transfer_out_value (out_csum, &ret_csum);
Expand Down
6 changes: 6 additions & 0 deletions src/libotutil/ot-checksum-utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,14 @@ typedef struct OtChecksum OtChecksum;

/* Same as OSTREE_SHA256_DIGEST_LEN, but this header can't depend on that */
#define _OSTREE_SHA256_DIGEST_LEN (32)
#if defined(OSTREE_SHA256_DIGEST_LEN) && _OSTREE_SHA256_DIGEST_LEN != OSTREE_SHA256_DIGEST_LEN
#error Mismatched OSTREE_SHA256_DIGEST_LEN
#endif
/* See above */
#define _OSTREE_SHA256_STRING_LEN (64)
#if defined(OSTREE_SHA256_STRING_LEN) && _OSTREE_SHA256_STRING_LEN != OSTREE_SHA256_STRING_LEN
#error Mismatched OSTREE_SHA256_STRING_LEN
#endif

void ot_checksum_init (OtChecksum *checksum);
void ot_checksum_update (OtChecksum *checksum,
Expand Down

0 comments on commit 36c8169

Please sign in to comment.