提交 0459bf32 编写于 作者: L Liangliang Zhang 提交者: Jiangtao Hu

Driver: cleared all warnings. Enabled strict check for Wconversion.

上级 44a7714f
......@@ -19,8 +19,8 @@
#include <memory>
#include <thread>
#include "gflags/gflags.h"
#include "cyber/common/log.h"
#include "gflags/gflags.h"
#include "modules/common/proto/error_code.pb.h"
#include "modules/common/time/time.h"
#include "modules/common/util/factory.h"
......@@ -134,8 +134,8 @@ class CanAgent {
send_id = id;
frames[i].id = id;
frames[i].len = 8;
frames[i].data[7] = count % 256;
for (int32_t j = 0; j < 7; ++j) {
frames[i].data[7] = static_cast<uint8_t>(count % 256);
for (uint8_t j = 0; j < 7; ++j) {
frames[i].data[j] = j;
}
++count;
......@@ -159,7 +159,7 @@ class CanAgent {
}
}
int64_t end = AsInt64<micros>(Clock::Now());
param->send_time = end - start;
param->send_time = static_cast<int32_t>(end - start);
// In case for finish too quick to receiver miss some msg
sleep(2);
AINFO << "Send thread stopping..." << param->conf.ShortDebugString();
......@@ -215,7 +215,7 @@ class CanAgent {
}
}
int64_t end = AsInt64<micros>(Clock::Now());
param->recv_time = end - start;
param->recv_time = static_cast<int32_t>(end - start);
AINFO << "Recv thread stopping..., conf:" << param->conf.ShortDebugString();
return;
}
......
......@@ -277,7 +277,7 @@ std::string EsdCanClient::GetErrorString(const NTCAN_RESULT ntstatus) {
char sz_error_text[60];
res = canFormatError(ntstatus, NTCAN_ERROR_FORMAT_LONG, sz_error_text,
sizeof(sz_error_text) - 1);
static_cast<uint32_t>(sizeof(sz_error_text) - 1));
if (NTCAN_SUCCESS == res) {
snprintf(reinterpret_cast<char *>(str_buf), ERROR_BUF_SIZE, "%s - %s",
es->str, sz_error_text);
......
......@@ -78,7 +78,7 @@ TEST_F(FakeCanClientTest, SendMessage) {
frames[i].id = 1 & 0x3FF;
frames[i].len = 8;
frames[i].data[7] = 1 % 256;
for (int32_t j = 0; j < 7; ++j) {
for (uint8_t j = 0; j < 7; ++j) {
frames[i].data[j] = j;
}
}
......
......@@ -121,7 +121,7 @@ T ProtocolData<SensorType>::BoundedValue(T lower, T upper, T val) {
template <typename SensorType>
uint8_t ProtocolData<SensorType>::CalculateCheckSum(const uint8_t *input,
const uint32_t length) {
return std::accumulate(input, input + length, 0) ^ 0xFF;
return static_cast<uint8_t>(std::accumulate(input, input + length, 0) ^ 0xFF);
}
template <typename SensorType>
......
......@@ -70,8 +70,7 @@ build --copt="-Werror=unused-but-set-variable"
build --copt="-Werror=switch"
# Strict check on type conversion.
# TODO(all): Clear drivers module and remove it from exception.
build --per_file_copt=^modules/.*\.cc,-^modules/drivers/.*\.cc@-Werror=conversion
build --per_file_copt=^modules/.*\.cc@-Werror=conversion
# TODO(all): Clear cyber warnings and add it to the strict check.
build --per_file_copt=^cyber/.*\.cc@-Wconversion
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册