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 some warnings identified by a static analyzer #2486

Merged
merged 3 commits into from
Oct 23, 2024

Conversation

pqarmitage
Copy link
Collaborator

Although none of the warnings was due to any error in the code that could cause a problem. for some of the warnings reported is was quite straightforward to modify the code in a way that was just as readable and would avoid the warnings.

Two of the warnings reported could not possibly result in an error, and checks (return code or null dereferences) were not made since the design of the code was such that they could not occur.

The code was using the reload variable as an indicator that
prev_global_data was not NULL, and this was causing some static
code analysers to to flag up NULL pointer dereferences.

The patch explicitly checks whether prev_global_data is NULL or not,
since this is synonymous with testing the reload variable.

Signed-off-by: Quentin Armitage <[email protected]>
The code was, in some places, also setting dbus_{in,out}_pipe[1]
to -1 when it closed the pipes, which is unnecessary. In other places
it set dbus_{in,out}_pipe[0] to -1 twice, and did not set the [1]
equivalents at all, which was just wrong.

Signed-off-by: Quentin Armitage <[email protected]>
This means that if that if there is a subsequent reference to the
old data via thoe old_global_data, or old{bfd,check,vrrp} pointers,
it should cause a segfault rather than undefined behaviour. It will
also make it more straightford to debug any problem should it occur.

Signed-off-by: Quentin Armitage <[email protected]>
@pqarmitage pqarmitage merged commit e0b820c into acassen:master Oct 23, 2024
10 checks passed
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.

1 participant