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

airscan-trace.c: Check the path length #140

Merged
merged 1 commit into from Apr 16, 2021

Conversation

zdohnal
Copy link
Contributor

@zdohnal zdohnal commented Apr 16, 2021

GCC 11 with -Werror generates an error for 'strcpy' usage, so checking
the size and returning NULL if lesser than 4 works it around.

@alexpevzner
Copy link
Owner

Hi @zdohnal,

I'd better put log_assert(NULL, str_len(path) >= 4) there, with the same comment regarding gcc 11. Technically it's the same, but looks better for human reader.

GCC 11 with -Werror generates an error for 'strcpy' usage,
so checking the size and returning NULL if lesser than 4
works it around.
@zdohnal
Copy link
Contributor Author

zdohnal commented Apr 16, 2021

Squashed and ready. Although I find a simple ifs more readable than asserts, but it is just a POV.

@alexpevzner alexpevzner merged commit 9844a12 into alexpevzner:master Apr 16, 2021
@zdohnal
Copy link
Contributor Author

zdohnal commented Apr 16, 2021

Thx, @alexpevzner !

@alexpevzner
Copy link
Owner

I probably need to create 0.99.26 release now?

@alexpevzner
Copy link
Owner

Returning NULL definitely breaks logic, so reader should understand, that it never happens actually. asserts indicates a condition that expected to never happen.

@zdohnal
Copy link
Contributor Author

zdohnal commented Apr 16, 2021

I probably need to create 0.99.26 release now?

If you have time... I expected to have it downstream till a new release, so it doesn't matter to me too much.

@zdohnal
Copy link
Contributor Author

zdohnal commented Apr 16, 2021

Returning NULL definitely breaks logic, so reader should understand, that it never happens actually. asserts indicates a condition that expected to never happen.

Aha, I took that from the start of function, where you return NULL if dgb_trace is NULL, but that can happen, if it stays initialized and no one defines/enables tracing in config. So in the end it makes sense to divide the states.

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.

None yet

2 participants