From fe2167b737928cda28d3e83791beb1dcc2324bc7 Mon Sep 17 00:00:00 2001 From: Bin Chen Date: Wed, 24 Aug 2016 14:36:58 +1000 Subject: Use c++ style cast Change-Id: I6394978e2cbc1a6efa9912a876f652d3d455d98b Signed-off-by: Bin Chen --- client/wrapper.cc | 5 +++-- daemon/i2c_driver_i2cdev.cc | 2 +- example/pio_mcp9808.cc | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/client/wrapper.cc b/client/wrapper.cc index f9cc3dc..cf396ca 100644 --- a/client/wrapper.cc +++ b/client/wrapper.cc @@ -28,9 +28,10 @@ namespace { // This is horrible. Get rid of it!!! static char** ConvertStringVectorToC(const std::vector& strings) { - char** c_strings = (char**)malloc(strings.size() * sizeof(*c_strings)); + char** c_strings = + static_cast(malloc(strings.size() * sizeof(*c_strings))); for (size_t i = 0; i < strings.size(); i++) { - c_strings[i] = (char*)malloc(strings[i].size() + 1); + c_strings[i] = static_cast(malloc(strings[i].size() + 1)); memset(c_strings[i], 0, strings[i].size() + 1); strcpy(c_strings[i], strings[i].c_str()); } diff --git a/daemon/i2c_driver_i2cdev.cc b/daemon/i2c_driver_i2cdev.cc index b4f2280..acc02ac 100644 --- a/daemon/i2c_driver_i2cdev.cc +++ b/daemon/i2c_driver_i2cdev.cc @@ -59,7 +59,7 @@ bool I2cDriverI2cDev::Init(uint32_t bus_id, uint32_t address) { if (fd < 0) return false; uintptr_t tmp_addr = address; - if (char_interface_->Ioctl(fd, I2C_SLAVE, (void*)tmp_addr) < 0) { + if (char_interface_->Ioctl(fd, I2C_SLAVE, reinterpret_cast(tmp_addr)) < 0) { LOG(ERROR) << "Failed to set I2C slave"; char_interface_->Close(fd); return false; diff --git a/example/pio_mcp9808.cc b/example/pio_mcp9808.cc index 446afbf..cad8990 100644 --- a/example/pio_mcp9808.cc +++ b/example/pio_mcp9808.cc @@ -50,7 +50,7 @@ int main(int argc, char* argv[]) { val = ntohs(val); float temp = (val >> 4) & 0xFF; - temp += (float)(val & 0xF) / 16; + temp += static_cast(val & 0xF) / 16; printf("Temp: %f\n", temp); BI2cDevice_delete(i2c_device); -- cgit v1.2.3