summaryrefslogtreecommitdiff
path: root/src/libotutil/ot-checksum-instream.c
diff options
context:
space:
mode:
authorColin Walters <walters@verbum.org>2023-05-03 08:24:21 -0400
committerGitHub <noreply@github.com>2023-05-03 08:24:21 -0400
commit8a2993a9d01cc358e4c2d936ca132174aabdc714 (patch)
tree5402001ab710dadfd51ba3e9071b044016030e3e /src/libotutil/ot-checksum-instream.c
parentdd70c9b78cc34ccc7e638eda4c2df1ddd8ee3add (diff)
parentc1044a02b28982ef6dd58af98b23a40482d26487 (diff)
downloadostree-8a2993a9d01cc358e4c2d936ca132174aabdc714.tar.gz
Merge pull request #2565 from cgwalters/clang-format
Add .clang-format file + tree-wide: Run `clang-format`
Diffstat (limited to 'src/libotutil/ot-checksum-instream.c')
-rw-r--r--src/libotutil/ot-checksum-instream.c50
1 files changed, 18 insertions, 32 deletions
diff --git a/src/libotutil/ot-checksum-instream.c b/src/libotutil/ot-checksum-instream.c
index b48b2360..31286a50 100644
--- a/src/libotutil/ot-checksum-instream.c
+++ b/src/libotutil/ot-checksum-instream.c
@@ -23,22 +23,20 @@
#include "ot-checksum-instream.h"
#include "ot-checksum-utils.h"
-struct _OtChecksumInstreamPrivate {
+struct _OtChecksumInstreamPrivate
+{
OtChecksum checksum;
};
G_DEFINE_TYPE_WITH_PRIVATE (OtChecksumInstream, ot_checksum_instream, G_TYPE_FILTER_INPUT_STREAM)
-static gssize ot_checksum_instream_read (GInputStream *stream,
- void *buffer,
- gsize count,
- GCancellable *cancellable,
- GError **error);
+static gssize ot_checksum_instream_read (GInputStream *stream, void *buffer, gsize count,
+ GCancellable *cancellable, GError **error);
static void
ot_checksum_instream_finalize (GObject *object)
{
- OtChecksumInstream *self = (OtChecksumInstream*)object;
+ OtChecksumInstream *self = (OtChecksumInstream *)object;
ot_checksum_clear (&self->priv->checksum);
@@ -62,26 +60,21 @@ ot_checksum_instream_init (OtChecksumInstream *self)
}
OtChecksumInstream *
-ot_checksum_instream_new (GInputStream *base,
- GChecksumType checksum_type)
+ot_checksum_instream_new (GInputStream *base, GChecksumType checksum_type)
{
return ot_checksum_instream_new_with_start (base, checksum_type, NULL, 0);
}
/* Initialize a checksum stream with starting state from data */
OtChecksumInstream *
-ot_checksum_instream_new_with_start (GInputStream *base,
- GChecksumType checksum_type,
- const guint8 *buf,
- size_t len)
+ot_checksum_instream_new_with_start (GInputStream *base, GChecksumType checksum_type,
+ const guint8 *buf, size_t len)
{
OtChecksumInstream *stream;
g_return_val_if_fail (G_IS_INPUT_STREAM (base), NULL);
- stream = g_object_new (OT_TYPE_CHECKSUM_INSTREAM,
- "base-stream", base,
- NULL);
+ stream = g_object_new (OT_TYPE_CHECKSUM_INSTREAM, "base-stream", base, NULL);
/* For now */
g_assert (checksum_type == G_CHECKSUM_SHA256);
@@ -89,25 +82,18 @@ ot_checksum_instream_new_with_start (GInputStream *base,
if (buf)
ot_checksum_update (&stream->priv->checksum, buf, len);
- return (OtChecksumInstream*) (stream);
+ return (OtChecksumInstream *)(stream);
}
static gssize
-ot_checksum_instream_read (GInputStream *stream,
- void *buffer,
- gsize count,
- GCancellable *cancellable,
- GError **error)
+ot_checksum_instream_read (GInputStream *stream, void *buffer, gsize count,
+ GCancellable *cancellable, GError **error)
{
- OtChecksumInstream *self = (OtChecksumInstream*) stream;
- GFilterInputStream *fself = (GFilterInputStream*) self;
+ OtChecksumInstream *self = (OtChecksumInstream *)stream;
+ GFilterInputStream *fself = (GFilterInputStream *)self;
gssize res = -1;
- res = g_input_stream_read (fself->base_stream,
- buffer,
- count,
- cancellable,
- error);
+ res = g_input_stream_read (fself->base_stream, buffer, count, cancellable, error);
if (res > 0)
ot_checksum_update (&self->priv->checksum, buffer, res);
@@ -117,7 +103,7 @@ ot_checksum_instream_read (GInputStream *stream,
char *
ot_checksum_instream_get_string (OtChecksumInstream *stream)
{
- char buf[_OSTREE_SHA256_STRING_LEN+1];
- ot_checksum_get_hexdigest (&stream->priv->checksum, buf, sizeof(buf));
- return g_strndup (buf, sizeof(buf));
+ char buf[_OSTREE_SHA256_STRING_LEN + 1];
+ ot_checksum_get_hexdigest (&stream->priv->checksum, buf, sizeof (buf));
+ return g_strndup (buf, sizeof (buf));
}