diff --git a/SConstruct b/SConstruct index 94369e4a2..5a111b561 100644 --- a/SConstruct +++ b/SConstruct @@ -181,6 +181,7 @@ env = Environment( "-O2", "-Wunused", "-Werror", + "-Wshadow", "-Wno-unknown-warning-option", "-Wno-deprecated-register", "-Wno-register", @@ -267,7 +268,7 @@ def abspath(x): py_include = sysconfig.get_paths()['include'] envCython = env.Clone() envCython["CPPPATH"] += [py_include, np.get_include()] -envCython["CCFLAGS"] += ["-Wno-#warnings", "-Wno-deprecated-declarations"] +envCython["CCFLAGS"] += ["-Wno-#warnings", "-Wno-shadow", "-Wno-deprecated-declarations"] envCython["LIBS"] = [] if arch == "Darwin": diff --git a/selfdrive/boardd/pigeon.cc b/selfdrive/boardd/pigeon.cc index c917c1ae8..b8735cc3b 100644 --- a/selfdrive/boardd/pigeon.cc +++ b/selfdrive/boardd/pigeon.cc @@ -41,16 +41,16 @@ Pigeon * Pigeon::connect(const char * tty) { return pigeon; } -bool Pigeon::wait_for_ack(const std::string &ack, const std::string &nack, int timeout_ms) { +bool Pigeon::wait_for_ack(const std::string &ack_, const std::string &nack_, int timeout_ms) { std::string s; const double start_t = millis_since_boot(); while (!do_exit) { s += receive(); - if (s.find(ack) != std::string::npos) { + if (s.find(ack_) != std::string::npos) { LOGD("Received ACK from ublox"); return true; - } else if (s.find(nack) != std::string::npos) { + } else if (s.find(nack_) != std::string::npos) { LOGE("Received NACK from ublox"); return false; } else if (s.size() > 0x1000 || ((millis_since_boot() - start_t) > timeout_ms)) { diff --git a/selfdrive/camerad/cameras/camera_common.cc b/selfdrive/camerad/cameras/camera_common.cc index c1d7002b2..4db6eaa12 100644 --- a/selfdrive/camerad/cameras/camera_common.cc +++ b/selfdrive/camerad/cameras/camera_common.cc @@ -75,11 +75,11 @@ private: cl_kernel krnl_; }; -void CameraBuf::init(cl_device_id device_id, cl_context context, CameraState *s, VisionIpcServer * v, int frame_cnt, VisionStreamType rgb_type, VisionStreamType yuv_type, release_cb release_callback) { +void CameraBuf::init(cl_device_id device_id, cl_context context, CameraState *s, VisionIpcServer * v, int frame_cnt, VisionStreamType init_rgb_type, VisionStreamType init_yuv_type, release_cb init_release_callback) { vipc_server = v; - this->rgb_type = rgb_type; - this->yuv_type = yuv_type; - this->release_callback = release_callback; + this->rgb_type = init_rgb_type; + this->yuv_type = init_yuv_type; + this->release_callback = init_release_callback; const CameraInfo *ci = &s->ci; camera_state = s; diff --git a/selfdrive/locationd/locationd.cc b/selfdrive/locationd/locationd.cc index 8844b37f5..5fdd34ecf 100755 --- a/selfdrive/locationd/locationd.cc +++ b/selfdrive/locationd/locationd.cc @@ -344,12 +344,12 @@ void Localizer::handle_cam_odo(double current_time, const cereal::CameraOdometry void Localizer::handle_live_calib(double current_time, const cereal::LiveCalibrationData::Reader& log) { if (log.getRpyCalib().size() > 0) { - auto calib = floatlist2vector(log.getRpyCalib()); - if ((calib.minCoeff() < -CALIB_RPY_SANITY_CHECK) || (calib.maxCoeff() > CALIB_RPY_SANITY_CHECK)) { + auto live_calib = floatlist2vector(log.getRpyCalib()); + if ((live_calib.minCoeff() < -CALIB_RPY_SANITY_CHECK) || (live_calib.maxCoeff() > CALIB_RPY_SANITY_CHECK)) { return; } - this->calib = calib; + this->calib = live_calib; this->device_from_calib = euler2rot(this->calib); this->calib_from_device = this->device_from_calib.transpose(); this->calibrated = log.getCalStatus() == 1; diff --git a/selfdrive/locationd/ublox_msg.cc b/selfdrive/locationd/ublox_msg.cc index cda433345..52c3906f1 100644 --- a/selfdrive/locationd/ublox_msg.cc +++ b/selfdrive/locationd/ublox_msg.cc @@ -172,12 +172,14 @@ kj::Array UbloxMsgParser::gen_rxm_sfrbx(ubx_t::rxm_sfrbx_t *msg) { } // Collect subframes in map and parse when we have all the parts - kaitai::kstream stream(subframe_data); - gps_t subframe(&stream); - int subframe_id = subframe.how()->subframe_id(); + { + kaitai::kstream stream(subframe_data); + gps_t subframe(&stream); + int subframe_id = subframe.how()->subframe_id(); - if (subframe_id == 1) gps_subframes[msg->sv_id()].clear(); - gps_subframes[msg->sv_id()][subframe_id] = subframe_data; + if (subframe_id == 1) gps_subframes[msg->sv_id()].clear(); + gps_subframes[msg->sv_id()][subframe_id] = subframe_data; + } if (gps_subframes[msg->sv_id()].size() == 5) { MessageBuilder msg_builder; diff --git a/selfdrive/locationd/ubloxd.cc b/selfdrive/locationd/ubloxd.cc index 3a6c5f1a8..bcf33b3f7 100644 --- a/selfdrive/locationd/ubloxd.cc +++ b/selfdrive/locationd/ubloxd.cc @@ -45,10 +45,10 @@ int main() { if(parser.add_data(data + bytes_consumed, (uint32_t)(len - bytes_consumed), bytes_consumed_this_time)) { try { - auto msg = parser.gen_msg(); - if (msg.second.size() > 0) { - auto bytes = msg.second.asBytes(); - pm.send(msg.first.c_str(), bytes.begin(), bytes.size()); + auto ublox_msg = parser.gen_msg(); + if (ublox_msg.second.size() > 0) { + auto bytes = ublox_msg.second.asBytes(); + pm.send(ublox_msg.first.c_str(), bytes.begin(), bytes.size()); } } catch (const std::exception& e) { LOGE("Error parsing ublox message %s", e.what()); diff --git a/selfdrive/loggerd/loggerd.cc b/selfdrive/loggerd/loggerd.cc index 5dea6e575..71df85396 100644 --- a/selfdrive/loggerd/loggerd.cc +++ b/selfdrive/loggerd/loggerd.cc @@ -126,21 +126,21 @@ struct LoggerdState { LoggerdState s; // Wait for all encoders to reach the same frame id -bool sync_encoders(LoggerdState *s, CameraType cam_type, uint32_t frame_id) { - if (s->camera_synced[cam_type]) return true; +bool sync_encoders(LoggerdState *state, CameraType cam_type, uint32_t frame_id) { + if (state->camera_synced[cam_type]) return true; - if (s->max_waiting > 1 && s->encoders_ready != s->max_waiting) { - update_max_atomic(s->latest_frame_id, frame_id); - if (std::exchange(s->camera_ready[cam_type], true) == false) { - ++s->encoders_ready; + if (state->max_waiting > 1 && state->encoders_ready != state->max_waiting) { + update_max_atomic(state->latest_frame_id, frame_id); + if (std::exchange(state->camera_ready[cam_type], true) == false) { + ++state->encoders_ready; LOGE("camera %d encoder ready", cam_type); } return false; } else { // Small margin in case one of the encoders already dropped the next frame - uint32_t start_frame_id = s->latest_frame_id + 2; + uint32_t start_frame_id = state->latest_frame_id + 2; bool synced = frame_id >= start_frame_id; - s->camera_synced[cam_type] = synced; + state->camera_synced[cam_type] = synced; if (!synced) LOGE("camera %d waiting for frame %d, cur %d", cam_type, start_frame_id, frame_id); return synced; } diff --git a/selfdrive/loggerd/tests/test_logger.cc b/selfdrive/loggerd/tests/test_logger.cc index baef312ad..21b1d711d 100644 --- a/selfdrive/loggerd/tests/test_logger.cc +++ b/selfdrive/loggerd/tests/test_logger.cc @@ -66,7 +66,7 @@ void write_msg(LoggerHandle *logger) { TEST_CASE("logger") { const std::string log_root = "/tmp/test_logger"; system(("rm " + log_root + " -rf").c_str()); - + ExitHandler do_exit; LoggerState logger = {}; @@ -121,11 +121,11 @@ TEST_CASE("logger") { REQUIRE(segment == i); main_segment = segment; if (i == 0) { - for (int i = 0; i < thread_cnt; ++i) { + for (int j = 0; j < thread_cnt; ++j) { threads.push_back(std::thread(logging_thread)); } } - for (int i = 0; i < 100; ++i) { + for (int j = 0; j < 100; ++j) { write_msg(logger.cur_handle); usleep(1); } diff --git a/selfdrive/modeld/models/commonmodel.cc b/selfdrive/modeld/models/commonmodel.cc index 457519994..1a1f6eaea 100644 --- a/selfdrive/modeld/models/commonmodel.cc +++ b/selfdrive/modeld/models/commonmodel.cc @@ -22,10 +22,10 @@ ModelFrame::ModelFrame(cl_device_id device_id, cl_context context) { loadyuv_init(&loadyuv, context, device_id, MODEL_WIDTH, MODEL_HEIGHT); } -float* ModelFrame::prepare(cl_mem yuv_cl, int frame_width, int frame_height, const mat3 &transform, cl_mem *output) { +float* ModelFrame::prepare(cl_mem yuv_cl, int frame_width, int frame_height, const mat3 &projection, cl_mem *output) { transform_queue(&this->transform, q, yuv_cl, frame_width, frame_height, - y_cl, u_cl, v_cl, MODEL_WIDTH, MODEL_HEIGHT, transform); + y_cl, u_cl, v_cl, MODEL_WIDTH, MODEL_HEIGHT, projection); if (output == NULL) { loadyuv_queue(&loadyuv, q, y_cl, u_cl, v_cl, net_input_cl); diff --git a/selfdrive/proclogd/proclog.cc b/selfdrive/proclogd/proclog.cc index adc828cb5..26fc1d94d 100644 --- a/selfdrive/proclogd/proclog.cc +++ b/selfdrive/proclogd/proclog.cc @@ -225,8 +225,8 @@ void buildProcs(cereal::ProcLog::Builder &builder) { const ProcCache &extra_info = Parser::getProcExtraInfo(r.pid, r.name); l.setExe(extra_info.exe); auto lcmdline = l.initCmdline(extra_info.cmdline.size()); - for (size_t i = 0; i < lcmdline.size(); i++) { - lcmdline.set(i, extra_info.cmdline[i]); + for (size_t j = 0; j < lcmdline.size(); j++) { + lcmdline.set(j, extra_info.cmdline[j]); } } } diff --git a/selfdrive/ui/qt/maps/map.cc b/selfdrive/ui/qt/maps/map.cc index 957c58f0a..3468f25e9 100644 --- a/selfdrive/ui/qt/maps/map.cc +++ b/selfdrive/ui/qt/maps/map.cc @@ -576,9 +576,9 @@ void MapInstructions::updateDistance(float d) { distance->setText(distance_str); } -void MapInstructions::showError(QString error) { +void MapInstructions::showError(QString error_text) { primary->setText(""); - distance->setText(error); + distance->setText(error_text); distance->setAlignment(Qt::AlignCenter); secondary->setVisible(false); diff --git a/selfdrive/ui/qt/maps/map_settings.cc b/selfdrive/ui/qt/maps/map_settings.cc index 9df155d62..60a781226 100644 --- a/selfdrive/ui/qt/maps/map_settings.cc +++ b/selfdrive/ui/qt/maps/map_settings.cc @@ -138,7 +138,6 @@ MapPanel::MapPanel(QWidget* parent) : QWidget(parent) { HttpRequest* deleter = new HttpRequest(this); QObject::connect(repeater, &RequestRepeater::receivedResponse, [=](QString resp) { - auto params = Params(); if (resp != "null") { if (params.get("NavDestination").empty()) { qWarning() << "Setting NavDestination from /next" << resp; diff --git a/selfdrive/ui/qt/offroad/networking.cc b/selfdrive/ui/qt/offroad/networking.cc index 05ca31225..dd519dd66 100644 --- a/selfdrive/ui/qt/offroad/networking.cc +++ b/selfdrive/ui/qt/offroad/networking.cc @@ -23,7 +23,7 @@ Networking::Networking(QWidget* parent, bool show_advanced) : QFrame(parent) { connect(wifi, &WifiManager::refreshSignal, this, &Networking::refresh); connect(wifi, &WifiManager::wrongPassword, this, &Networking::wrongPassword); - QWidget* wifiScreen = new QWidget(this); + wifiScreen = new QWidget(this); QVBoxLayout* vlayout = new QVBoxLayout(wifiScreen); vlayout->setContentsMargins(20, 20, 20, 20); if (show_advanced) { diff --git a/selfdrive/ui/qt/offroad/wifiManager.cc b/selfdrive/ui/qt/offroad/wifiManager.cc index 957d65e26..e798949a8 100644 --- a/selfdrive/ui/qt/offroad/wifiManager.cc +++ b/selfdrive/ui/qt/offroad/wifiManager.cc @@ -416,19 +416,19 @@ void WifiManager::activateModemConnection(const QDBusObjectPath &path) { NetworkType WifiManager::currentNetworkType() { QDBusInterface nm(NM_DBUS_SERVICE, NM_DBUS_PATH, NM_DBUS_INTERFACE_PROPERTIES, bus); nm.setTimeout(DBUS_TIMEOUT); - const QDBusObjectPath &path = get_response(nm.call("Get", NM_DBUS_INTERFACE, "PrimaryConnection")); + const QDBusObjectPath &primary_conn = get_response(nm.call("Get", NM_DBUS_INTERFACE, "PrimaryConnection")); - QDBusInterface nm2(NM_DBUS_SERVICE, path.path(), NM_DBUS_INTERFACE_PROPERTIES, bus); + QDBusInterface nm2(NM_DBUS_SERVICE, primary_conn.path(), NM_DBUS_INTERFACE_PROPERTIES, bus); nm.setTimeout(DBUS_TIMEOUT); - const QString &type = get_response(nm2.call("Get", NM_DBUS_INTERFACE_ACTIVE_CONNECTION, "Type")); + const QString &primary_type = get_response(nm2.call("Get", NM_DBUS_INTERFACE_ACTIVE_CONNECTION, "Type")); - if (type == "802-3-ethernet") { + if (primary_type == "802-3-ethernet") { return NetworkType::ETHERNET; - } else if (type == "802-11-wireless" && !isTetheringEnabled()) { + } else if (primary_type == "802-11-wireless" && !isTetheringEnabled()) { return NetworkType::WIFI; } else { - for (const QDBusObjectPath &path : get_active_connections()) { - QDBusInterface nm3(NM_DBUS_SERVICE, path.path(), NM_DBUS_INTERFACE_PROPERTIES, bus); + for (const QDBusObjectPath &conn : get_active_connections()) { + QDBusInterface nm3(NM_DBUS_SERVICE, conn.path(), NM_DBUS_INTERFACE_PROPERTIES, bus); nm3.setTimeout(DBUS_TIMEOUT); const QString &type = get_response(nm3.call("Get", NM_DBUS_INTERFACE_ACTIVE_CONNECTION, "Type")); if (type == "gsm") { diff --git a/selfdrive/ui/qt/setup/setup.cc b/selfdrive/ui/qt/setup/setup.cc index 7c464639c..a85581368 100644 --- a/selfdrive/ui/qt/setup/setup.cc +++ b/selfdrive/ui/qt/setup/setup.cc @@ -2,6 +2,7 @@ #include #include +#include #include #include diff --git a/selfdrive/ui/qt/widgets/cameraview.cc b/selfdrive/ui/qt/widgets/cameraview.cc index f9fa56207..3d7c37559 100644 --- a/selfdrive/ui/qt/widgets/cameraview.cc +++ b/selfdrive/ui/qt/widgets/cameraview.cc @@ -201,9 +201,9 @@ void CameraViewWidget::updateFrameMat(int w, int h) { } } else if (vipc_client->connected) { // fit frame to widget size - float w = (float)width() / height(); - float f = (float)vipc_client->buffers[0].width / vipc_client->buffers[0].height; - frame_mat = matmul(device_transform, get_fit_view_transform(w, f)); + float widget_aspect_ratio = (float)width() / height(); + float frame_aspect_ratio = (float)vipc_client->buffers[0].width / vipc_client->buffers[0].height; + frame_mat = matmul(device_transform, get_fit_view_transform(widget_aspect_ratio, frame_aspect_ratio)); } } diff --git a/selfdrive/ui/qt/widgets/controls.cc b/selfdrive/ui/qt/widgets/controls.cc index d103db40d..8b09ba2bb 100644 --- a/selfdrive/ui/qt/widgets/controls.cc +++ b/selfdrive/ui/qt/widgets/controls.cc @@ -30,10 +30,10 @@ AbstractControl::AbstractControl(const QString &title, const QString &desc, cons // left icon if (!icon.isEmpty()) { QPixmap pix(icon); - QLabel *icon = new QLabel(); - icon->setPixmap(pix.scaledToWidth(80, Qt::SmoothTransformation)); - icon->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); - hlayout->addWidget(icon); + QLabel *icon_label = new QLabel(); + icon_label->setPixmap(pix.scaledToWidth(80, Qt::SmoothTransformation)); + icon_label->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); + hlayout->addWidget(icon_label); } // title diff --git a/selfdrive/ui/replay/framereader.cc b/selfdrive/ui/replay/framereader.cc index 3587ec1d2..12dda678f 100644 --- a/selfdrive/ui/replay/framereader.cc +++ b/selfdrive/ui/replay/framereader.cc @@ -113,7 +113,7 @@ bool FrameReader::load(const std::string &url, std::atomic *abort) { frames_.reserve(60 * 20); // 20fps, one minute while (!(abort && *abort)) { Frame &frame = frames_.emplace_back(); - int err = av_read_frame(pFormatCtx_, &frame.pkt); + err = av_read_frame(pFormatCtx_, &frame.pkt); if (err < 0) { frames_.pop_back(); valid_ = (err == AVERROR_EOF); diff --git a/selfdrive/ui/replay/main.cc b/selfdrive/ui/replay/main.cc index 1be21b0ca..fea351c4b 100644 --- a/selfdrive/ui/replay/main.cc +++ b/selfdrive/ui/replay/main.cc @@ -39,7 +39,7 @@ int getch() { return ch; } -void keyboardThread(Replay *replay) { +void keyboardThread(Replay *replay_) { char c; while (true) { c = getch(); @@ -51,26 +51,26 @@ void keyboardThread(Replay *replay) { try { if (r[0] == '#') { r.erase(0, 1); - replay->seekTo(std::stoi(r) * 60, false); + replay_->seekTo(std::stoi(r) * 60, false); } else { - replay->seekTo(std::stoi(r), false); + replay_->seekTo(std::stoi(r), false); } } catch (std::invalid_argument) { qDebug() << "invalid argument"; } getch(); // remove \n from entering seek } else if (c == 'm') { - replay->seekTo(+60, true); + replay_->seekTo(+60, true); } else if (c == 'M') { - replay->seekTo(-60, true); + replay_->seekTo(-60, true); } else if (c == 's') { - replay->seekTo(+10, true); + replay_->seekTo(+10, true); } else if (c == 'S') { - replay->seekTo(-10, true); + replay_->seekTo(-10, true); } else if (c == 'G') { - replay->seekTo(0, true); + replay_->seekTo(0, true); } else if (c == ' ') { - replay->pause(!replay->isPaused()); + replay_->pause(!replay_->isPaused()); } } } diff --git a/third_party/nanovg/nanovg_gl_utils.h b/third_party/nanovg/nanovg_gl_utils.h index 1323e90c6..2d8699c4c 100644 --- a/third_party/nanovg/nanovg_gl_utils.h +++ b/third_party/nanovg/nanovg_gl_utils.h @@ -52,11 +52,11 @@ static GLint defaultFBO = -1; NVGLUframebuffer* nvgluCreateFramebuffer(NVGcontext* ctx, int w, int h, int imageFlags) { #ifdef NANOVG_FBO_VALID - GLint defaultFBO; + GLint localDefaultFBO; GLint defaultRBO; NVGLUframebuffer* fb = NULL; - glGetIntegerv(GL_FRAMEBUFFER_BINDING, &defaultFBO); + glGetIntegerv(GL_FRAMEBUFFER_BINDING, &localDefaultFBO); glGetIntegerv(GL_RENDERBUFFER_BINDING, &defaultRBO); fb = (NVGLUframebuffer*)malloc(sizeof(NVGLUframebuffer)); @@ -92,11 +92,11 @@ NVGLUframebuffer* nvgluCreateFramebuffer(NVGcontext* ctx, int w, int h, int imag if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) goto error; - glBindFramebuffer(GL_FRAMEBUFFER, defaultFBO); + glBindFramebuffer(GL_FRAMEBUFFER, localDefaultFBO); glBindRenderbuffer(GL_RENDERBUFFER, defaultRBO); return fb; error: - glBindFramebuffer(GL_FRAMEBUFFER, defaultFBO); + glBindFramebuffer(GL_FRAMEBUFFER, localDefaultFBO); glBindRenderbuffer(GL_RENDERBUFFER, defaultRBO); nvgluDeleteFramebuffer(fb); return NULL;