Skip to content

Commit

Permalink
Rename buffer_util.h to binary.h
Browse files Browse the repository at this point in the history
It will allow to expose more binary util functions not related to
buffers.

PR #3369 <#3369>
  • Loading branch information
rom1v committed Aug 28, 2022
1 parent 136ab8c commit 041cdf6
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 20 deletions.
4 changes: 2 additions & 2 deletions app/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,8 @@ if get_option('buildtype') == 'debug'
'src/util/str.c',
'src/util/strbuf.c',
]],
['test_buffer_util', [
'tests/test_buffer_util.c',
['test_binary', [
'tests/test_binary.c',
]],
['test_cbuf', [
'tests/test_cbuf.c',
Expand Down
2 changes: 1 addition & 1 deletion app/src/control_msg.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <stdlib.h>
#include <string.h>

#include "util/buffer_util.h"
#include "util/binary.h"
#include "util/log.h"
#include "util/str.h"

Expand Down
2 changes: 1 addition & 1 deletion app/src/demuxer.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "decoder.h"
#include "events.h"
#include "recorder.h"
#include "util/buffer_util.h"
#include "util/binary.h"
#include "util/log.h"

#define SC_PACKET_HEADER_SIZE 12
Expand Down
2 changes: 1 addition & 1 deletion app/src/device_msg.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <stdlib.h>
#include <string.h>

#include "util/buffer_util.h"
#include "util/binary.h"
#include "util/log.h"

ssize_t
Expand Down
4 changes: 2 additions & 2 deletions app/src/util/buffer_util.h → app/src/util/binary.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef SC_BUFFER_UTIL_H
#define SC_BUFFER_UTIL_H
#ifndef SC_BINARY_H
#define SC_BINARY_H

#include "common.h"

Expand Down
26 changes: 13 additions & 13 deletions app/tests/test_buffer_util.c → app/tests/test_binary.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

#include <assert.h>

#include "util/buffer_util.h"
#include "util/binary.h"

static void test_buffer_write16be(void) {
static void test_write16be(void) {
uint16_t val = 0xABCD;
uint8_t buf[2];

Expand All @@ -14,7 +14,7 @@ static void test_buffer_write16be(void) {
assert(buf[1] == 0xCD);
}

static void test_buffer_write32be(void) {
static void test_write32be(void) {
uint32_t val = 0xABCD1234;
uint8_t buf[4];

Expand All @@ -26,7 +26,7 @@ static void test_buffer_write32be(void) {
assert(buf[3] == 0x34);
}

static void test_buffer_write64be(void) {
static void test_write64be(void) {
uint64_t val = 0xABCD1234567890EF;
uint8_t buf[8];

Expand All @@ -42,23 +42,23 @@ static void test_buffer_write64be(void) {
assert(buf[7] == 0xEF);
}

static void test_buffer_read16be(void) {
static void test_read16be(void) {
uint8_t buf[2] = {0xAB, 0xCD};

uint16_t val = sc_read16be(buf);

assert(val == 0xABCD);
}

static void test_buffer_read32be(void) {
static void test_read32be(void) {
uint8_t buf[4] = {0xAB, 0xCD, 0x12, 0x34};

uint32_t val = sc_read32be(buf);

assert(val == 0xABCD1234);
}

static void test_buffer_read64be(void) {
static void test_read64be(void) {
uint8_t buf[8] = {0xAB, 0xCD, 0x12, 0x34,
0x56, 0x78, 0x90, 0xEF};

Expand All @@ -71,11 +71,11 @@ int main(int argc, char *argv[]) {
(void) argc;
(void) argv;

test_buffer_write16be();
test_buffer_write32be();
test_buffer_write64be();
test_buffer_read16be();
test_buffer_read32be();
test_buffer_read64be();
test_write16be();
test_write32be();
test_write64be();
test_read16be();
test_read32be();
test_read64be();
return 0;
}

0 comments on commit 041cdf6

Please sign in to comment.