diff mbox

ssh: Remove unnecessary use of strlen function.

Message ID 1366319373-12926-1-git-send-email-rjones@redhat.com
State New
Headers show

Commit Message

Richard W.M. Jones April 18, 2013, 9:09 p.m. UTC
From: "Richard W.M. Jones" <rjones@redhat.com>

---
 block/ssh.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

Comments

Eric Blake April 18, 2013, 9:24 p.m. UTC | #1
On 04/18/2013 03:09 PM, Richard W.M. Jones wrote:
> From: "Richard W.M. Jones" <rjones@redhat.com>
> 
> ---
>  block/ssh.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)

Reviewed-by: Eric Blake <eblake@redhat.com>
Stefan Weil April 19, 2013, 4:07 a.m. UTC | #2
Am 18.04.2013 23:09, schrieb Richard W.M. Jones:
> From: "Richard W.M. Jones" <rjones@redhat.com>
>
> ---
>  block/ssh.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/block/ssh.c b/block/ssh.c
> index 8f78e2e..7bc008d 100644
> --- a/block/ssh.c
> +++ b/block/ssh.c
> @@ -387,15 +387,13 @@ static int check_host_key(BDRVSSHState *s, const char *host, int port,
>      }
>  
>      /* host_key_check=md5:xx:yy:zz:... */
> -    if (strlen(host_key_check) >= 4 &&
> -        strncmp(host_key_check, "md5:", 4) == 0) {
> +    if (strncmp(host_key_check, "md5:", 4) == 0) {
>          return check_host_key_hash(s, &host_key_check[4],
>                                     LIBSSH2_HOSTKEY_HASH_MD5, 16);
>      }
>  
>      /* host_key_check=sha1:xx:yy:zz:... */
> -    if (strlen(host_key_check) >= 5 &&
> -        strncmp(host_key_check, "sha1:", 5) == 0) {
> +    if (strncmp(host_key_check, "sha1:", 5) == 0) {
>          return check_host_key_hash(s, &host_key_check[5],
>                                     LIBSSH2_HOSTKEY_HASH_SHA1, 20);
>      }


Reviewed-by: Stefan Weil <sw@weilnetz.de>
Stefan Hajnoczi April 19, 2013, 9:45 a.m. UTC | #3
On Thu, Apr 18, 2013 at 10:09:33PM +0100, Richard W.M. Jones wrote:
> From: "Richard W.M. Jones" <rjones@redhat.com>
> 
> ---
>  block/ssh.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)

Thanks, applied to the trivial patches tree:
https://github.com/stefanha/qemu/commits/trivial-patches

Stefan
diff mbox

Patch

diff --git a/block/ssh.c b/block/ssh.c
index 8f78e2e..7bc008d 100644
--- a/block/ssh.c
+++ b/block/ssh.c
@@ -387,15 +387,13 @@  static int check_host_key(BDRVSSHState *s, const char *host, int port,
     }
 
     /* host_key_check=md5:xx:yy:zz:... */
-    if (strlen(host_key_check) >= 4 &&
-        strncmp(host_key_check, "md5:", 4) == 0) {
+    if (strncmp(host_key_check, "md5:", 4) == 0) {
         return check_host_key_hash(s, &host_key_check[4],
                                    LIBSSH2_HOSTKEY_HASH_MD5, 16);
     }
 
     /* host_key_check=sha1:xx:yy:zz:... */
-    if (strlen(host_key_check) >= 5 &&
-        strncmp(host_key_check, "sha1:", 5) == 0) {
+    if (strncmp(host_key_check, "sha1:", 5) == 0) {
         return check_host_key_hash(s, &host_key_check[5],
                                    LIBSSH2_HOSTKEY_HASH_SHA1, 20);
     }