Skip to content

Commit 19df26b

Browse files
authored
fix: fix compile warnings (#4038)
1 parent 18ac3d3 commit 19df26b

File tree

17 files changed

+41
-36
lines changed

17 files changed

+41
-36
lines changed

hybridse/include/base/fe_status.h

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,9 @@ namespace hybridse {
2727
namespace base {
2828

2929
template <typename STREAM, typename... Args>
30-
static inline std::initializer_list<int> __output_literal_args(STREAM& stream, // NOLINT
31-
Args... args) { // NOLINT
32-
#ifdef __APPLE__
33-
#pragma GCC diagnostic push
34-
#pragma GCC diagnostic ignored "-Wreturn-stack-address"
35-
#endif
36-
return std::initializer_list<int>{(stream << args, 0)...};
37-
#ifdef __APPLE__
38-
#pragma GCC diagnostic pop
39-
#endif
30+
static inline void __output_literal_args(STREAM& stream, // NOLINT
31+
Args... args) { // NOLINT
32+
((stream << args), ...);
4033
}
4134

4235
#define MAX_STATUS_TRACE_SIZE 4096

hybridse/include/vm/engine.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ class RequestRunSession : public RunSession {
256256
/// \param in_row: request row
257257
/// \param[out] output: result is written to this variable
258258
/// \return `0` if run successfully else negative integer
259-
int32_t Run(uint32_t task_id, const Row& in_row, Row* output); // NOLINT
259+
int32_t Run(int32_t task_id, const Row& in_row, Row* output); // NOLINT
260260

261261
/// \brief Return the schema of request row
262262
virtual const Schema& GetRequestSchema() const {
@@ -303,7 +303,7 @@ class BatchRequestRunSession : public RunSession {
303303
/// \param request_batch: a batch of request rows
304304
/// \param output: query results will be returned as std::vector<Row> in output
305305
/// \return 0 if runs successfully else negative integer
306-
int32_t Run(const uint32_t id, const std::vector<Row>& request_batch, std::vector<Row>& output); // NOLINT
306+
int32_t Run(int32_t id, const std::vector<Row>& request_batch, std::vector<Row>& output); // NOLINT
307307

308308
/// \brief Add common column idx
309309
void AddCommonColumnIdx(size_t idx) { common_column_indices_.insert(idx); }

hybridse/src/base/fe_linenoise.cc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,9 @@ static void refreshSingleLine(struct linenoiseState *l) {
539539
/* Move cursor to original position. */
540540
snprintf(seq, sizeof(seq), "\r\x1b[%dC", static_cast<int>(pos + plen));
541541
abAppend(&ab, seq, strlen(seq));
542-
write(fd, ab.b, ab.len);
542+
if (write(fd, ab.b, ab.len) == -1) {
543+
perror("terminal write failed");
544+
}
543545
/* Can't recover from write error. */
544546
abFree(&ab);
545547
}
@@ -627,7 +629,9 @@ static void refreshMultiLine(struct linenoiseState *l) {
627629
lndebug("\n");
628630
l->oldpos = l->pos;
629631

630-
write(fd, ab.b, ab.len); /* Can't recover from write error. */
632+
if (write(fd, ab.b, ab.len) == -1) { /* Can't recover from write error. */
633+
perror("terminal write failed");
634+
}
631635
abFree(&ab);
632636
}
633637

hybridse/src/codec/fe_row_codec.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1166,7 +1166,7 @@ base::Status RowBuilder2::Build(const std::vector<node::ExprNode*>& values, code
11661166

11671167
auto expect_cols =
11681168
std::accumulate(schemas_.begin(), schemas_.end(), 0, [](int val, const auto& e) { return val + e.size(); });
1169-
CHECK_TRUE(values.size() == expect_cols, common::kCodegenEncodeError, "pass in expr number do not match, expect ",
1169+
CHECK_TRUE(values.size() == static_cast<size_t>(expect_cols), common::kCodegenEncodeError, "pass in expr number do not match, expect ",
11701170
expect_cols, " but got ", values.size(), ": (",
11711171
absl::StrJoin(
11721172
values, ", ",
@@ -1193,7 +1193,7 @@ base::Status RowBuilder2::Build(const std::vector<node::ExprNode*>& values, code
11931193
return {};
11941194
}
11951195
base::Status RowBuilder2::InitSchema(int idx, const codec::Schema& sc) {
1196-
if (idx >= schemas_.size()) {
1196+
if (static_cast<size_t>(idx) >= schemas_.size()) {
11971197
return {common::kCodegenEncodeError, "idx out of bound"};
11981198
}
11991199
schemas_[idx] = sc;

hybridse/src/codegen/insert_row_builder.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ absl::StatusOr<std::shared_ptr<int8_t>> InsertRowBuilder::ComputeRow(absl::Span<
5858
}
5959

6060
absl::StatusOr<int8_t*> InsertRowBuilder::ComputeRowUnsafe(absl::Span<node::ExprNode* const> values) {
61-
if (schema_->size() != values.size()) {
61+
if (static_cast<size_t>(schema_->size()) != values.size()) {
6262
return absl::FailedPreconditionError(
6363
absl::Substitute("invalid expression number, expect $0, but got $1", schema_->size(), values.size()));
6464
}

hybridse/src/codegen/struct_ir_builder.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ absl::StatusOr<NativeValue> Combine(CodeGenContextBase* ctx, const NativeValue d
301301
llvm::Value* input_arrays = builder->CreateAlloca(input_arr_type, builder->getInt32(args.size()), "array_data");
302302
node::NodeManager nm;
303303
std::vector<NativeValue> casted_args(args.size());
304-
for (int i = 0; i < args.size(); ++i) {
304+
for (size_t i = 0; i < args.size(); ++i) {
305305
const node::TypeNode* tp = nullptr;
306306
if (!GetFullType(&nm, args.at(i).GetType(), &tp)) {
307307
return absl::InternalError("codegen error: fail to get valid type from llvm value");

hybridse/src/node/plan_node.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,10 @@ std::string NameOfPlanNodeType(const PlanType &type) {
231231
return "kPlanTypeAlterUser";
232232
case kPlanTypeCallStmt:
233233
return "kPlanTypeCallStmt";
234+
case kPlanTypeGrant:
235+
return "kPlanTypeGrant";
236+
case kPlanTypeRevoke:
237+
return "kPlanTypeRevoke";
234238
case kUnknowPlan:
235239
return std::string("kUnknow");
236240
}

hybridse/src/passes/expression/cache_expressions.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ std::string CallExprKey(const node::CallExprNode* call) {
3737

3838
base::Status CacheExpressions::Apply(node::ExprAnalysisContext* ctx, node::ExprNode* expr, node::ExprNode** out) {
3939
*out = expr;
40-
for (int i = 0; i < expr->GetChildNum(); ++i) {
40+
for (size_t i = 0; i < expr->GetChildNum(); ++i) {
4141
node::ExprNode* co = nullptr;
4242
CHECK_STATUS(Apply(ctx, expr->GetChild(i), &co));
4343
if (co != nullptr && co != expr->GetChild(i)) {

hybridse/src/rewriter/ast_rewriter.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ class RequestQueryRewriteUnparser : public zetasql::parser::Unparser {
459459

460460
void constSelectListAsConfigClause(const std::vector<const zetasql::ASTExpression*>& selects, void* data) {
461461
print("CONFIG (execute_mode = 'request', values = (");
462-
for (int i = 0; i < selects.size(); ++i) {
462+
for (size_t i = 0; i < selects.size(); ++i) {
463463
selects.at(i)->Accept(this, data);
464464
if (i + 1 < selects.size()) {
465465
print(",");

hybridse/src/udf/default_defs/array_def.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ void SplitString(StringRef* str, StringRef* delimeter, ArrayRef<StringRef>* arra
104104

105105
void array_join(ArrayRef<StringRef>* arr, StringRef* del, bool del_null, StringRef* out) {
106106
int sz = 0;
107-
for (int i = 0; i < arr->size; ++i) {
107+
for (size_t i = 0; i < arr->size; ++i) {
108108
if (!arr->nullables[i]) {
109109
if (!del_null && i > 0) {
110110
sz += del->size_;
@@ -117,7 +117,7 @@ void array_join(ArrayRef<StringRef>* arr, StringRef* del, bool del_null, StringR
117117
memset(buf, 0, sz);
118118

119119
int32_t idx = 0;
120-
for (int i = 0; i < arr->size; ++i) {
120+
for (size_t i = 0; i < arr->size; ++i) {
121121
if (!arr->nullables[i]) {
122122
if (!del_null && i > 0) {
123123
memcpy(buf + idx, del->data_, del->size_);

0 commit comments

Comments
 (0)