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

Harald Sitter noreply at phabricator.kde.org
Fri Mar 6 17:42:22 GMT 2020


sitter added inline comments.

INLINE COMMENTS

> bruns wrote in kio_sftp.cpp:1687
> You should save errno immediately after QT_LSEEK, otherwise any function may overwrite it. See `man 3 errno`:
> 
> > A common mistake is to do
> > 
> >   if (somecall() == -1) {
> >       printf("somecall() failed\n");
> >       if (errno == ...) { ... }
> >   }
> >    
> > 
> > where errno no longer needs to have the value it had upon return from somecall() (i.e., it may have been changed by the printf(3)).  If the value of errno should be preserved across a library call, it must be saved:
> > 
> >   if (somecall() == -1) {
> >       int errsv = errno;
> >       printf("somecall() failed\n");
> >       if (errsv == ...) { ... }
> >   }
> >

Which call between the seek and the debug do you take offense here exactly?

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: <http://mail.kde.org/pipermail/kde-frameworks-devel/attachments/20200306/fe86643b/attachment.html>


More information about the Kde-frameworks-devel mailing list