Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
5135288
Introduce .clang-tidy
pjungkamp May 27, 2025
c422b4c
nix: Add clang based package and devShell
pjungkamp Jun 4, 2025
61832cc
Make villas::utils::PopenStream operator>> a friend
pjungkamp Jan 24, 2026
f53bc12
fix(vfio_device): Remove unused pci_device pointer
pjungkamp Jan 25, 2026
4eba32c
fix(vfio_device): Make IrqVectorInfo initialization more explicit
pjungkamp Jan 25, 2026
e7812ed
fix(fpga/intc): Make IrqVectorInfo initialization more explicit
pjungkamp Jan 25, 2026
2bdd6e0
fix(kernel): Mark ~Driver interface destructor as virtual
pjungkamp Jan 24, 2026
e20190a
fix(clang): Allow unkown warning options
pjungkamp Jan 24, 2026
33c1a13
fix(tests/utils): Fix string use-after-free
pjungkamp Jan 24, 2026
a03a7eb
fix(fpga/rtds): Fix broken reinterpret_cast to virtual base class
pjungkamp Jan 24, 2026
7cee0f3
fix(cpuset): Fix ambiguous C++20 operator== overload
pjungkamp Jan 24, 2026
11e4f11
fix(memory): Fix non-virtual destructor in polymorphic class
pjungkamp Jan 24, 2026
8d0780c
fix(exceptions): Add missing override annotation
pjungkamp Jan 24, 2026
fa748f6
fix(opal/ddf): Fix non-virtual destructor in polymorphic class
pjungkamp Jan 24, 2026
a90acbf
fix(webrtc): Fix use of deleted default constructor of sample_pool
pjungkamp Jan 24, 2026
968474e
fix(tests/config): Remove broken putenv call
pjungkamp Jan 25, 2026
33be336
fix(tests/queue): Fix unintentional sleep(0) using usleep
pjungkamp Jan 25, 2026
0e7575f
fix(tests/format): Use proper printf formatting specifiers for std::i…
pjungkamp Jan 25, 2026
86aadc3
fix(config): Fix string use-after-free
pjungkamp Jan 25, 2026
ba18200
fix(hook/lua): Remove unused lua_tojson function
pjungkamp Jan 25, 2026
1d786d9
fix(hooks/lua): Fix forward declaration of SignalType
pjungkamp Jan 25, 2026
bcd629a
fix(format/json_kafka): Fix json_pack string parameter
pjungkamp Jan 25, 2026
b267998
fix(sample): Remove C compatability macros
pjungkamp Jan 25, 2026
d3b2ec2
fix(web): Conditionally add global extensions array
pjungkamp Jan 25, 2026
4a32887
fix(opal-async-param): Close header comment
pjungkamp Jan 25, 2026
c788b73
fix(treewide): Fix virtual/override annotations
pjungkamp Jan 25, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# SPDX-FileCopyrightText: 2025 Institute for Automation of Complex Power Systems, RWTH Aachen University
# SPDX-License-Identifier: Apache-2.0

Checks: >
-*,
modernize-use-override,
WarningsAsErrors: '*'
HeaderFilterRegex: villas/.*
FormatStyle: file
9 changes: 8 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,14 @@ include(FindSymbol)
include(CMakeDependentOption)

add_definitions(-D_POSIX_C_SOURCE=200809L -D_GNU_SOURCE)
add_compile_options(-Wall -Wno-unknown-pragmas -fdiagnostics-color=auto)
add_compile_options(
-Wall
-Wno-unknown-pragmas
-Wno-unknown-warning-option
-Wno-vla-cxx-extension
-Wno-unused-command-line-argument
-fdiagnostics-color=auto
)

