[GLUTEN-8475][VL] Fix C-style casts to C++-style#8474
Conversation
|
Thanks for opening a pull request! Could you open an issue for this pull request on Github Issues? https://github.com/apache/incubator-gluten/issues Then could you also rename commit message and pull request title in the following format? See also: |
cpp/core/memory/MemoryAllocator.cc
Outdated
| } | ||
| if (newSize <= size) { | ||
| auto aligned = ROUND_TO_LINE(newSize, alignment); | ||
| auto aligned = ROUND_TO_LINE(static_cast<uint64_t> newSize, alignment); |
There was a problem hiding this comment.
Dont Use Cast@cpp/core/memory/MemoryAllocator.cc:164
looks like newSize is int64_t and alignment is uint64_t so i'm assuming there is some sort of casting that goes on when calling this function. With that I figured they should both go in with the same type. With the above line showing if (newSize <= 0) {return false;} im assuming newSize will be positive if it gets to here so I just casted it to be uint64_t like the alignment variable
There was a problem hiding this comment.
sorry I did forget the parenthesis around newSize, updating!
There was a problem hiding this comment.
I see, thanks.
It seems GitHub CI service is encountering issues so the CI is not triggering BTW.
|
@jkhaliqi Would you fix the code style? Thanks! https://github.com/apache/incubator-gluten/actions/runs/12682962050/job/35349998150?pr=8474 |
| const auto* rawBuffer = buffer->as<char>(); | ||
| while (rowOffset_ < cur->first && readRows < batchSize_) { | ||
| auto rowSize = *(RowSizeType*)(rawBuffer + byteOffset_) - sizeof(RowSizeType); | ||
| auto rowSize = *(static_cast<RowSizeType*>(rawBuffer + byteOffset_)) - sizeof(RowSizeType); |
There was a problem hiding this comment.
Is there a reason that you don't use this one liner for other occurrences?
In other cases you are splitting it into two lines (first the ptr and then the dereference, for example, previous file line 186ff.
There was a problem hiding this comment.
No reason updating all to be one liner, thank you!
| makeConstantExpr(INTEGER(), static_cast<int32_t>(678)), | ||
| makeConstantExpr(BIGINT(), static_cast<int64_t>(910)), | ||
| makeConstantExpr(REAL(), static_cast<float>(1.23)), | ||
| makeConstantExpr(BOOLEAN(), 1), |
There was a problem hiding this comment.
What's wrong with these but not the last double cast?
There was a problem hiding this comment.
Missed the last one, updated, thank you!
38bbc19 to
6b942fb
Compare
cpp/core/utils/qpl/QplCodec.cc
Outdated
| ARROW_DCHECK_GE(input_len, 0); | ||
| /// Aligned with ZLIB | ||
| return ((input_len) + ((input_len) >> 12) + ((input_len) >> 14) + ((input_len) >> 25) + 13); | ||
| return ((input_len) + ((input_len) >> 12) + ((input_len) >> 14) + ((input_len) >> 25) + static_cast<int64_t>(13)); |
There was a problem hiding this comment.
13LL gets rid of the unnecessary casting so updating with this, thank you!
Coupld of security volation fix
What changes were proposed in this pull request?
False positives for Do not Cast
cpp/velox/compute/WholeStageResultIterator.cc:461
cpp/velox/compute/WholeStageResultIterator.cc:463](http://wholestageresultiterator.cc:463/)
cpp/velox/shuffle/VeloxSortShuffleWriter.cc:219
cpp/velox/tests/FunctionTest.cc:157
cpp/velox/shuffle/VeloxShuffleReader.cc:437
cpp/velox/shuffle/VeloxSortShuffleWriter.cc:347
cpp/velox/substrait/SubstraitToVeloxPlan.cc:1049
cpp/velox/substrait/SubstraitToVeloxPlan.cc:1040
cpp/velox/substrait/SubstraitToVeloxPlan.cc:1102
cpp/velox/substrait/SubstraitToVeloxPlan.cc:1095
cpp/velox/tests/VeloxSubstraitRoundTripTest.cc:370 -> and below test would fail at BaseVector.cpp comparing the VELOX_CHECK_EQ(type->kind(), value.kind()); if it is not casted correctly so leaving as is
cpp/velox/tests/VeloxSubstraitRoundTripTest.cc:371
cpp/velox/tests/VeloxSubstraitRoundTripTest.cc:372
cpp/velox/tests/VeloxSubstraitRoundTripTest.cc:374
cpp/velox/tests/VeloxSubstraitRoundTripTest.cc:375
(Please fill in changes proposed in this fix)
(Fixes: #8475)