Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getRawPacketReadOnly() const-correctness #1573

Open
luizfeldmann opened this issue Sep 11, 2024 · 2 comments · May be fixed by #1637
Open

getRawPacketReadOnly() const-correctness #1573

luizfeldmann opened this issue Sep 11, 2024 · 2 comments · May be fixed by #1637
Labels

Comments

@luizfeldmann
Copy link

Hi,

It seems that both the read-only and non-read-only getters of the raw packet from the parsed packet have the exact same signature and behaviour:

RawPacket* getRawPacket() const;
RawPacket* getRawPacketReadOnly() const;

Wouldn't it be more correct to declare the read-only getter as returning a pointer-to-const, and similarly, the non-read-only method not be marked as const method as it can alter the underlying object ?

RawPacket* getRawPacket();
const RawPacket* getRawPacketReadOnly() const;

Best regards,

@tigercosmos
Copy link
Collaborator

Yes, it's a bug.

@egecetin
Copy link
Collaborator

@luizfeldmann Feel free to open a PR to fix it if you have time. Contributions are welcome!

egecetin added a commit to egecetin/PcapPlusPlus that referenced this issue Nov 5, 2024
@egecetin egecetin linked a pull request Nov 5, 2024 that will close this issue
@egecetin egecetin linked a pull request Nov 5, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants