Don't call function in assert (#19997)

old-commit-hash: 91504176e4
commatwo_master
Dean Lee 4 years ago committed by GitHub
parent fac6d44e8b
commit 04adbaf8e1
  1. 3
      installer/installer.c
  2. 22
      selfdrive/boardd/pigeon.cc
  3. 24
      selfdrive/logcatd/logcatd_systemd.cc
  4. 6
      selfdrive/modeld/runners/onnxmodel.cc
  5. 6
      selfdrive/modeld/runners/snpemodel.cc
  6. 3
      selfdrive/modeld/test/snpe_benchmark/benchmark.cc

@ -156,7 +156,8 @@ void * run_spinner(void * args) {
int main() { int main() {
pthread_t spinner_thread; pthread_t spinner_thread;
assert(pthread_create(&spinner_thread, NULL, run_spinner, NULL) == 0); int err = pthread_create(&spinner_thread, NULL, run_spinner, NULL);
assert(err == 0);
int status = do_install(); int status = do_install();

@ -132,8 +132,10 @@ void TTYPigeon::connect(const char * tty) {
if (pigeon_tty_fd < 0){ if (pigeon_tty_fd < 0){
handle_tty_issue(errno, __func__); handle_tty_issue(errno, __func__);
assert(pigeon_tty_fd >= 0); assert(pigeon_tty_fd >= 0);
} }
assert(tcgetattr(pigeon_tty_fd, &pigeon_tty) == 0); int err = tcgetattr(pigeon_tty_fd, &pigeon_tty);
assert(err == 0);
// configure tty // configure tty
pigeon_tty.c_cflag &= ~PARENB; // disable parity pigeon_tty.c_cflag &= ~PARENB; // disable parity
@ -152,7 +154,8 @@ void TTYPigeon::connect(const char * tty) {
pigeon_tty.c_cc[VMIN] = 0; // min amount of characters returned pigeon_tty.c_cc[VMIN] = 0; // min amount of characters returned
pigeon_tty.c_cc[VTIME] = 0; // max blocking time in s/10 (0=inf) pigeon_tty.c_cc[VTIME] = 0; // max blocking time in s/10 (0=inf)
assert(tcsetattr(pigeon_tty_fd, TCSANOW, &pigeon_tty) == 0); err = tcsetattr(pigeon_tty_fd, TCSANOW, &pigeon_tty);
assert(err == 0);
} }
void TTYPigeon::set_baud(int baud){ void TTYPigeon::set_baud(int baud){
@ -169,15 +172,20 @@ void TTYPigeon::set_baud(int baud){
} }
// make sure everything is tx'ed before changing baud // make sure everything is tx'ed before changing baud
assert(tcdrain(pigeon_tty_fd) == 0); int err = tcdrain(pigeon_tty_fd);
assert(err == 0);
// change baud // change baud
assert(tcgetattr(pigeon_tty_fd, &pigeon_tty) == 0); err = tcgetattr(pigeon_tty_fd, &pigeon_tty);
assert(cfsetspeed(&pigeon_tty, baud_const) == 0); assert(err == 0);
assert(tcsetattr(pigeon_tty_fd, TCSANOW, &pigeon_tty) == 0); err = cfsetspeed(&pigeon_tty, baud_const);
assert(err == 0);
err = tcsetattr(pigeon_tty_fd, TCSANOW, &pigeon_tty);
assert(err == 0);
// flush // flush
assert(tcflush(pigeon_tty_fd, TCIOFLUSH) == 0); err = tcflush(pigeon_tty_fd, TCIOFLUSH);
assert(err == 0);
} }
void TTYPigeon::send(const std::string &s) { void TTYPigeon::send(const std::string &s) {

@ -17,25 +17,27 @@ int main(int argc, char *argv[]) {
PubMaster pm({"androidLog"}); PubMaster pm({"androidLog"});
sd_journal *journal; sd_journal *journal;
assert(sd_journal_open(&journal, 0) >= 0); int err = sd_journal_open(&journal, 0);
assert(sd_journal_get_fd(journal) >= 0); // needed so sd_journal_wait() works properly if files rotate assert(err >= 0);
assert(sd_journal_seek_tail(journal) >= 0); err = sd_journal_get_fd(journal); // needed so sd_journal_wait() works properly if files rotate
assert(err >= 0);
err = sd_journal_seek_tail(journal);
assert(err >= 0);
int r;
while (!do_exit) { while (!do_exit) {
r = sd_journal_next(journal); err = sd_journal_next(journal);
assert(r >= 0); assert(err >= 0);
// Wait for new message if we didn't receive anything // Wait for new message if we didn't receive anything
if (r == 0){ if (err == 0){
r = sd_journal_wait(journal, 1000 * 1000); err = sd_journal_wait(journal, 1000 * 1000);
assert (r >= 0); assert (err >= 0);
continue; // Try again continue; // Try again
} }
uint64_t timestamp = 0; uint64_t timestamp = 0;
r = sd_journal_get_realtime_usec(journal, &timestamp); err = sd_journal_get_realtime_usec(journal, &timestamp);
assert(r >= 0); assert(err >= 0);
const void *data; const void *data;
size_t length; size_t length;

@ -22,8 +22,10 @@ ONNXModel::ONNXModel(const char *path, float *_output, size_t _output_size, int
strcat(tmp, ".onnx"); strcat(tmp, ".onnx");
LOGD("loading model %s", tmp); LOGD("loading model %s", tmp);
assert(pipe(pipein) == 0); int err = pipe(pipein);
assert(pipe(pipeout) == 0); assert(err == 0);
err = pipe(pipeout);
assert(err == 0);
std::string exe_dir = util::dir_name(util::readlink("/proc/self/exe")); std::string exe_dir = util::dir_name(util::readlink("/proc/self/exe"));
std::string onnx_runner = exe_dir + "/runners/onnx_runner.py"; std::string onnx_runner = exe_dir + "/runners/onnx_runner.py";

@ -140,7 +140,8 @@ void SNPEModel::execute(float *net_input_buf, int buf_size) {
if (Runtime == zdl::DlSystem::Runtime_t::GPU) { if (Runtime == zdl::DlSystem::Runtime_t::GPU) {
float *inputs[4] = {recurrent, trafficConvention, desire, net_input_buf}; float *inputs[4] = {recurrent, trafficConvention, desire, net_input_buf};
if (thneed == NULL) { if (thneed == NULL) {
assert(inputBuffer->setBufferAddress(net_input_buf)); bool ret = inputBuffer->setBufferAddress(net_input_buf);
assert(ret == true);
if (!snpe->execute(inputMap, outputMap)) { if (!snpe->execute(inputMap, outputMap)) {
PrintErrorStringAndExit(); PrintErrorStringAndExit();
} }
@ -173,7 +174,8 @@ void SNPEModel::execute(float *net_input_buf, int buf_size) {
} }
} else { } else {
#endif #endif
assert(inputBuffer->setBufferAddress(net_input_buf)); bool ret = inputBuffer->setBufferAddress(net_input_buf);
assert(ret == true);
if (!snpe->execute(inputMap, outputMap)) { if (!snpe->execute(inputMap, outputMap)) {
PrintErrorStringAndExit(); PrintErrorStringAndExit();
} }

@ -85,7 +85,8 @@ void test(char *filename) {
cout << "**** starting benchmark ****" << endl; cout << "**** starting benchmark ****" << endl;
for (int i = 0; i < 50; i++) { for (int i = 0; i < 50; i++) {
clock_gettime(CLOCK_MONOTONIC, &start); clock_gettime(CLOCK_MONOTONIC, &start);
assert(snpe->execute(inputTensorMap, outputTensorMap)); int err = snpe->execute(inputTensorMap, outputTensorMap);
assert(err == true);
clock_gettime(CLOCK_MONOTONIC, &end); clock_gettime(CLOCK_MONOTONIC, &end);
uint64_t timeElapsed = timespecDiff(&end, &start); uint64_t timeElapsed = timespecDiff(&end, &start);
printf("time: %f ms\n", timeElapsed*1.0/1e6); printf("time: %f ms\n", timeElapsed*1.0/1e6);

Loading…
Cancel
Save