Re: [PATCH] rpc: fixing compilation error due to deprecated ssh_get_publickey().

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 05/04/2018 04:01 PM, Julio Faracco wrote:
IMHO:
- The first approach is simple to remove in the future.

No, both approaches are equally easy to trim down in the future (true, the second approach leaves a temporary variable that could possibly be deleted, but it's not a prerequisite to remove the temporary variable when trimming the ifdefs).

- The second one is easy to read and understand.

Furthermore, the second one does not have unbalanced { vs. }, which makes it better for some editors.

+#if LIBSSH_VERSION_INT > 0x0705 /* 0.7.5 */
+    if (ssh_get_server_publickey(sess->session, &key) != SSH_OK) {
+#else
      if (ssh_get_publickey(sess->session, &key) != SSH_OK) {
+#endif
          virReportError(VIR_ERR_LIBSSH, "%s",
                         _("failed to get the key of the current "
                           "session"));

How about making it easier to read and harder to mess up:

     #if LIBSSH_VERSION_INT > 0x0705 /* 0.7.5 */
         rc = ssh_get_server_publickey(sess->session, &key);
     #else
         rc = ssh_get_publickey(sess->session, &key);
     #endif

     if (rc != SSH_OK) {
         ...
     }

Furthermore, top-posting on technical lists is harder to read.

If you want a third approach, there is:

#if LIBSSH_VERSION_INT <= 0x0705 /* 0.7.5 */
# define ssh_get_server_publickey ssh_get_publickey
#endif

    if (ssh_get_server_publickey(sess->session, &key) != SSH_OK) {
        virReportError(...

--
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux