Skip to content

Commit

Permalink
refactor: fix cppcoreguidelines-non-private-member-variables-in-class…
Browse files Browse the repository at this point in the history
…es lint errors
  • Loading branch information
edubart committed Oct 17, 2024
1 parent ea0c7ee commit a60c09f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
1 change: 0 additions & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ Checks: >-
-clang-analyzer-optin.cplusplus.VirtualCall,
cppcoreguidelines*,
-cppcoreguidelines-avoid-magic-numbers,
-cppcoreguidelines-non-private-member-variables-in-classes,
-cppcoreguidelines-owning-memory,
-cppcoreguidelines-pro-bounds-array-to-pointer-decay,
-cppcoreguidelines-pro-bounds-constant-array-index,
Expand Down
8 changes: 6 additions & 2 deletions src/virtio-device.h
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,6 @@ struct virtq {

/// \brief VirtIO device common interface
class virtio_device {
protected:
uint32_t virtio_idx = 0; ///< VirtIO device index
uint32_t int_status = 0; ///< Interrupt status mask (see virtio_status)
uint32_t device_id = 0; ///< Device id (see virtio_devices)
Expand All @@ -258,12 +257,17 @@ class virtio_device {
uint32_t device_status = 0; ///< Device status mask (see virtio_status)
uint32_t config_generation = 0; ///< Configuration generation counter
uint32_t config_space_size = 0; ///< Configuration size
bool driver_ok = false; ///< True when the device was successfully initialized by the driver

protected:
// NOLINTBEGIN(cppcoreguidelines-non-private-member-variables-in-classes)
bool driver_ok = false; ///< True when the device was successfully initialized by the driver

// Use an array of uint32 instead of uint8, to make sure we can perform 4-byte aligned reads on config space
std::array<uint32_t, VIRTIO_MAX_CONFIG_SPACE_SIZE / sizeof(uint32_t)> config_space{}; ///< Configuration space
std::array<virtq, VIRTIO_QUEUE_COUNT> queue{}; ///< Virtqueues

// NOLINTEND(cppcoreguidelines-non-private-member-variables-in-classes)

public:
explicit virtio_device(uint32_t virtio_idx, uint32_t device_id, uint64_t device_features,
uint32_t config_space_size);
Expand Down
3 changes: 1 addition & 2 deletions src/virtio-p9fs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ static bool is_name_legal(const std::string &name) {

virtio_p9fs_device::virtio_p9fs_device(uint32_t virtio_idx, const std::string &mount_tag,
const std::string &root_path) :
virtio_device(virtio_idx, VIRTIO_DEVICE_9P, VIRTIO_9P_F_MOUNT_TAG, VIRTIO_MAX_CONFIG_SPACE_SIZE),
virtio_device(virtio_idx, VIRTIO_DEVICE_9P, VIRTIO_9P_F_MOUNT_TAG, mount_tag.length() + sizeof(uint16_t)),
m_msize(P9_MAX_MSIZE),
m_root_path(root_path) {
if (root_path.length() + 1 >= P9_ROOT_PATH_MAX) {
Expand All @@ -528,7 +528,6 @@ virtio_p9fs_device::virtio_p9fs_device(uint32_t virtio_idx, const std::string &m
virtio_p9fs_config_space *config = get_config();
strncpy(config->mount_tag.data(), mount_tag.c_str(), mount_tag.length());
config->mount_tag_len = mount_tag.length();
config_space_size = mount_tag.length() + sizeof(uint16_t);
}

virtio_p9fs_device::~virtio_p9fs_device() {
Expand Down

0 comments on commit a60c09f

Please sign in to comment.