D27871: sftp: fix seekPos + file resuming when part file is of size 11

Stefan BrĂ¼ns noreply at phabricator.kde.org
Mon Mar 9 17:17:12 GMT 2020


bruns added inline comments.

INLINE COMMENTS

> sitter wrote in kio_sftp.cpp:1687
> Oh, I'm sorry. My reading comprehension isn't so good. I am not sure what you are asking of me though. errno access in qdebug streaming is used all over our software and this line here isn't even new. If the errno access wasn't a problem before, why is it now? And what does it have to do with the fix this diff has? Why don't you just do something about the errno problems?

Essentially, apply the change from the man page example to the code here:

  if (pos != sbPart->size) {
      int errsv = errno;
      qCDebug(KIO_SFTP_LOG) << "Failed to seek to" << sbPart->size << "bytes in source file. Reason given:" << strerror(errsv);
  }

As the errno value is now held in a local variable (and thus the global/thread-local errno does not matter), no function called from qCDebug() is able to mess with the value. qCDebug() *may* call all kind of functions (remember, it may log to the terminal, to the system journal, ...) which may fail in a non-fatal way ("if this does not work, try that"), overwriting errno in the course.

Making assumptions about errno can lead to some surprises, and while it may work most of the time it is better to be save than sorry.

REPOSITORY
  R320 KIO Extras

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

To: sitter, ngraham, feverfew
Cc: bruns, kde-frameworks-devel, kfm-devel, pberestov, iasensio, fprice, LeGast00n, cblack, MrPepe, fbampaloukas, alexde, GB_2, Codezela, feverfew, meven, michaelh, spoorun, navarromorales, firef, ngraham, andrebarros, emmanuelp, mikesomov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.kde.org/mailman/private/kfm-devel/attachments/20200309/a4619206/attachment.htm>


More information about the kfm-devel mailing list