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

cleanup(libsinsp): introduce param->as<std::string>(), add error for unsupported types #1893

Merged

Conversation

LucaGuerra
Copy link
Contributor

@LucaGuerra LucaGuerra commented Jun 4, 2024

What type of PR is this?

Uncomment one (or more) /kind <> lines:

/kind cleanup

Any specific area of the project related to this PR?

Uncomment one (or more) /area <> lines:

/area libsinsp

Does this PR require a change in the driver versions?

No

What this PR does / why we need it:

Addressing feedback received.

A contributor tried to set up a test with something like evt->get_param(1)->as<std::string>() and was confused by the fact that (1) std::string was not directly supported and (2) this did not result in a compilation error but in a runtime error which was hard to understand, as the engine tried to reinterpret a char string as an std::string basically setting the raw bytes of the string object and then erroring out because of the wrong size.

So to make it easier to work with this this PR does two things:

  • Adds a param conversion type std::string
  • Adds a compile time error for unsupported types

/milestone 0.18.0

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Code that does some_stuct->some_string = evt->get_param(N)->as<std::string>() does not copy the string. It creates it once and then, if necessary uses the move assignment operator.

Does this PR introduce a user-facing change?:

cleanup(libsinsp): introduce param->as<std::string>(), add error for unsupported types

…unsupported types

Signed-off-by: Luca Guerra <luca@guerra.sh>
@LucaGuerra LucaGuerra force-pushed the cleanup/param-as-string-clean-err branch from 29d9e5f to 0d73ac1 Compare June 4, 2024 14:40
Copy link
Contributor

@FedeDP FedeDP left a comment

Choose a reason for hiding this comment

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

/approve

@poiana
Copy link
Contributor

poiana commented Jun 19, 2024

LGTM label has been added.

Git tree hash: ef9d96f6a3409111ef68e972fed1622b4d97b506

Copy link
Member

@Andreagit97 Andreagit97 left a comment

Choose a reason for hiding this comment

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

/approve

@poiana
Copy link
Contributor

poiana commented Jun 21, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Andreagit97, FedeDP, LucaGuerra

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [Andreagit97,FedeDP,LucaGuerra]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@poiana poiana merged commit 1b81ff0 into falcosecurity:master Jun 21, 2024
40 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants