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

minor - code readability HTTP CODES as defines && clear warnings #6539

Merged
merged 1 commit into from Jul 25, 2019
Merged

minor - code readability HTTP CODES as defines && clear warnings #6539

merged 1 commit into from Jul 25, 2019

Conversation

underhood
Copy link
Contributor

@underhood underhood commented Jul 24, 2019

Summary

Just a minor code cleanup for better readability of code that I didn't want to include in UTF8 URL parser PR due to IMHO being unrelated

Component Name

libnetdata/server

Additional Info

No behavior change. Just code readability - something that annoyed me a bit when I was going trough code. (not all people keep all the codes in memory (besides 200/400/404))
Additionally one compiler warning fixed if compiling with -Wpointer-sign

@thiagoftsm
Copy link
Contributor

Hi @underhood ,

I liked what the PR you brought, without any doubt, the code will be more readable with these changes, but before we approve, I will ask you to change one thing that we missed in the previous PR, because I had a problem in my compiler and I could not detect it. As you can see below

/home/thiago/Netdata/netdata/libnetdata/url/url.c: In function ‘url_decode_r’:
/home/thiago/Netdata/netdata/libnetdata/url/url.c:211:29: warning: pointer targets in passing argument 1 of ‘utf8_check’ differ in signedness [-Wpointer-sign]
211 | if(unlikely( utf8_check(to) )) //NULL means sucess here
| ^~
| |
| char *
/home/thiago/Netdata/netdata/./config.h:356:41: note: in definition of macro ‘unlikely’
356 | #define unlikely(x) __builtin_expect(!!(x), 0)
| ^
/home/thiago/Netdata/netdata/libnetdata/url/url.c:126:42: note: expected ‘unsigned char *’ but argument is of type ‘char *’
126 | unsigned char *utf8_check(unsigned char *s)
| ~~~~~~~~~~~~~~~^

It is necessary to cast the variable when we call utf8_check, but for these new code that you are bringing there is nothing to change.

Thanks a lot!

libnetdata/url/url.c Outdated Show resolved Hide resolved
@underhood underhood changed the title minor - code readability HTTP CODES as defines minor - code readability HTTP CODES as defines && clear warnings Jul 25, 2019
Copy link
Contributor

@cakrit cakrit left a comment

Choose a reason for hiding this comment

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

Damn, we just got a conflict due to a different PR getting merged. Can you please rebase?

@underhood
Copy link
Contributor Author

Damn, we just got a conflict due to a different PR getting merged. Can you please rebase?

Yep, the URL rework PR also fixed the comp warning in url.c. Will do when i get home

@underhood
Copy link
Contributor Author

I kicked out that url.c change

@cakrit cakrit merged commit ca5c183 into netdata:master Jul 25, 2019
@underhood underhood deleted the cleanup_http_code branch July 25, 2019 18:16
jacekkolasa pushed a commit to jacekkolasa/netdata that referenced this pull request Aug 6, 2019
jacekkolasa pushed a commit to jacekkolasa/netdata that referenced this pull request Aug 6, 2019
jackyhuang85 pushed a commit to jackyhuang85/netdata that referenced this pull request Jan 1, 2020
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 this pull request may close these issues.

None yet

5 participants