Skip to content

Commit

Permalink
Fix style issues
Browse files Browse the repository at this point in the history
  • Loading branch information
larsevj authored and eivindjahren committed Jan 6, 2025
1 parent c76fecd commit 9c3f836
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 28 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,14 @@ jobs:

steps:
- uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.12'

- name: Install dependencies
run: |
sudo pip install cmake-format black
pip install cmake-format clang-format black
- name: Clang Format
run: ./script/clang-format --check
Expand Down
5 changes: 2 additions & 3 deletions lib/include/resdata/rd_file.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ extern "C" {
#include <resdata/rd_type.hpp>

#define RD_FILE_FLAGS_ENUM_DEFS \
{.value = 1, .name = "RD_FILE_CLOSE_STREAM"}, { \
.value = 2, .name = "RD_FILE_WRITABLE" \
}
{.value = 1, .name = "RD_FILE_CLOSE_STREAM"}, \
{.value = 2, .name = "RD_FILE_WRITABLE"}
#define RD_FILE_FLAGS_ENUM_SIZE 2

typedef struct rd_file_struct rd_file_type;
Expand Down
2 changes: 1 addition & 1 deletion lib/include/resdata/rd_grid.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ extern "C" {
#endif

#define RD_GRID_COORD_SIZE(nx, ny) (((nx) + 1) * ((ny) + 1) * 6)
#define RD_GRID_ZCORN_SIZE(nx, ny, nz) (((nx) * (ny) * (nz)*8))
#define RD_GRID_ZCORN_SIZE(nx, ny, nz) (((nx) * (ny) * (nz) * 8))

#define RD_GRID_GLOBAL_GRID "Global" // used as key in hash tables over grids.
#define RD_GRID_MAINGRID_LGR_NR 0
Expand Down
23 changes: 8 additions & 15 deletions lib/include/resdata/rd_type.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,8 @@ typedef enum {
{.value = 2, .name = "RD_DOUBLE_TYPE"}, \
{.value = 3, .name = "RD_INT_TYPE"}, \
{.value = 4, .name = "RD_BOOL_TYPE"}, \
{.value = 5, .name = "RD_MESS_TYPE"}, { \
.value = 7, .name = "RD_STRING_TYPE" \
}
{.value = 5, .name = "RD_MESS_TYPE"}, \
{.value = 7, .name = "RD_STRING_TYPE"}

/*
Character data in restart format files comes as an array of fixed-length
Expand All @@ -67,20 +66,15 @@ struct rd_type_struct {
rd_data_type { RD_DOUBLE_TYPE, sizeof(double) }
#define RD_BOOL \
rd_data_type { RD_BOOL_TYPE, sizeof(bool) }
#define RD_CHAR \
rd_data_type { RD_CHAR_TYPE, RD_STRING8_LENGTH + 1 }
#define RD_MESS \
rd_data_type { RD_MESS_TYPE, 0 }
#define RD_STRING(size) \
rd_data_type { RD_STRING_TYPE, (size) + 1 }
#define RD_CHAR rd_data_type{RD_CHAR_TYPE, RD_STRING8_LENGTH + 1}
#define RD_MESS rd_data_type{RD_MESS_TYPE, 0}
#define RD_STRING(size) rd_data_type{RD_STRING_TYPE, (size) + 1}
}

#else

#define RD_CHAR \
(rd_data_type) { \
.type = RD_CHAR_TYPE, .element_size = RD_STRING8_LENGTH + 1 \
}
(rd_data_type){.type = RD_CHAR_TYPE, .element_size = RD_STRING8_LENGTH + 1}
#define RD_INT \
(rd_data_type) { .type = RD_INT_TYPE, .element_size = sizeof(int) }
#define RD_FLOAT \
Expand All @@ -89,10 +83,9 @@ struct rd_type_struct {
(rd_data_type) { .type = RD_DOUBLE_TYPE, .element_size = sizeof(double) }
#define RD_BOOL \
(rd_data_type) { .type = RD_BOOL_TYPE, .element_size = sizeof(bool) }
#define RD_MESS \
(rd_data_type) { .type = RD_MESS_TYPE, .element_size = 0 }
#define RD_MESS (rd_data_type){.type = RD_MESS_TYPE, .element_size = 0}
#define RD_STRING(size) \
(rd_data_type) { .type = RD_STRING_TYPE, .element_size = (size) + 1 }
(rd_data_type){.type = RD_STRING_TYPE, .element_size = (size) + 1}

#endif

Expand Down
4 changes: 2 additions & 2 deletions lib/include/resdata/rd_units.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ extern "C" {
#endif

#define RD_UNITS_CUBIC(x) ((x) * (x) * (x))
#define RD_UNITS_MILLI(x) ((x)*0.001)
#define RD_UNITS_MEGA(x) ((x)*1000000)
#define RD_UNITS_MILLI(x) ((x) * 0.001)
#define RD_UNITS_MEGA(x) ((x) * 1000000)

#define RD_UNITS_LENGTH_INCH 0.0254
#define RD_UNITS_LENGTH_FEET 12 * RD_UNITS_LENGTH_INCH
Expand Down
5 changes: 2 additions & 3 deletions lib/include/resdata/rd_util.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,8 @@ typedef enum {

#define RD_PHASE_ENUM_DEFS \
{.value = 1, .name = "RD_OIL_PHASE"}, \
{.value = 2, .name = "RD_GAS_PHASE"}, { \
.value = 4, .name = "RD_WATER_PHASE" \
}
{.value = 2, .name = "RD_GAS_PHASE"}, \
{.value = 4, .name = "RD_WATER_PHASE"}
#define RD_PHASE_ENUM_SIZE 3

typedef enum {
Expand Down
4 changes: 3 additions & 1 deletion lib/resdata/tests/rd_kw_fread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ void test_kw_io_charlength() {
fortio_fclose(f);
}

{ test_assert_false(util_file_exists("TEST1")); }
{
test_assert_false(util_file_exists("TEST1"));
}

{
FILE *file = util_fopen("TEST2", "w");
Expand Down
4 changes: 2 additions & 2 deletions lib/util/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,8 @@ void util_endian_flip_vector(void *data, int element_size, int elements) {
}

#ifndef S_ISDIR
#define S_ISDIR(m) (((m)&S_IFMT) == S_IFDIR)
#define S_ISREG(m) (((m)&S_IFMT) == S_IFREG)
#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
#endif

static bool EOL_CHAR(char c) {
Expand Down

0 comments on commit 9c3f836

Please sign in to comment.