Skip to content

Commit 0fd20ad

Browse files
authored
Re-format project + bump clang-format version (#129)
Setting a fixed clang-format version should avoid confusion about nit-ty details in between clang-format versions. Pick 15; it should be available on all developer platforms, and is fairly recent.
1 parent 904a493 commit 0fd20ad

File tree

4 files changed

+14
-15
lines changed

4 files changed

+14
-15
lines changed

export/planloader/planloader.cpp

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
#include "planloader.h"
44

5-
#include <limits>
65
#include <substrait/common/Io.h>
6+
#include <limits>
77

88
extern "C" {
99

@@ -20,17 +20,16 @@ SerializedPlan* load_substrait_plan(const char* filename) {
2020
auto planOrError = io::substrait::loadPlan(filename);
2121
if (!planOrError.ok()) {
2222
auto errMsg = planOrError.status().message();
23-
newPlan->error_message = new char[errMsg.length()+1];
24-
strncpy(newPlan->error_message, errMsg.data(), errMsg.length()+1);
23+
newPlan->error_message = new char[errMsg.length() + 1];
24+
strncpy(newPlan->error_message, errMsg.data(), errMsg.length() + 1);
2525
return newPlan;
2626
}
2727
::substrait::proto::Plan plan = *planOrError;
2828
std::string text = plan.SerializeAsString();
29-
newPlan->buffer = new unsigned char[text.length()+1];
30-
memcpy(newPlan->buffer, text.data(), text.length()+1);
31-
newPlan->size = static_cast<int32_t>(
32-
text.length() &
33-
std::numeric_limits<int32_t>::max());
29+
newPlan->buffer = new unsigned char[text.length() + 1];
30+
memcpy(newPlan->buffer, text.data(), text.length() + 1);
31+
newPlan->size =
32+
static_cast<int32_t>(text.length() & std::numeric_limits<int32_t>::max());
3433
return newPlan;
3534
}
3635

@@ -49,7 +48,7 @@ const char* save_substrait_plan(
4948
const char* filename,
5049
io::substrait::PlanFileFormat format) {
5150
::substrait::proto::Plan plan;
52-
std::string data((const char*) plan_data, plan_data_length);
51+
std::string data((const char*)plan_data, plan_data_length);
5352
plan.ParseFromString(data);
5453
auto result = io::substrait::savePlan(plan, filename, format);
5554
if (!result.ok()) {
@@ -58,4 +57,4 @@ const char* save_substrait_plan(
5857
return nullptr;
5958
}
6059

61-
} // extern "C"
60+
} // extern "C"

export/planloader/planloader.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ extern "C" {
99

1010
using SerializedPlan = struct {
1111
// If set, contains a serialized ::substrait::proto::Plan object.
12-
unsigned char *buffer;
12+
unsigned char* buffer;
1313
// If buffer is set, this is the size of the buffer.
1414
int32_t size;
1515
// If null the buffer is valid, otherwise this points to a null terminated
1616
// error string.
17-
char *error_message;
17+
char* error_message;
1818
};
1919

2020
// Load a Substrait plan (in any format) from disk.
@@ -43,4 +43,4 @@ const char* save_substrait_plan(
4343

4444
// NOLINTEND(readability-identifier-naming)
4545

46-
} // extern "C"
46+
} // extern "C"

scripts/run-clang-format.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
SCRIPTDIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
44
WORKDIR="$( cd $SCRIPTDIR/.. && pwd )"
55

6-
find $WORKDIR/src $WORKDIR/include \( -name '*.h' -o -name '*.cpp' \) -exec clang-format -style=file -i {} \;
6+
find $WORKDIR/src $WORKDIR/include \( -name '*.h' -o -name '*.cpp' \) -exec clang-format-15 -style=file -i {} \;

scripts/setup-ubuntu.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ sudo --preserve-env apt install -y \
1818
clang-tidy \
1919
git \
2020
wget \
21-
clang-format \
21+
clang-format-15 \
2222
uuid-dev \
2323
default-jre \
2424
libcurl4-openssl-dev

0 commit comments

Comments
 (0)