mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
Fix or suppress clang-tidy warnings (#8254)
This commit is contained in:
@@ -45,6 +45,8 @@ Checks:
|
||||
-clang-diagnostic-#warnings,
|
||||
-clang-diagnostic-pedantic,
|
||||
clang-analyzer-*,
|
||||
-clang-analyzer-optin.cplusplus.UninitializedObject,
|
||||
-clang-analyzer-security.FloatLoopCounter,
|
||||
cppcoreguidelines-slicing,
|
||||
google-build-namespaces,
|
||||
google-explicit-constructor,
|
||||
|
||||
@@ -22,6 +22,7 @@ void BM_Transform(benchmark::State& state) {
|
||||
auto transform = pose2 - pose1;
|
||||
return units::math::hypot(transform.X(), transform.Y()).value();
|
||||
}};
|
||||
// NOLINTNEXTLINE(clang-analyzer-deadcode.DeadStores)
|
||||
for (auto _ : state) {
|
||||
traveler.Solve(poses, iterations);
|
||||
}
|
||||
@@ -33,6 +34,7 @@ void BM_Twist(benchmark::State& state) {
|
||||
auto twist = pose1.Log(pose2);
|
||||
return units::math::hypot(twist.dx, twist.dy).value();
|
||||
}};
|
||||
// NOLINTNEXTLINE(clang-analyzer-deadcode.DeadStores)
|
||||
for (auto _ : state) {
|
||||
traveler.Solve(poses, iterations);
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#include <opencv2/core/core.hpp>
|
||||
#include <wpi/print.h>
|
||||
|
||||
#include "cscore.h"
|
||||
#include "cscore_cv.h"
|
||||
|
||||
int main() {
|
||||
|
||||
@@ -44,7 +44,7 @@ static O* ConvertToC(std::vector<I>&& in, int* count) {
|
||||
// retain vector at end of returned array
|
||||
alignas(T) unsigned char buf[sizeof(T)];
|
||||
new (buf) T(std::move(in));
|
||||
std::memcpy(out + size * sizeof(O), buf, sizeof(T));
|
||||
std::memcpy(out + size, buf, sizeof(T));
|
||||
|
||||
return out;
|
||||
}
|
||||
@@ -392,7 +392,7 @@ void CS_FreeEvents(CS_Event* arr, int count) {
|
||||
// destroy vector saved at end of array
|
||||
using T = std::vector<cs::RawEvent>;
|
||||
alignas(T) unsigned char buf[sizeof(T)];
|
||||
std::memcpy(buf, arr + count * sizeof(CS_Event), sizeof(T));
|
||||
std::memcpy(buf, arr + count, sizeof(T));
|
||||
reinterpret_cast<T*>(buf)->~T();
|
||||
|
||||
std::free(arr);
|
||||
|
||||
@@ -707,8 +707,9 @@ void UsbCameraImpl::DeviceCacheProperty(
|
||||
}
|
||||
|
||||
NotifyPropertyCreated(*rawIndex, *rawPropPtr);
|
||||
if (perPropPtr && perIndex)
|
||||
if (perPropPtr && perIndex) {
|
||||
NotifyPropertyCreated(*perIndex, *perPropPtr);
|
||||
}
|
||||
}
|
||||
|
||||
CS_StatusValue UsbCameraImpl::DeviceProcessCommand(
|
||||
|
||||
@@ -4,11 +4,8 @@
|
||||
|
||||
#include "glass/other/PIDController.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <imgui.h>
|
||||
|
||||
#include "glass/Context.h"
|
||||
#include "glass/DataSource.h"
|
||||
|
||||
using namespace glass;
|
||||
@@ -34,8 +31,8 @@ void glass::DisplayPIDController(PIDControllerModel* m) {
|
||||
[flag](const char* name, double* v,
|
||||
std::function<void(double)> callback) {
|
||||
ImGui::SetNextItemWidth(ImGui::GetFontSize() * 4);
|
||||
if (ImGui::InputScalar(name, ImGuiDataType_Double, v, NULL, NULL,
|
||||
"%.3f", flag)) {
|
||||
if (ImGui::InputScalar(name, ImGuiDataType_Double, v, nullptr,
|
||||
nullptr, "%.3f", flag)) {
|
||||
callback(*v);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -4,11 +4,8 @@
|
||||
|
||||
#include "glass/other/ProfiledPIDController.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <imgui.h>
|
||||
|
||||
#include "glass/Context.h"
|
||||
#include "glass/DataSource.h"
|
||||
|
||||
using namespace glass;
|
||||
@@ -34,8 +31,8 @@ void glass::DisplayProfiledPIDController(ProfiledPIDControllerModel* m) {
|
||||
[flag](const char* name, double* v,
|
||||
std::function<void(double)> callback) {
|
||||
ImGui::SetNextItemWidth(ImGui::GetFontSize() * 4);
|
||||
if (ImGui::InputScalar(name, ImGuiDataType_Double, v, NULL, NULL,
|
||||
"%.3f", flag)) {
|
||||
if (ImGui::InputScalar(name, ImGuiDataType_Double, v, nullptr,
|
||||
nullptr, "%.3f", flag)) {
|
||||
callback(*v);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -44,6 +44,7 @@ Checks:
|
||||
-clang-diagnostic-#warnings,
|
||||
-clang-diagnostic-pedantic,
|
||||
clang-analyzer-*,
|
||||
-clang-analyzer-optin.cplusplus.UninitializedObject,
|
||||
cppcoreguidelines-slicing,
|
||||
google-build-namespaces,
|
||||
google-explicit-constructor,
|
||||
|
||||
@@ -11,20 +11,17 @@
|
||||
|
||||
int main() {
|
||||
auto inst = nt::GetDefaultInstance();
|
||||
nt::AddLogger(
|
||||
inst,
|
||||
[](const nt::LogMessage& msg) {
|
||||
std::fputs(msg.message.c_str(), stderr);
|
||||
std::fputc('\n', stderr);
|
||||
},
|
||||
0, UINT_MAX);
|
||||
nt::StartClient(inst, "127.0.0.1", 10000);
|
||||
nt::AddLogger(inst, 0, UINT_MAX, [](const nt::Event& event) {
|
||||
std::fputs(event.GetLogMessage()->message.c_str(), stderr);
|
||||
std::fputc('\n', stderr);
|
||||
});
|
||||
nt::StartClient4(inst, "127.0.0.1");
|
||||
std::this_thread::sleep_for(std::chrono::seconds(2));
|
||||
|
||||
auto foo = nt::GetEntry(inst, "/foo");
|
||||
auto foo_val = nt::GetEntryValue(foo);
|
||||
if (foo_val && foo_val->IsDouble()) {
|
||||
std::printf("Got foo: %g\n", foo_val->GetDouble());
|
||||
if (foo_val && foo_val.IsDouble()) {
|
||||
std::printf("Got foo: %g\n", foo_val.GetDouble());
|
||||
}
|
||||
|
||||
auto bar = nt::GetEntry(inst, "/bar");
|
||||
|
||||
@@ -11,14 +11,11 @@
|
||||
|
||||
int main() {
|
||||
auto inst = nt::GetDefaultInstance();
|
||||
nt::AddLogger(
|
||||
inst,
|
||||
[](const nt::LogMessage& msg) {
|
||||
std::fputs(msg.message.c_str(), stderr);
|
||||
std::fputc('\n', stderr);
|
||||
},
|
||||
0, UINT_MAX);
|
||||
nt::StartServer(inst, "persistent.ini", "", 10000);
|
||||
nt::AddLogger(inst, 0, UINT_MAX, [](const nt::Event& event) {
|
||||
std::fputs(event.GetLogMessage()->message.c_str(), stderr);
|
||||
std::fputc('\n', stderr);
|
||||
});
|
||||
nt::StartServer(inst, "persistent.ini", "", 10000, 10001);
|
||||
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||
|
||||
auto foo = nt::GetEntry(inst, "/foo");
|
||||
|
||||
@@ -177,6 +177,7 @@ static_assert(ValidType<uint8_t[]>);
|
||||
static_assert(ValidType<std::vector<uint8_t>>);
|
||||
|
||||
template <ValidType T, NT_Type type>
|
||||
// NOLINTNEXTLINE(google-readability-casting)
|
||||
constexpr bool IsNTType = TypeInfo<std::remove_cvref_t<T>>::kType == type;
|
||||
|
||||
static_assert(IsNTType<bool, NT_BOOLEAN>);
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <functional>
|
||||
#include <string_view>
|
||||
|
||||
|
||||
@@ -7,9 +7,7 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#include <atomic>
|
||||
#include <concepts>
|
||||
#include <span>
|
||||
#include <string_view>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
@@ -207,7 +205,7 @@ class ProtobufPublisher : public Publisher {
|
||||
ProtobufPublisher(ProtobufPublisher&& rhs)
|
||||
: Publisher{std::move(rhs)},
|
||||
m_msg{std::move(rhs.m_msg)},
|
||||
m_schemaPublished{rhs.m_schemaPublished} {}
|
||||
m_schemaPublished{rhs.m_schemaPublished.load()} {}
|
||||
|
||||
ProtobufPublisher& operator=(ProtobufPublisher&& rhs) {
|
||||
Publisher::operator=(std::move(rhs));
|
||||
|
||||
@@ -157,7 +157,7 @@ namespace nt {
|
||||
class StructTest : public ::testing::Test {
|
||||
public:
|
||||
StructTest() { inst = nt::NetworkTableInstance::Create(); }
|
||||
~StructTest() { nt::NetworkTableInstance::Destroy(inst); }
|
||||
~StructTest() override { nt::NetworkTableInstance::Destroy(inst); }
|
||||
|
||||
nt::NetworkTableInstance inst;
|
||||
};
|
||||
|
||||
@@ -72,8 +72,9 @@ int StartJavaTool(std::filesystem::path& exePath) {
|
||||
|
||||
std::string data = jarPath;
|
||||
std::string jarArg = "-jar";
|
||||
char* const arguments[] = {Java.generic_string().data(), jarArg.data(),
|
||||
data.data(), nullptr};
|
||||
auto javaGenericStr = Java.generic_string();
|
||||
char* const arguments[] = {javaGenericStr.data(), jarArg.data(), data.data(),
|
||||
nullptr};
|
||||
|
||||
int status =
|
||||
posix_spawn(&pid, Java.c_str(), nullptr, nullptr, arguments, environ);
|
||||
|
||||
@@ -69,10 +69,12 @@ TEST_F(DSCommPacketTest, MainJoystickTag) {
|
||||
std::array<uint8_t, 12> _buttons{{0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1}};
|
||||
|
||||
std::array<uint8_t, 2> _button_bytes{{0, 0}};
|
||||
for (int btn = 0; btn < 8; btn++)
|
||||
for (int btn = 0; btn < 8; btn++) {
|
||||
_button_bytes[1] |= _buttons[btn] << btn;
|
||||
for (int btn = 8; btn < 12; btn++)
|
||||
}
|
||||
for (int btn = 8; btn < 12; btn++) {
|
||||
_button_bytes[0] |= _buttons[btn] << (btn - 8);
|
||||
}
|
||||
|
||||
// 5 for base, 4 joystick, 12 buttons (2 bytes) 3 povs
|
||||
uint8_t arr[5 + 4 + 2 + 6] = {// Size, Tag
|
||||
|
||||
@@ -31,7 +31,6 @@ includeOtherLibs {
|
||||
^mrcal_wrapper\.h$
|
||||
^opencv2\.h$
|
||||
^portable-file-dialogs\.h$
|
||||
^tagpose\.h$
|
||||
^wpi/
|
||||
^wpigui
|
||||
}
|
||||
|
||||
@@ -19,10 +19,11 @@
|
||||
#include <fmt/format.h>
|
||||
#include <imgui.h>
|
||||
#include <portable-file-dialogs.h>
|
||||
#include <tagpose.h>
|
||||
#include <wpi/json.h>
|
||||
#include <wpigui.h>
|
||||
|
||||
#include "tagpose.h"
|
||||
|
||||
namespace gui = wpi::gui;
|
||||
|
||||
const char* GetWPILibVersion();
|
||||
@@ -140,7 +141,7 @@ static bool EmitEntryTarget(int tag_id, std::string& file) {
|
||||
if (ImGui::BeginDragDropTarget()) {
|
||||
if (const ImGuiPayload* payload =
|
||||
ImGui::AcceptDragDropPayload("FieldCalibration")) {
|
||||
file = *(std::string*)payload->Data;
|
||||
file = *static_cast<std::string*>(payload->Data);
|
||||
rv = true;
|
||||
}
|
||||
ImGui::EndDragDropTarget();
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#include <tagpose.h>
|
||||
#include "tagpose.h"
|
||||
|
||||
#include <wpi/deprecated.h>
|
||||
|
||||
WPI_IGNORE_DEPRECATED
|
||||
|
||||
@@ -7,9 +7,10 @@
|
||||
#include <cmath>
|
||||
#include <map>
|
||||
|
||||
#include <tagpose.h>
|
||||
#include <wpi/json.h>
|
||||
|
||||
#include "tagpose.h"
|
||||
|
||||
class Fieldmap {
|
||||
public:
|
||||
Fieldmap() = default;
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <fieldmap.h>
|
||||
|
||||
#include <tagpose.h>
|
||||
#include <wpi/json.h>
|
||||
|
||||
#include "fieldmap.h"
|
||||
#include "tagpose.h"
|
||||
|
||||
namespace fmap {
|
||||
wpi::json singleTag(int tag, const tag::Pose& tagpose);
|
||||
wpi::json convertfmap(const wpi::json& json);
|
||||
|
||||
@@ -53,7 +53,7 @@ class Config {
|
||||
std::optional<units::volt_t> stepVoltage,
|
||||
std::optional<units::second_t> timeout,
|
||||
std::function<void(frc::sysid::State)> recordState)
|
||||
: m_recordState{recordState} {
|
||||
: m_recordState{std::move(recordState)} {
|
||||
if (rampRate) {
|
||||
m_rampRate = rampRate.value();
|
||||
}
|
||||
|
||||
@@ -79,9 +79,9 @@ ADIS16470_IMU::ADIS16470_IMU(IMUAxis yaw_axis, IMUAxis pitch_axis,
|
||||
"IMUAxis.kZ as arguments.");
|
||||
REPORT_ERROR(
|
||||
"Constructing ADIS with default axes. (IMUAxis.kZ is defined as Yaw)");
|
||||
yaw_axis = kZ;
|
||||
pitch_axis = kY;
|
||||
roll_axis = kX;
|
||||
m_yaw_axis = kZ;
|
||||
m_pitch_axis = kY;
|
||||
m_roll_axis = kX;
|
||||
}
|
||||
|
||||
if (m_simDevice) {
|
||||
|
||||
@@ -22,7 +22,7 @@ using namespace frc;
|
||||
using enum Alert::AlertType;
|
||||
class AlertsTest : public ::testing::Test {
|
||||
public:
|
||||
~AlertsTest() {
|
||||
~AlertsTest() override {
|
||||
// test all destructors
|
||||
Update();
|
||||
EXPECT_EQ(GetSubscriberForType(kError).Get().size(), 0ul);
|
||||
|
||||
@@ -4,14 +4,16 @@
|
||||
|
||||
#include "commands/TeleopArcadeDrive.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "subsystems/Drivetrain.h"
|
||||
|
||||
TeleopArcadeDrive::TeleopArcadeDrive(
|
||||
Drivetrain* subsystem, std::function<double()> xaxisSpeedSupplier,
|
||||
std::function<double()> zaxisRotateSuppplier)
|
||||
: m_drive{subsystem},
|
||||
m_xaxisSpeedSupplier{xaxisSpeedSupplier},
|
||||
m_zaxisRotateSupplier{zaxisRotateSuppplier} {
|
||||
m_xaxisSpeedSupplier{std::move(xaxisSpeedSupplier)},
|
||||
m_zaxisRotateSupplier{std::move(zaxisRotateSuppplier)} {
|
||||
AddRequirements(subsystem);
|
||||
}
|
||||
|
||||
|
||||
@@ -171,8 +171,9 @@ TEST_F(DIOLoopTest, SynchronousInterruptWorks) {
|
||||
timer.Start();
|
||||
interrupt.WaitForInterrupt(kSynchronousInterruptTime + 1_s);
|
||||
auto time = timer.Get().value();
|
||||
if (thr.joinable())
|
||||
if (thr.joinable()) {
|
||||
thr.join();
|
||||
}
|
||||
EXPECT_NEAR(kSynchronousInterruptTime.value(), time,
|
||||
kSynchronousInterruptTimeTolerance.value());
|
||||
}
|
||||
|
||||
@@ -322,6 +322,7 @@ class JSpanBase {
|
||||
}
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(google-explicit-constructor)
|
||||
operator std::span<T, Size>() const { return array(); }
|
||||
|
||||
std::span<T, Size> array() const {
|
||||
|
||||
@@ -335,6 +335,7 @@ TEST_F(StringMapTest, MoveConstruct) {
|
||||
StringMap<int> A;
|
||||
A["x"] = 42;
|
||||
StringMap<int> B = std::move(A);
|
||||
// NOLINTNEXTLINE(clang-analyzer-cplusplus.Move)
|
||||
ASSERT_EQ(A.size(), 0u);
|
||||
ASSERT_EQ(B.size(), 1u);
|
||||
ASSERT_EQ(B["x"], 42);
|
||||
@@ -348,8 +349,10 @@ TEST_F(StringMapTest, MoveAssignment) {
|
||||
B["y"] = 117;
|
||||
A = std::move(B);
|
||||
ASSERT_EQ(A.size(), 1u);
|
||||
// NOLINTNEXTLINE(clang-analyzer-cplusplus.Move)
|
||||
ASSERT_EQ(B.size(), 0u);
|
||||
ASSERT_EQ(A["y"], 117);
|
||||
// NOLINTNEXTLINE(clang-analyzer-cplusplus.Move)
|
||||
ASSERT_EQ(B.count("x"), 0u);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user