Skip to content

Commit

Permalink
apacheGH-40882: [C++] Suppress shorten-64-to-32 warnings in CUDA/Skyh…
Browse files Browse the repository at this point in the history
…ook codes (apache#40883)

### Rationale for this change

```text
cpp/src/arrow/gpu/cuda_memory.cc:497:72: error: implicit conversion loses integer precision: 'int64_t' (aka 'long') to 'int' [-Werror,-Wshorten-64-to-32]
      ARROW_ASSIGN_OR_RAISE(auto device, arrow::cuda::CudaDevice::Make(device_id));
                                         ~~~~~                         ^~~~~~~~~
```

```text
cpp/src/arrow/gpu/cuda_memory.cc:508:68: error: implicit conversion loses integer precision: 'int64_t' (aka 'long') to 'int' [-Werror,-Wshorten-64-to-32]
  ARROW_ASSIGN_OR_RAISE(auto device, arrow::cuda::CudaDevice::Make(device_id));
                                     ~~~~~                         ^~~~~~~~~
```

```text
cpp/src/skyhook/protocol/skyhook_protocol.cc:109:69: error: implicit conversion loses integer precision: 'int64_t' (aka 'long') to 'unsigned int' [-Werror,-Wshorten-64-to-32]
  bl->append(reinterpret_cast<const char*>(buffer->data()), buffer->size());
      ~~~~~~                                                ~~~~~~~~^~~~~~
```

```text
cpp/src/skyhook/cls/cls_skyhook.cc:87:37: error: implicit conversion loses integer precision: 'int64_t' (aka 'long') to 'int' [-Werror,-Wshorten-64-to-32]
      cls_cxx_read(hctx_, position, nbytes, bl.get());
      ~~~~~~~~~~~~                  ^~~~~~
cpp/src/skyhook/cls/cls_skyhook.cc:87:27: error: implicit conversion loses integer precision: 'int64_t' (aka 'long') to 'int' [-Werror,-Wshorten-64-to-32]
      cls_cxx_read(hctx_, position, nbytes, bl.get());
      ~~~~~~~~~~~~        ^~~~~~~~
```

```text
cpp/src/skyhook/protocol/skyhook_protocol.cc:109:69: error: implicit conversion loses integer precision: 'int64_t' (aka 'long') to 'unsigned int' [-Werror,-Wshorten-64-to-32]
  bl->append(reinterpret_cast<const char*>(buffer->data()), buffer->size());
      ~~~~~~
```

### What changes are included in this PR?

Add casts explicitly.

### Are these changes tested?

Yes.

### Are there any user-facing changes?

No.
* GitHub Issue: apache#40882

Authored-by: Sutou Kouhei <kou@clear-code.com>
Signed-off-by: Sutou Kouhei <kou@clear-code.com>
  • Loading branch information
kou authored and vibhatha committed May 25, 2024
1 parent bf66b19 commit d141ade
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
6 changes: 4 additions & 2 deletions cpp/src/arrow/gpu/cuda_memory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,8 @@ Result<std::shared_ptr<MemoryManager>> DefaultMemoryMapper(ArrowDeviceType devic
case ARROW_DEVICE_CUDA:
case ARROW_DEVICE_CUDA_HOST:
case ARROW_DEVICE_CUDA_MANAGED: {
ARROW_ASSIGN_OR_RAISE(auto device, arrow::cuda::CudaDevice::Make(device_id));
ARROW_ASSIGN_OR_RAISE(auto device,
arrow::cuda::CudaDevice::Make(static_cast<int>(device_id)));
return device->default_memory_manager();
}
default:
Expand All @@ -505,7 +506,8 @@ Result<std::shared_ptr<MemoryManager>> DefaultMemoryMapper(ArrowDeviceType devic
namespace {

Result<std::shared_ptr<MemoryManager>> DefaultCUDADeviceMapper(int64_t device_id) {
ARROW_ASSIGN_OR_RAISE(auto device, arrow::cuda::CudaDevice::Make(device_id));
ARROW_ASSIGN_OR_RAISE(auto device,
arrow::cuda::CudaDevice::Make(static_cast<int>(device_id)));
return device->default_memory_manager();
}

Expand Down
2 changes: 1 addition & 1 deletion cpp/src/skyhook/cls/cls_skyhook.cc
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class RandomAccessObject : public arrow::io::RandomAccessFile {

if (nbytes > 0) {
std::shared_ptr<ceph::bufferlist> bl = std::make_shared<ceph::bufferlist>();
cls_cxx_read(hctx_, position, nbytes, bl.get());
cls_cxx_read(hctx_, static_cast<int>(position), static_cast<int>(nbytes), bl.get());
chunks_.push_back(bl);
return std::make_shared<arrow::Buffer>((uint8_t*)bl->c_str(), bl->length());
}
Expand Down
3 changes: 2 additions & 1 deletion cpp/src/skyhook/protocol/skyhook_protocol.cc
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ arrow::Status SerializeTable(const std::shared_ptr<arrow::Table>& table,
ARROW_RETURN_NOT_OK(writer->Close());

ARROW_ASSIGN_OR_RAISE(auto buffer, buffer_output_stream->Finish());
bl->append(reinterpret_cast<const char*>(buffer->data()), buffer->size());
bl->append(reinterpret_cast<const char*>(buffer->data()),
static_cast<unsigned int>(buffer->size()));
return arrow::Status::OK();
}

Expand Down

0 comments on commit d141ade

Please sign in to comment.