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

Fix static code analysis warnings #428

Merged
merged 7 commits into from
Jan 26, 2021

Conversation

ArnoStiefvater
Copy link
Member

What:

Fix warnings of static code analysis.

Why:

Improve code quality and make CI happy.

How:

Install clang-tools-7 and run static code analysis with e.g.:

mkdir build && cd build/ && /bin/scan-build-7 cmake -DCMAKE_BUILD_TYPE=Debug .. && /bin/scan-build-7 -o tmp/scan-build-report make && [ -z "$(ls -A tmp/scan-build-report/)" ]

Checklist:

@@ -782,9 +782,9 @@ ip_islocalhost (struct sockaddr_storage *storage)
struct in_addr addr;
struct in_addr *addr_p;
struct in6_addr addr6;
struct in6_addr *addr6_p;
struct in6_addr *addr6_p = NULL;
Copy link
Contributor

Choose a reason for hiding this comment

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

These look wrong, because they're set directly below. Wouldn't recommend adding them just to quiet clang, but if you want to I recommend adding a note that it's for clang.

base/logging.c Outdated
@@ -510,7 +510,7 @@ gvm_log_func (const char *log_domain, GLogLevelFlags log_level,
/* Make the tmp pointer (for iteration) point to the format string. */
tmp = prepend_format;

while (*tmp != '\0')
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess there should rather be a NULL check at line 483 like there is at line 441, to prevent prepend_format from ever being NULL.

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 think it's good to let tmp be NULL because then prepend_buf ends up "" instead of the default "%t %s %p - ".

Remove possibility of having garbage value in
call to IN6_ARE_ADDR_EQUAL
gnutls_certificate_set_dh_params only stores a
pointer to the parameters in the certificate
handle, so you must not deallocate the parameters
before the certificate is deallocated.
@mattmundell mattmundell merged commit d93a4d3 into greenbone:master Jan 26, 2021
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.

2 participants