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
(#1694605) Backport/fixes for issues found by LGTM on RHEL 7 #311
Conversation
This pull request fixes 13 alerts when merging 4df22c7 into a781c22 - view on LGTM.com fixed alerts:
Comment posted by LGTM.com |
dee5636
to
d4974ce
Compare
This pull request fixes 15 alerts when merging 73386a7 into a781c22 - view on LGTM.com fixed alerts:
Comment posted by LGTM.com |
375afff
to
368d4f4
Compare
This pull request fixes 23 alerts when merging 368d4f4 into a781c22 - view on LGTM.com fixed alerts:
Comment posted by LGTM.com |
This pull request introduces 1 alert and fixes 25 when merging 300a5dd into a781c22 - view on LGTM.com new alerts:
fixed alerts:
Comment posted by LGTM.com |
300a5dd
to
5a5a676
Compare
This pull request fixes 26 alerts when merging 5a5a676 into a781c22 - view on LGTM.com fixed alerts:
Comment posted by LGTM.com |
d859133
to
ba2518d
Compare
This pull request fixes 28 alerts when merging ba2518d into a781c22 - view on LGTM.com fixed alerts:
Comment posted by LGTM.com |
a7b5463
to
70c9246
Compare
This pull request fixes 35 alerts when merging 70c9246 into a781c22 - view on LGTM.com fixed alerts:
Comment posted by LGTM.com |
Even though this PR doesn't fix all identified warnings, I'd review and merge it in its current state, as stuff's getting too hard to follow. |
IMHO all the commits need to include "Resolves:" or "Related:", otherwise it won't be possible to merge them downstream. |
70c9246
to
3302ab3
Compare
@jsynacek thanks for pointing it out, it completely slipped my mind. Should be fixed now. |
gmtime() and localtime() operate on a static buffer. let's avoid this, as we never know whether some library might use these calls in some backrgound thread. Discovered by lgtm: https://lgtm.com/projects/g/systemd/systemd/ (cherry picked from commit e46acb7) Resolves: #1694605
This makes OBJECT_PATH_FOREACH_PREFIX consistent with PATH_FOREACH_PREFIX and also fixes 7 alerts reported by LGTM at https://lgtm.com/projects/g/systemd/systemd/snapshot/ac0a08700344a5690803df8dd80e8bb5013184a5/files/src/libsystemd/sd-bus/bus-objects.c?sort=name&dir=ASC&mode=heatmap&showExcluded=true#V1383 (cherry picked from commit 283c265) Resolves: #1694605
LGMT complains: > The size argument of this snprintf call is derived from its return value, > which may exceed the size of the buffer and overflow. Let's make sure that r is non-negative. (This shouldn't occur unless the format string is borked, so let's just add an assert.) Then, let's reorder the comparison to avoid the potential overflow. (cherry picked from commit 91db8ed) Resolves: #1694605
Discovered by LGTM. (cherry picked from commit e681315) Resolves: #1694605
r is always >= 0 so let's drop the unnecessary condition to make LGTM happy Based on commit 7c3733d Resolves: #1694605
In this case ret is always >= 0 as it still contains the initialization value (i.e. 0). Let's drop the unnecessary condition to make LGTM happy. Relevant commit: efdb023 Resolves: #1694605
Relevant commit: d61b34f Resolves: #1694605
(cherry picked from commit 0a58733) Resolves: #1694605
Relevant commit: 29bfb68 Resolves: #1694605
ldp_receive_frame after correct processing of the packet the state should be LLDP_AGENT_RX_WAIT_FOR_FRAME not LLDP_AGENT_RX_UPDATE_INFO. (cherry picked from commit 9bb1bff) Resolves: #1694605
(cherry picked from commit affaed1) Resolves: #1694605
Suggested by LGTM: https://lgtm.com/rules/1506024027114/ (cherry picked from commit 845d247) Resolves: #1694605
Found by LGTM. Resolves: #1694605
We want to store either the first error or the total number of changes in 'r'. Instead, we were overwriting this with the return value from install_info_traverse(). LGTM complained later in the loop that: > Comparison is always true because r >= 0. Relevant commit: 459500a Resolves: #1694605
set_put() returns 0 if the key already exists, 1 if the entry was inserted successfully, and -ENOMEM otherwise. See: set_put(), hashmap_base_put_boldly() Found by LGTM. Resolves: #1694605
r could never be less than zero. CID #1271350. (cherry picked from commit 2558691) Resolves: #1694605
Suggested by LGTM. (cherry picked from commit c497e44) Resolves: #1694605
Discovered by LGTM. (cherry picked from commit 944072f) Resolves: #1694605
Resolves: #1694605
3fec580
to
3cb4e37
Compare
Even though LGTM is right is these cases, fixing it would require substantial refactoring in some cases, so it's better to leave them here (at least for RHEL 7). Resolves: #1694605 rhel-only
3cb4e37
to
d75397f
Compare
This pull request fixes 38 alerts when merging d75397f into dd004bc - view on LGTM.com fixed alerts:
Comment posted by LGTM.com |
Closed in favor of redhat-plumbers/systemd-rhel7#2 |
This PR attempts to fix errors & warnings found by LGTM. Recommendations are currently ignored, as it would make this PR unnecessarily big.
Note: some of these patches are not even in upstream (mostly because the particular code was completely rewritten in upstream).
Unresolved errors/warnings:
src/shared/pager.c
[link] - pager-related stuff has been significantly refactored in upstream, needs further investigation[ignored]src/libsystemd/sd-bus/bus-bloom.h
[link] - dropped from upstream along with kdbussrc/shared/strv.c
[link] -strv_join_quoted
was dropped from upstream (replaced by a different approach) without resolving this issue; would require some, possibly substantial, refactoring[ignored]src/bootchart/*
[link] - dropped from upstream (systemd/systemd@232c84b)src/core/execute.c
[link] -process_execute
has been refactored to support longer process names (systemd/systemd@9bfaffd), not sure if it's worth backporting[ignored]src/gudev/*
- dropped from upstream (systemd/systemd@2375607)src/shared/fw-util.c
[link] - renamed tosrc/shared/firewall-util.c
, however, not yet fixed in upstreamThe [ignored] rules should hopefully take effect once this PR is merged.