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

John Ferlan jferlan at redhat.com
Tue May 8 21:46:17 UTC 2018



On 05/06/2018 03:15 PM, Julio Faracco wrote:
> Well,
> 
> Do we have a winner? :-)
> 
> --
> Julio Cesar Faracco
> 


sigh, top posting is not favored in technical groups.

In any case, I kind of like Eric's suggestion and I just figured you'd
end up coding it and posting it.

John

> 2018-05-04 18:23 GMT-03:00 Eric Blake <eblake at redhat.com>:
>> 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 at redhat.com
> https://www.redhat.com/mailman/listinfo/libvir-list
> 




More information about the libvir-list mailing list