Fix uninitialized value in SimpleJobPrivate
ClosedPublic

Authored by mpyne on Mar 23 2019, 11:05 PM.

Details

Summary

As reported in bug 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.

Diff Detail

Repository
R241 KIO
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
mpyne created this revision.Mar 23 2019, 11:05 PM
Restricted Application added a project: Frameworks. · View Herald TranscriptMar 23 2019, 11:05 PM
Restricted Application added a subscriber: kde-frameworks-devel. · View Herald Transcript
mpyne requested review of this revision.Mar 23 2019, 11:05 PM
dfaure accepted this revision.Mar 23 2019, 11:18 PM

The patch is OK, but the commit message is scarier than the truth. There is no actual use of an uninitialized value in practice. Please add "compiler warning" to the commit log.

This revision is now accepted and ready to land.Mar 23 2019, 11:18 PM
This revision was automatically updated to reflect the committed changes.