aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBin Chen <pierr.chen@gmail.com>2016-08-24 14:36:58 +1000
committerBin Chen <pierr.chen@gmail.com>2016-08-28 20:31:43 +1000
commitfe2167b737928cda28d3e83791beb1dcc2324bc7 (patch)
treeb01a673f8d0232b62bc4022a51c9e88f87080c32
parent4cfe4e853b4c1c296e0a2fb2d7e6a6777ed03559 (diff)
downloadperipheralmanager-fe2167b737928cda28d3e83791beb1dcc2324bc7.tar.gz
Use c++ style castHEADmastermain
Change-Id: I6394978e2cbc1a6efa9912a876f652d3d455d98b Signed-off-by: Bin Chen <pierr.chen@gmail.com>
-rw-r--r--client/wrapper.cc5
-rw-r--r--daemon/i2c_driver_i2cdev.cc2
-rw-r--r--example/pio_mcp9808.cc2
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<std::string>& strings) {
- char** c_strings = (char**)malloc(strings.size() * sizeof(*c_strings));
+ char** c_strings =
+ static_cast<char**>(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<char*>(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<void*>(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<float>(val & 0xF) / 16;
printf("Temp: %f\n", temp);
BI2cDevice_delete(i2c_device);