Skip to content

Conversation

gnosek
Copy link
Contributor

@gnosek gnosek commented Mar 7, 2019

Basically #1266 with some changes, on top of the nfs branch, so please review only the last commit (the rest is in separate PRs already and should be merged before this)

@gnosek gnosek requested review from speedyguy17 and bertocci March 7, 2019 17:07

namespace {
// All severity strings should be ENCODE_LEN chars long
const char* sev_levels[] = {
Copy link
Contributor

Choose a reason for hiding this comment

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

all caps preferred...

SEVERITY_LEVELS

@@ -95,10 +98,16 @@ class SINSP_PUBLIC sinsp_logger
char* format(severity sev, const char* fmt, ...);
char* format(const char* fmt, ...);

// Returns the decoded severity or SEV_MAX+1 for errors.
// len is set to the length of the severity string on success
// and 0 in case of errors
Copy link
Contributor

Choose a reason for hiding this comment

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

Change to doxy style...

/**
 * This is my stuff
 */

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see this returning SEV_MAX+1 anywhere

for(size_t i = 1; i <= SEV_MAX; ++i)
{
uint64_t level = *((uint64_t*) sev_levels[i]);
if(msg_level == level)
Copy link
Contributor

Choose a reason for hiding this comment

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

this is fine, but not convinced it buys us much vs just a string compare

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Even with a hardcoded length of 8, the strncmp isn't optimized out, while the pointer cast (which I changed to a memcpy in the meantime to avoid alignment issues) gets compiled down to cmp reg, [reg]:

https://godbolt.org/z/4q2Vhb

Either way, this is nowhere near the hot path (hopefully) so we'll be fine with the strncmp. Thoughts?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Settled on using strncmp.

@gnosek gnosek force-pushed the nfs-with-logger-fix branch from 1d77a0b to 5e2b1d3 Compare March 29, 2019 16:15
@gnosek gnosek force-pushed the nfs-with-logger-fix branch 2 times, most recently from f873b5e to 7b20b69 Compare April 12, 2019 14:38
@gnosek gnosek force-pushed the nfs-with-logger-fix branch from 7b20b69 to d3e6abd Compare April 17, 2019 15:03
@gnosek gnosek force-pushed the nfs-with-logger-fix branch from d3e6abd to f5f9d16 Compare April 29, 2019 13:28
@gnosek gnosek force-pushed the nfs-with-logger-fix branch from f5f9d16 to ab05eaf Compare April 29, 2019 14:52
@gnosek gnosek force-pushed the nfs-with-logger-fix branch from ab05eaf to ce04f3a Compare April 29, 2019 15:30
@gnosek gnosek merged commit 9104e0f into dev Apr 29, 2019
@gnosek gnosek deleted the nfs-with-logger-fix branch April 29, 2019 15:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants