From 88716ce19a3d562af7cbb5339013a14158307071 Mon Sep 17 00:00:00 2001 From: Pragyansh Chaturvedi Date: Mon, 20 Oct 2025 05:47:40 +0530 Subject: [PATCH] Fill missing fields in BpfObject's move constructor --- src/core/bpf_object.cpp | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/core/bpf_object.cpp b/src/core/bpf_object.cpp index dbc66d4..b3d66a5 100644 --- a/src/core/bpf_object.cpp +++ b/src/core/bpf_object.cpp @@ -4,6 +4,7 @@ #include "bpf_program.h" #include "utils/struct_parser.h" #include +#include BpfObject::BpfObject(std::string object_path, py::dict structs) : obj_(nullptr), object_path_(std::move(object_path)), loaded_(false), @@ -22,9 +23,13 @@ BpfObject::~BpfObject() { } BpfObject::BpfObject(BpfObject &&other) noexcept - : obj_(other.obj_), object_path_(std::move(other.object_path_)), - loaded_(other.loaded_), prog_cache_(std::move(other.prog_cache_)), - maps_cache_(std::move(other.maps_cache_)) { + : obj_(std::exchange(other.obj_, nullptr)), + object_path_(std::move(other.object_path_)), + loaded_(std::exchange(other.loaded_, false)), + maps_cache_(std::move(other.maps_cache_)), + prog_cache_(std::move(other.prog_cache_)), + struct_defs_(std::move(other.struct_defs_)), + struct_parser_(std::move(other.struct_parser_)) { other.obj_ = nullptr; other.loaded_ = false; @@ -38,14 +43,13 @@ BpfObject &BpfObject::operator=(BpfObject &&other) noexcept { bpf_object__close(obj_); } - obj_ = other.obj_; + obj_ = std::exchange(other.obj_, nullptr); object_path_ = std::move(other.object_path_); - loaded_ = other.loaded_; - prog_cache_ = std::move(other.prog_cache_); + loaded_ = std::exchange(other.loaded_, false); maps_cache_ = std::move(other.maps_cache_); - - other.obj_ = nullptr; - other.loaded_ = false; + prog_cache_ = std::move(other.prog_cache_); + struct_defs_ = std::move(other.struct_defs_); + struct_parser_ = std::move(other.struct_parser_); } return *this; }