# Check OS
check_include_file("sys/eventfd.h" HAS_EVENTFD)
Expand Down
6 changes: 3 additions & 3 deletions clients/shmem/villas-shmem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class Shmem : public Tool {
protected:
std::atomic<bool> stop;

void usage() {
void usage() override {
std::cout
<< "Usage: villas-test-shmem WNAME VECTORIZE" << std::endl
<< " WNAME name of the shared memory object for the output queue"
Expand All @@ -47,9 +47,9 @@ class Shmem : public Tool {
printCopyright();
}

void handler(int, siginfo_t *, void *) { stop = true; }
void handler(int, siginfo_t *, void *) override { stop = true; }

int main() {
int main() override {
int ret, readcnt, writecnt, avail;

struct ShmemInterface shm;
Expand Down
4 changes: 3 additions & 1 deletion common/include/villas/cpuset.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ class CpuSet {
return full ^ *this;
}

bool operator==(const CpuSet &rhs) { return CPU_EQUAL_S(sz, setp, rhs.setp); }
friend bool operator==(const CpuSet &lhs, const CpuSet &rhs) {
return CPU_EQUAL_S(lhs.sz, lhs.setp, rhs.setp);
}

CpuSet &operator&=(const CpuSet &rhs) {
CPU_AND_S(sz, setp, setp, rhs.setp);
Expand Down
2 changes: 1 addition & 1 deletion common/include/villas/dsp/window_cosine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class CosineWindow : public Window<T> {

T correctionFactor;

virtual T filter(T in, size_type i) const { return in * coefficients[i]; }
T filter(T in, size_type i) const override { return in * coefficients[i]; }

public:
CosineWindow(double a0, double a1, double a2, double a3, double a4,
Expand Down
2 changes: 1 addition & 1 deletion common/include/villas/exceptions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class ConfigError : public std::runtime_error {
}

public:
~ConfigError() {
~ConfigError() override {
if (msg)
free(msg);
}
Expand Down
3 changes: 2 additions & 1 deletion common/include/villas/kernel/devices/driver.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Interface for device drivers. OS/platform independend.
/* Interface for device drivers. OS/platform independent.
* Implemented for Linux/Unix drivers in linux_driver.hpp
*
* Author: Pascal Bauer <pascal.bauer@rwth-aachen.de>
Expand All @@ -24,6 +24,7 @@ class Driver {
virtual std::string name() const = 0;
virtual void override(const Device &device) const = 0;
virtual void unbind(const Device &device) const = 0;
virtual ~Driver() = default;
};

} // namespace devices
Expand Down
3 changes: 0 additions & 3 deletions common/include/villas/kernel/vfio_device.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,6 @@ class Device {
std::vector<struct vfio_region_info> regions;
std::vector<void *> mappings;

// libpci handle of the device
const kernel::devices::PciDevice *pci_device;

Logger log;
};

Expand Down
11 changes: 6 additions & 5 deletions common/include/villas/memory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,9 @@ template <typename DerivedAllocator> class BaseAllocator {
derivedAlloc = nullptr;
}

virtual std::unique_ptr<MemoryBlock, MemoryBlock::deallocator_fn>
virtual ~BaseAllocator() = default;

virtual std::unique_ptr<MemoryBlock, MemoryBlock::deallocator_fn>
allocateBlock(size_t size) = 0;

template <typename T> MemoryAccessor<T> allocate(size_t num) {
Expand Down Expand Up @@ -217,8 +218,8 @@ class LinearAllocator : public BaseAllocator<LinearAllocator> {

std::string getName() const;

virtual std::unique_ptr<MemoryBlock, MemoryBlock::deallocator_fn>
allocateBlock(size_t size);
std::unique_ptr<MemoryBlock, MemoryBlock::deallocator_fn>
allocateBlock(size_t size) override;

private:
static constexpr size_t alignBytes = sizeof(uintptr_t);
Expand Down Expand Up @@ -247,7 +248,7 @@ class HostRam {
std::string getName() const { return "HostRamAlloc"; }

std::unique_ptr<MemoryBlock, MemoryBlock::deallocator_fn>
allocateBlock(size_t size);
allocateBlock(size_t size) override;
};

static HostRamAllocator &getAllocator() {
Expand All @@ -264,7 +265,7 @@ class HostDmaRam {
public:
HostDmaRamAllocator(int num);

virtual ~HostDmaRamAllocator();
~HostDmaRamAllocator() override;

std::string getName() const { return getUdmaBufName(num); }

Expand Down
10 changes: 5 additions & 5 deletions common/include/villas/popen.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ class PopenStream : public Popen {
void open();
int close();

template <typename T>
friend std::istream &operator>>(villas::utils::PopenStream &po, T &value) {
return *(po.input.stream) >> value;
}

protected:
struct {
std::unique_ptr<std::istream> stream;
Expand All @@ -84,8 +89,3 @@ class PopenStream : public Popen {

} // namespace utils
} // namespace villas

template <typename T>
std::istream &operator>>(villas::utils::PopenStream &po, T &value) {
return *(po.input.stream) >> value;
}
10 changes: 5 additions & 5 deletions common/lib/kernel/vfio_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ static const char *vfio_pci_irq_names[] = {
Device::Device(const std::string &name, int groupFileDescriptor,
const kernel::devices::PciDevice *pci_device)
: name(name), fd(-1), attachedToGroup(false), groupFd(groupFileDescriptor),
info(), info_irq_vectors(), regions(), mappings(), pci_device(pci_device),
info(), info_irq_vectors(), regions(), mappings(),
log(Log::get("kernel:vfio:device")) {
if (groupFileDescriptor < 0)
throw RuntimeError("Invalid group file descriptor");
Expand Down Expand Up @@ -254,7 +254,7 @@ bool Device::pciEnable() {
std::vector<Device::IrqVectorInfo> Device::initEventFds() {
std::vector<Device::IrqVectorInfo> vectors;
for (auto info_irq_vector : info_irq_vectors) {
Device::IrqVectorInfo irq = {0};
Device::IrqVectorInfo irq = {.eventFds = {0}};
const size_t irqCount = info_irq_vector.count;
const size_t irqSetSize =
sizeof(struct vfio_irq_set) + sizeof(int) * irqCount;
Expand Down Expand Up @@ -296,7 +296,7 @@ std::vector<Device::IrqVectorInfo> Device::initEventFds() {
return vectors;
}

int Device::pciMsiInit(int efds[]) {
int Device::pciMsiInit(int efds[32]) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not correct. The function does not work with a fixed length array.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But that is what the declaration of the function in the header says. The mismatch in declaration and definition signature breaks the clang build.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok sorry, didn't realize that. In the function itself, we don't do proper bounds checking.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I can tell, this is the only one of your concerns that remains in the stripped-down version of this MR and wasn't addressed yet.

I want to touch as little logic as possible here and therefore I'll do one of 2 things:

  1. Use the type from the header (int[32]) like I'm doing now.
  2. Use the type from the source (int[]).

Please tell me which one you'd prefer and file an issue if you think that there's a bug here.

// Check if this is really a vfio-pci device
if (not isVfioPciDevice())
return -1;
Expand Down Expand Up @@ -341,7 +341,7 @@ int Device::pciMsiInit(int efds[]) {
return irqCount;
}

int Device::pciMsiDeinit(int efds[]) {
int Device::pciMsiDeinit(int efds[32]) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is also not correct. See above.

Log::get("Device")->debug("Deinitializing MSI interrupts for device {}",
name);
// Check if this is really a vfio-pci device
Expand Down Expand Up @@ -381,7 +381,7 @@ int Device::pciMsiDeinit(int efds[]) {
return irqCount;
}

bool Device::pciMsiFind(int nos[]) {
bool Device::pciMsiFind(int nos[32]) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also incorrect to specify the length here.

int ret, idx, irq;
char *end, *col, *last, line[1024], name[13];
FILE *f;
Expand Down
2 changes: 1 addition & 1 deletion common/tests/unit/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ Test(utils, cpuset) {
cset4.clear(6);
cr_assert_not(cset4[6]);

cr_assert_str_eq(static_cast<std::string>(cset4).c_str(), "1-5");
cr_assert_eq(static_cast<std::string>(cset4), "1-5");

cr_assert_any_throw(CpuSet cset5("0-"));

Expand Down
39 changes: 29 additions & 10 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@
withAllNodes = true;
};

villas-node-clang = pkgs.villas-node.override {
stdenv = pkgs.clangStdenv;
};

dockerImage = pkgs.dockerTools.buildLayeredImage {
name = "villas-node";
tag = "latest-nix";
Expand All @@ -89,7 +93,6 @@
};

# Cross-compiled packages

villas-node-x86_64-linux =
if pkgs.system == "x86_64-linux" then pkgs.villas-node else pkgs.pkgsCross.x86_64-linux.villas-node;
villas-node-aarch64-linux =
Expand Down Expand Up @@ -144,7 +147,7 @@
system:
let
pkgs = devPkgsFor system;
hardeningDisable = [ "all" ];

packages = with pkgs; [
bashInteractive
bc
Expand All @@ -161,19 +164,35 @@
pre-commit
ruby # for pre-commit markdownlint hook
];

mkShellFor = stdenv: pkg: stdenv.mkDerivation {
name = "${pkg.pname}-${stdenv.cc.cc.pname}-devShell";

# disable all hardening to suppress warnings in debug builds
hardeningDisable = [ "all" ];

# inherit inputs from pkg
buildInputs = pkg.buildInputs ++ packages;
nativeBuildInputs = pkg.nativeBuildInputs ++ packages;
propagatedBuildInputs = pkg.propagatedBuildInputs;
propagatedNativeBuildInputs = pkg.propagatedNativeBuildInputs;

# configure nix-ld for pre-commit
env = {
NIX_LD = lib.fileContents "${stdenv.cc}/nix-support/dynamic-linker";
NIX_LD_LIBRARY_PATH = lib.makeLibraryPath [ pkgs.gcc-unwrapped.lib ];
};
};
in
rec {
default = full;
default = gcc;

full = pkgs.mkShell {
inherit hardeningDisable packages;
name = "full";
inputsFrom = with pkgs; [ villas-node ];
};
gcc = mkShellFor pkgs.stdenv pkgs.villas-node;
clang = mkShellFor pkgs.clangStdenv pkgs.villas-node;

python = pkgs.mkShell {
inherit hardeningDisable;
name = "python";
name = "villas-python-devShell";
hardeningDisable = [ "all" ];
inputsFrom = with pkgs; [ villas-node-python ];
packages =
with pkgs;
Expand Down
12 changes: 6 additions & 6 deletions fpga/include/villas/fpga/core.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,15 +227,15 @@ class CoreFactory : public plugin::Plugin {
// Returns a running and checked FPGA IP
static std::list<std::shared_ptr<Core>> make(Card *card, json_t *json_ips);

virtual std::string getType() const { return "core"; }
std::string getType() const override { return "core"; }

protected:
enum PollingMode {
POLL,
IRQ,
};

Logger getLogger() { return villas::Log::get(getName()); }
Logger getLogger() override { return villas::Log::get(getName()); }

// Configure IP instance from JSON config
virtual void parse(Core &, json_t *) {}
Expand All @@ -257,15 +257,15 @@ template <typename T, const char *name, const char *desc, const char *vlnv>
class CorePlugin : public CoreFactory {

public:
virtual std::string getName() const { return name; }
std::string getName() const override { return name; }

virtual std::string getDescription() const { return desc; }
std::string getDescription() const override { return desc; }

private:
virtual Vlnv getCompatibleVlnv() const { return Vlnv(vlnv); }
Vlnv getCompatibleVlnv() const override { return Vlnv(vlnv); }

// Create a concrete IP instance
Core *make() const { return new T; };
Core *make() const override { return new T; };
};

} // namespace ip
Expand Down
10 changes: 6 additions & 4 deletions fpga/include/villas/fpga/ips/aurora.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,17 @@ class Aurora : public Node {
static constexpr const char *masterPort = "m_axis";
static constexpr const char *slavePort = "s_axis";

virtual void dump() override;
void dump() override;

std::list<std::string> getMemoryBlocks() const { return {registerMemory}; }
std::list<std::string> getMemoryBlocks() const override {
return {registerMemory};
}

const StreamVertex &getDefaultSlavePort() const {
const StreamVertex &getDefaultSlavePort() const override {
return getSlavePort(slavePort);
}

const StreamVertex &getDefaultMasterPort() const {
const StreamVertex &getDefaultMasterPort() const override {
return getMasterPort(masterPort);
}

Expand Down
4 changes: 2 additions & 2 deletions fpga/include/villas/fpga/ips/aurora_xilinx.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ class AuroraXilinx : public Node {
static constexpr const char *masterPort = "USER_DATA_M_AXI_RX";
static constexpr const char *slavePort = "USER_DATA_S_AXI_TX";

const StreamVertex &getDefaultSlavePort() const {
const StreamVertex &getDefaultSlavePort() const override {
return getSlavePort(slavePort);
}

const StreamVertex &getDefaultMasterPort() const {
const StreamVertex &getDefaultMasterPort() const override {
return getMasterPort(masterPort);
}
};
Expand Down
6 changes: 3 additions & 3 deletions fpga/include/villas/fpga/ips/axis_cache.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ namespace ip {
class AxisCache : public Node {
public:
AxisCache();
virtual ~AxisCache();
virtual bool init() override;
virtual bool check() override;
~AxisCache() override;
bool init() override;
bool check() override;
void invalidate();

protected:
Expand Down
Loading