D4769: Try to get the real port instead of always use DEFAULT_SFTP_PORT

David Faure noreply at phabricator.kde.org
Fri Mar 3 11:56:33 UTC 2017


dfaure accepted this revision.
dfaure added a comment.
This revision is now accepted and ready to land.


  Looks good - just a minor nitpick on coding style / readability, feel free to push (either way, actually).

INLINE COMMENTS

> kio_sftp.cpp:605
>  
> +  unsigned int effectivePort = DEFAULT_SFTP_PORT;
> +  if (mPort > 0) {

This is a bit confusing when reading : first it's initialized to a value...

> kio_sftp.cpp:607
> +  if (mPort > 0) {
> +      effectivePort = mPort;
> +  } else {

... and here another one is assigned, making the initialization useless.

I would find this more readable:

  unsigned int effectivePort;
  if (mPort > 0) {
      effectivePort = mPort;
  } else {
      effectivePort = DEFAULT_SFTP_PORT;
      ssh_options_get_port(mSession, &effectivePort);
  }

This encapsulates the ugly C API with a nasty output parameter in the second block only ;)

REPOSITORY
  R320 KIO Extras

BRANCH
  master

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

To: xuetianweng, #frameworks, apol, dfaure
Cc: dfaure
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-frameworks-devel/attachments/20170303/620e00bf/attachment.html>


More information about the Kde-frameworks-devel mailing list