You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The fix correctly addresses the COPY_INSTEAD_OF_MOVE Coverity defect by applying std::move() to local string variables at the point where they are assigned to their final destinations. All four changes are valid: (1) wifiIfname, ethIfname, and deviceHostname in getDeviceProperties() are local variables that are no longer used after the move assignments, and the subsequent NMLOG_INFO correctly reads from the destination members (m_wlanifname, m_ethifname, m_deviceHostname) rather than the moved-from sources; (2) line in readPersistentHostname() is a local variable not used after the move assignment to hostname, and the subsequent NMLOG_INFO correctly reads from hostname; (3) hwAddr in resolveGatewayMac() is a local variable not used after the move assignment to mac, and the subsequent NMLOG_INFO correctly reads from mac. No new defects are introduced, no logic is broken, no unnecessary abstractions are added, and the changes are minimal and targeted.
plugin/NetworkManagerConnectivity.cpp
The fix correctly applies std::move() to three local std::string variables (interface/defaultIface) that are passed by value to functions and not used after the call. All three changes are correct: (1) moving 'interface' into checkCurlResponse() in the TestConnectivity constructor where it's the last use, (2) moving 'defaultIface' into ReportInternetStatusChange() where it's the last use, and (3) moving 'defaultIface' into the TestConnectivity constructor in the ideal-case branch where it's not used afterward. The m_switchToInitial branch correctly retains a copy since defaultIface is used again after the TestConnectivity construction. No logic is broken and no new defects are introduced.
plugin/gnome/NetworkManagerGnomeProxy.cpp
All four std::move() additions correctly address COPY_INSTEAD_OF_MOVE defects. The moved variables are not accessed after the move in each case. The fix on line 595 applies std::move() to a const string, which is technically a no-op for move semantics (the copy constructor will still be invoked), but this does not introduce any new defect or break any logic — it simply fails to optimize that particular case. All other changes are effective and correct.
plugin/gnome/gdbus/NetworkManagerGdbusUtils.cpp
The fix correctly addresses the COPY_INSTEAD_OF_MOVE defect by replacing hostname = line with hostname = std::move(line) at line 755. After the two erase operations, line is a fully processed local string that is no longer needed — moving it into hostname avoids an unnecessary heap allocation and copy. The moved-from line is not accessed after the assignment; hostname.c_str() is used in the subsequent log call, which is correct. The change is minimal (one line), introduces no new defects, preserves all existing logic and return values, and is the canonical fix for this defect type.
plugin/gnome/NetworkManagerGnomeEvents.cpp
The fix correctly applies std::move() to local string variables at their last point of use before being passed to functions that take by value. All six changes are verified: the moved variables are not accessed after the move in any execution path, the if/else branches are correctly analyzed (notably the addrString move in the isIPv6LinkLocal branch does not affect the else-if/else branches), and no new defects are introduced. The fix is minimal and directly addresses the COPY_INSTEAD_OF_MOVE defect.
plugin/NetworkManagerStunClient.cpp
The fix correctly addresses the COPY_INSTEAD_OF_MOVE defect. In the original code, s was declared as std::string const s, which prevented it from being moved. The fix removes the const qualifier (making s a non-const std::string) and then uses std::move(s) when inserting into already_seen. This is the correct and minimal fix: s is used first in already_seen.find(s) (which requires a valid string), and only after that check passes and the address is processed does std::move(s) transfer ownership into the set, avoiding an unnecessary copy. The variable s is not used after the move, so there is no use-after-move issue. The indentation differences in the diff are cosmetic and noted as already verified by clang-format. No new defects are introduced, existing logic is fully preserved, and the change is minimal and targeted.
The reason will be displayed to describe this comment to others. Learn more.
🟢 Approval recommended
The changes resolve the targeted Coverity findings without behavioral issues; only a minor indentation nit remains.
No open issues 🎉
1 previously missed issue
In code that hasn't changed since last review
Fix over-indented declaration in loop body
plugin/NetworkManagerStunClient.cpp:217
This new declaration is indented four spaces deeper than the surrounding loop body (the preceding if is at six spaces), so the change does not follow the indentation used throughout this file. Align it with the other statements in the loop.
This issue also appears on line 233 of the same file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Automated Fix for Coverity Defects
Triggered by: Gururaja ErodeSriranganRamlingham
Fixed Files
plugin/gnome/NetworkManagerGnomeUtils.cppplugin/NetworkManagerConnectivity.cppplugin/gnome/NetworkManagerGnomeProxy.cppplugin/gnome/gdbus/NetworkManagerGdbusUtils.cppplugin/gnome/NetworkManagerGnomeEvents.cppplugin/NetworkManagerStunClient.cppFix Summaries
plugin/gnome/NetworkManagerGnomeUtils.cppThe fix correctly addresses the COPY_INSTEAD_OF_MOVE Coverity defect by applying std::move() to local string variables at the point where they are assigned to their final destinations. All four changes are valid: (1) wifiIfname, ethIfname, and deviceHostname in getDeviceProperties() are local variables that are no longer used after the move assignments, and the subsequent NMLOG_INFO correctly reads from the destination members (m_wlanifname, m_ethifname, m_deviceHostname) rather than the moved-from sources; (2) line in readPersistentHostname() is a local variable not used after the move assignment to hostname, and the subsequent NMLOG_INFO correctly reads from hostname; (3) hwAddr in resolveGatewayMac() is a local variable not used after the move assignment to mac, and the subsequent NMLOG_INFO correctly reads from mac. No new defects are introduced, no logic is broken, no unnecessary abstractions are added, and the changes are minimal and targeted.
plugin/NetworkManagerConnectivity.cppThe fix correctly applies std::move() to three local std::string variables (interface/defaultIface) that are passed by value to functions and not used after the call. All three changes are correct: (1) moving 'interface' into checkCurlResponse() in the TestConnectivity constructor where it's the last use, (2) moving 'defaultIface' into ReportInternetStatusChange() where it's the last use, and (3) moving 'defaultIface' into the TestConnectivity constructor in the ideal-case branch where it's not used afterward. The m_switchToInitial branch correctly retains a copy since defaultIface is used again after the TestConnectivity construction. No logic is broken and no new defects are introduced.
plugin/gnome/NetworkManagerGnomeProxy.cppAll four std::move() additions correctly address COPY_INSTEAD_OF_MOVE defects. The moved variables are not accessed after the move in each case. The fix on line 595 applies std::move() to a const string, which is technically a no-op for move semantics (the copy constructor will still be invoked), but this does not introduce any new defect or break any logic — it simply fails to optimize that particular case. All other changes are effective and correct.
plugin/gnome/gdbus/NetworkManagerGdbusUtils.cppThe fix correctly addresses the COPY_INSTEAD_OF_MOVE defect by replacing
hostname = linewithhostname = std::move(line)at line 755. After the twoeraseoperations,lineis a fully processed local string that is no longer needed — moving it intohostnameavoids an unnecessary heap allocation and copy. The moved-fromlineis not accessed after the assignment;hostname.c_str()is used in the subsequent log call, which is correct. The change is minimal (one line), introduces no new defects, preserves all existing logic and return values, and is the canonical fix for this defect type.plugin/gnome/NetworkManagerGnomeEvents.cppThe fix correctly applies std::move() to local string variables at their last point of use before being passed to functions that take by value. All six changes are verified: the moved variables are not accessed after the move in any execution path, the if/else branches are correctly analyzed (notably the addrString move in the isIPv6LinkLocal branch does not affect the else-if/else branches), and no new defects are introduced. The fix is minimal and directly addresses the COPY_INSTEAD_OF_MOVE defect.
plugin/NetworkManagerStunClient.cppThe fix correctly addresses the COPY_INSTEAD_OF_MOVE defect. In the original code,
swas declared asstd::string const s, which prevented it from being moved. The fix removes theconstqualifier (makingsa non-conststd::string) and then usesstd::move(s)when inserting intoalready_seen. This is the correct and minimal fix:sis used first inalready_seen.find(s)(which requires a valid string), and only after that check passes and the address is processed doesstd::move(s)transfer ownership into the set, avoiding an unnecessary copy. The variablesis not used after the move, so there is no use-after-move issue. The indentation differences in the diff are cosmetic and noted as already verified by clang-format. No new defects are introduced, existing logic is fully preserved, and the change is minimal and targeted.