Skip to content

Commit

Permalink
Fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
timopollmeier committed Aug 30, 2024
1 parent 3d4e746 commit b3be202
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 26 deletions.
13 changes: 7 additions & 6 deletions util/compressutils.c
Original file line number Diff line number Diff line change
Expand Up @@ -242,11 +242,11 @@ gvm_compress_gzipheader (const void *src, unsigned long srclen,

/**
* @brief Read decompressed data from a gzip file.
*
*
* @param[in] cookie The gzFile to read from.
* @param[in] buffer The buffer to output decompressed data to.
* @param[in] buffer_size The size of the buffer.
*
*
* @return The number of bytes read into the buffer.
*/
static ssize_t
Expand All @@ -259,17 +259,18 @@ gz_file_read (void *cookie, char *buffer, size_t buffer_size)

/**
* @brief Close a gzip file.
*
*
* @param[in] cookie The gzFile to close.
*
*
* @return 0 on success, other values on error (see gzclose() from zlib).
*/
static int
gz_file_close (void *cookie)
{
gzFile gz_file = cookie;

return gzclose (gz_file);;
return gzclose (gz_file);
;
}

/**
Expand All @@ -288,7 +289,7 @@ gvm_gzip_open_file_reader (const char *path)
.seek = NULL,
.close = gz_file_close,
};

if (path == NULL)
{
return NULL;

Check warning on line 295 in util/compressutils.c

View check run for this annotation

Codecov / codecov/patch

util/compressutils.c#L295

Added line #L295 was not covered by tests
Expand Down
39 changes: 19 additions & 20 deletions util/compressutils_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,52 +17,52 @@ AfterEach (compressutils)
{
}

Ensure(compressutils, can_compress_and_uncompress_without_header)
Ensure (compressutils, can_compress_and_uncompress_without_header)
{
const char *testdata = "TEST-12345-12345-TEST";

size_t compressed_len;
char *compressed
= gvm_compress (testdata, strlen(testdata) + 1, &compressed_len);
char *compressed =
gvm_compress (testdata, strlen (testdata) + 1, &compressed_len);
assert_that (compressed_len, is_greater_than (0));
assert_that (compressed, is_not_null);
assert_that (compressed, is_not_equal_to_string (testdata));

size_t uncompressed_len;
char *uncompressed
= gvm_uncompress (compressed, compressed_len, &uncompressed_len);
assert_that (uncompressed_len, is_equal_to (strlen(testdata) + 1));
char *uncompressed =
gvm_uncompress (compressed, compressed_len, &uncompressed_len);
assert_that (uncompressed_len, is_equal_to (strlen (testdata) + 1));
assert_that (uncompressed, is_equal_to_string (testdata));
}

Ensure(compressutils, can_compress_and_uncompress_with_header)
Ensure (compressutils, can_compress_and_uncompress_with_header)
{
const char *testdata = "TEST-12345-12345-TEST";

size_t compressed_len;
char *compressed
= gvm_compress_gzipheader (testdata, strlen(testdata) + 1, &compressed_len);
char *compressed =
gvm_compress_gzipheader (testdata, strlen (testdata) + 1, &compressed_len);
assert_that (compressed_len, is_greater_than (0));
assert_that (compressed, is_not_null);
assert_that (compressed, is_not_equal_to_string (testdata));
// Check for gzip magic number and deflate compression mode byte
assert_that (compressed[0], is_equal_to((char)0x1f));
assert_that (compressed[1], is_equal_to((char)0x8b));
assert_that (compressed[2], is_equal_to(8));
assert_that (compressed[0], is_equal_to ((char) 0x1f));
assert_that (compressed[1], is_equal_to ((char) 0x8b));
assert_that (compressed[2], is_equal_to (8));

size_t uncompressed_len;
char *uncompressed
= gvm_uncompress (compressed, compressed_len, &uncompressed_len);
assert_that (uncompressed_len, is_equal_to (strlen(testdata) + 1));
char *uncompressed =
gvm_uncompress (compressed, compressed_len, &uncompressed_len);
assert_that (uncompressed_len, is_equal_to (strlen (testdata) + 1));
assert_that (uncompressed, is_equal_to_string (testdata));
}

Ensure(compressutils, can_uncompress_using_reader)
Ensure (compressutils, can_uncompress_using_reader)
{
const char *testdata = "TEST-12345-12345-TEST";
size_t compressed_len;
char *compressed
= gvm_compress_gzipheader (testdata, strlen(testdata) + 1, &compressed_len);
char *compressed =
gvm_compress_gzipheader (testdata, strlen (testdata) + 1, &compressed_len);

char compressed_filename[35] = "/tmp/gvm_gzip_test_XXXXXX";
int compressed_fd = mkstemp (compressed_filename);
Expand Down Expand Up @@ -91,8 +91,7 @@ main (int argc, char **argv)
can_compress_and_uncompress_without_header);
add_test_with_context (suite, compressutils,
can_compress_and_uncompress_with_header);
add_test_with_context (suite, compressutils,
can_uncompress_using_reader);
add_test_with_context (suite, compressutils, can_uncompress_using_reader);

if (argc > 1)
return run_single_test (suite, argv[1], create_text_reporter ());

Check warning on line 97 in util/compressutils_tests.c

View check run for this annotation

Codecov / codecov/patch

util/compressutils_tests.c#L97

Added line #L97 was not covered by tests
Expand Down

0 comments on commit b3be202

Please sign in to comment.