D20008: Fix uninitialized value in SimpleJobPrivate

Michael Pyne noreply at phabricator.kde.org
Sat Mar 23 23:05:37 GMT 2019


mpyne created this revision.
mpyne added reviewers: dfaure, Frameworks, apol.
Herald added a project: Frameworks.
Herald added a subscriber: kde-frameworks-devel.
mpyne requested review of this revision.

REVISION SUMMARY
  As reported in bug 404474 <https://bugs.kde.org/show_bug.cgi?id=404474>, GCC gives a warning about using an uninitialized value in KIO.
  
  The relevant portion of code is:
  
    FileOperationType opType;
    switch (command) {
    case CMD_DEL:
        opType = Delete;
        break;
    case CMD_RENAME:
        opType = Rename;
        break;
    case CMD_SYMLINK:
        opType = Symlink;
        break;
    }
    job->d_func()->m_operationType = opType;
     
  
  `command` in this case is an `int` and there's no other checks here to let the compiler know that `command` could only be one of those three values. There's a comment here but even I don't know whether the comment discusses what *should* be true or what *is* actually checked elsewhere.
  
  Since even I was confused I don't blame the compiler. So I add a default branch that just returns the job unmodified. There may be a better error condition here.

TEST PLAN
  Builds, installs, KIO-using software works fine still.

REPOSITORY
  R241 KIO

REVISION DETAIL
  https://phabricator.kde.org/D20008

AFFECTED FILES
  src/core/job_p.h

To: mpyne, dfaure, #frameworks, apol
Cc: kde-frameworks-devel, michaelh, ngraham, bruns
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-frameworks-devel/attachments/20190323/ae2410c8/attachment-0001.html>


More information about the Kde-frameworks-devel mailing list