Skip to content

Comments

Add enum for RawPacket concrete implementation.#2062

Open
Dimi1010 wants to merge 8 commits intoseladb:devfrom
Dimi1010:refactor/rawpacket-impl-enum
Open

Add enum for RawPacket concrete implementation.#2062
Dimi1010 wants to merge 8 commits intoseladb:devfrom
Dimi1010:refactor/rawpacket-impl-enum

Conversation

@Dimi1010
Copy link
Collaborator

@Dimi1010 Dimi1010 commented Feb 1, 2026

This PR replaces the raw packet type identifier integers uint8_t with strongly typed enum internal::RawPacketImplType.

The associated method RawPacket::getObjectType() has been deprecated in favor of RawPacket::getImplType().

The new method getImplType has been documented as for internal use, and should not be considered part of the stable API.

@Dimi1010 Dimi1010 added refactoring API deprecation Pull requests that deprecate parts of the public interface. labels Feb 1, 2026
@Dimi1010 Dimi1010 marked this pull request as ready for review February 1, 2026 13:04
@Dimi1010 Dimi1010 requested a review from seladb as a code owner February 1, 2026 13:04
@codecov
Copy link

codecov bot commented Feb 1, 2026

Codecov Report

❌ Patch coverage is 0% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.80%. Comparing base (bcc9ffd) to head (1b1a30b).

Files with missing lines Patch % Lines
Packet++/header/RawPacket.h 0.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #2062      +/-   ##
==========================================
- Coverage   83.81%   83.80%   -0.01%     
==========================================
  Files         313      313              
  Lines       55676    55673       -3     
  Branches    11606    11578      -28     
==========================================
- Hits        46665    46659       -6     
- Misses       7810     7826      +16     
+ Partials     1201     1188      -13     
Flag Coverage Δ
alpine320 76.39% <0.00%> (-0.01%) ⬇️
fedora42 76.12% <0.00%> (-0.03%) ⬇️
macos-14 81.97% <0.00%> (-0.01%) ⬇️
macos-15 81.96% <0.00%> (-0.01%) ⬇️
mingw32 70.34% <0.00%> (-0.03%) ⬇️
mingw64 70.33% <0.00%> (+0.05%) ⬆️
npcap ?
rhel94 75.74% <0.00%> (-0.01%) ⬇️
ubuntu2004 59.61% <0.00%> (+0.02%) ⬆️
ubuntu2004-zstd 59.72% <0.00%> (-0.01%) ⬇️
ubuntu2204 75.68% <0.00%> (-0.01%) ⬇️
ubuntu2204-icpx 59.06% <0.00%> (-0.01%) ⬇️
ubuntu2404 76.06% <0.00%> (-0.01%) ⬇️
ubuntu2404-arm64 76.06% <0.00%> (+0.01%) ⬆️
unittest 83.80% <0.00%> (-0.01%) ⬇️
windows-2022 85.60% <0.00%> (+0.10%) ⬆️
windows-2025 85.64% <0.00%> (+0.12%) ⬆️
winpcap 85.64% <0.00%> (-0.10%) ⬇️
xdp 51.94% <0.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

enum class RawPacketImplType : uint8_t
{
/// @brief Unknown type
Unknown = 0,
Copy link
Owner

Choose a reason for hiding this comment

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

Why do we need Unknown?

Copy link
Collaborator Author

@Dimi1010 Dimi1010 Feb 8, 2026

Choose a reason for hiding this comment

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

It is so zero initialized values have a separate enum value that won't just be assumed to be a certain implementation.

It is mostly a defensive programming technique.

Copy link
Owner

Choose a reason for hiding this comment

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

Since the base class RawPacket is the default, I think it should be the default for the enum as well

Copy link
Collaborator Author

@Dimi1010 Dimi1010 Feb 22, 2026

Choose a reason for hiding this comment

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

The RawPacket being nominal default implementation doesn't guarantee it is to be assumed everywhere tho?

I would prefer not to risk it in this case, as it can lead to memory corruption bugs due to improper down casting and those are hard to track down. It is done this way precisely to reduce general assumptions, which can be dangerous when working with memory.

@seladb
Copy link
Owner

seladb commented Feb 8, 2026

@Dimi1010 do you know why the "Generate Cobertura Report" phase randomly fails? It uses gcovr to generate the coverage report from the .gcda files generated during the build with --coverage. I tried checking with AI but not exactly sure why it could fail...

@Dimi1010
Copy link
Collaborator Author

Dimi1010 commented Feb 9, 2026

@Dimi1010 do you know why the "Generate Cobertura Report" phase randomly fails? It uses gcovr to generate the coverage report from the .gcda files generated during the build with --coverage. I tried checking with AI but not exactly sure why it could fail...

Tbh, I'm not really sure either. I can try to debug it, but I'm not promising anything.

@Dimi1010
Copy link
Collaborator Author

@Dimi1010 do you know why the "Generate Cobertura Report" phase randomly fails? It uses gcovr to generate the coverage report from the .gcda files generated during the build with --coverage. I tried checking with AI but not exactly sure why it could fail...

Tbh, I'm not really sure either. I can try to debug it, but I'm not promising anything.

@seladb created a separate issue #2067 for that so it isn't scattered in PRs.

Copy link
Owner

@seladb seladb left a comment

Choose a reason for hiding this comment

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

Please see the comment below, otherwise LGTM

enum class RawPacketImplType : uint8_t
{
/// @brief Unknown type
Unknown = 0,
Copy link
Owner

Choose a reason for hiding this comment

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

Since the base class RawPacket is the default, I think it should be the default for the enum as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

API deprecation Pull requests that deprecate parts of the public interface. refactoring

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants