From fc003d4dc3b1b86bfaf7720bfc3fd6f2bf94b17a Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Thu, 4 May 2023 11:31:40 +0000 Subject: [PATCH] tidy-up: formatting nits Whitespace and redundant parenthesis in `return`s. Closes #1029 --- example/x11.c | 2 +- src/channel.c | 2 +- src/crypto.c | 1 - src/knownhost.c | 2 +- src/misc.c | 2 +- src/openssl.c | 2 +- src/sftp.c | 16 ++++++++-------- vms/man2help.c | 18 +++++++++--------- 8 files changed, 22 insertions(+), 23 deletions(-) diff --git a/example/x11.c b/example/x11.c index b16a0f88..8be003fb 100644 --- a/example/x11.c +++ b/example/x11.c @@ -436,7 +436,7 @@ int main(int argc, char *argv[]) fds[0].revents = LIBSSH2_POLLFD_POLLIN; rc = libssh2_poll(fds, nfds, 0); - if(rc >0) { + if(rc > 0) { libssh2_channel_read(channel, buf, sizeof(buf)); fprintf(stdout, "%s", buf); fflush(stdout); diff --git a/src/channel.c b/src/channel.c index 06a6acae..f55d1bb6 100644 --- a/src/channel.c +++ b/src/channel.c @@ -2314,7 +2314,7 @@ _libssh2_channel_packet_data_len(LIBSSH2_CHANNEL * channel, int stream_id) && (channel->local.id == read_local_id) && (channel->remote.extended_data_ignore_mode == LIBSSH2_CHANNEL_EXTENDED_DATA_MERGE))) { - return (read_packet->data_len - read_packet->data_head); + return read_packet->data_len - read_packet->data_head; } read_packet = next_packet; diff --git a/src/crypto.c b/src/crypto.c index 68db0f2a..b91dc37a 100644 --- a/src/crypto.c +++ b/src/crypto.c @@ -1,5 +1,4 @@ #define LIBSSH2_CRYPTO_C - #include "libssh2_priv.h" #if defined(LIBSSH2_OPENSSL) || defined(LIBSSH2_WOLFSSL) diff --git a/src/knownhost.c b/src/knownhost.c index 78df1613..59bc2161 100644 --- a/src/knownhost.c +++ b/src/knownhost.c @@ -821,7 +821,7 @@ static int hostline(LIBSSH2_KNOWNHOSTS *hosts, } /* Figure out host format */ - if((hostlen >2) && memcmp(host, "|1|", 3)) { + if((hostlen > 2) && memcmp(host, "|1|", 3)) { /* old style plain text: [name]([,][name])* for the sake of simplicity, we add them as separate hosts with the diff --git a/src/misc.c b/src/misc.c index 10864b8b..62497197 100644 --- a/src/misc.c +++ b/src/misc.c @@ -935,7 +935,7 @@ int _libssh2_check_length(struct string_buf *buf, size_t len) { unsigned char *endp = &buf->data[buf->len]; size_t left = endp - buf->dataptr; - return ((len <= left) && (left <= buf->len)); + return (len <= left) && (left <= buf->len); } int _libssh2_eob(struct string_buf *buf) diff --git a/src/openssl.c b/src/openssl.c index a4036f70..ee61c5b1 100644 --- a/src/openssl.c +++ b/src/openssl.c @@ -3280,7 +3280,7 @@ clean_exit: if(md_ctx) EVP_MD_CTX_free(md_ctx); - return (rc == 1 ? 0 : -1); + return (rc == 1) ? 0 : -1; } int diff --git a/src/sftp.c b/src/sftp.c index 34d3c06b..27c09918 100644 --- a/src/sftp.c +++ b/src/sftp.c @@ -632,11 +632,11 @@ sftp_packet_requirev(LIBSSH2_SFTP *sftp, int num_valid_responses, */ static int sftp_attrsize(unsigned long flags) { - return (4 + /* flags(4) */ - ((flags & LIBSSH2_SFTP_ATTR_SIZE) ? 8 : 0) + - ((flags & LIBSSH2_SFTP_ATTR_UIDGID) ? 8 : 0) + - ((flags & LIBSSH2_SFTP_ATTR_PERMISSIONS) ? 4 : 0) + - ((flags & LIBSSH2_SFTP_ATTR_ACMODTIME) ? 8 : 0)); + return 4 + /* flags(4) */ + ((flags & LIBSSH2_SFTP_ATTR_SIZE) ? 8 : 0) + + ((flags & LIBSSH2_SFTP_ATTR_UIDGID) ? 8 : 0) + + ((flags & LIBSSH2_SFTP_ATTR_PERMISSIONS) ? 4 : 0) + + ((flags & LIBSSH2_SFTP_ATTR_ACMODTIME) ? 8 : 0); /* atime + mtime as u32 */ } @@ -681,7 +681,7 @@ sftp_attr2bin(unsigned char *p, const LIBSSH2_SFTP_ATTRIBUTES * attrs) _libssh2_store_u32(&s, (uint32_t)attrs->mtime); } - return (s - p); + return s - p; } /* sftp_bin2attr @@ -758,7 +758,7 @@ sftp_bin2attr(LIBSSH2_SFTP_ATTRIBUTES *attrs, const unsigned char *p, } } - return (buf.dataptr - buf.data); + return buf.dataptr - buf.data; } /* ************ @@ -1875,7 +1875,7 @@ static ssize_t sftp_readdir(LIBSSH2_SFTP_HANDLE *handle, char *buffer, goto end; } - if(longentry && (longentry_maxlen>1)) { + if(longentry && (longentry_maxlen > 1)) { longentry_len = real_longentry_len; if(longentry_len >= longentry_maxlen || diff --git a/vms/man2help.c b/vms/man2help.c index 71f12584..49ef10d2 100644 --- a/vms/man2help.c +++ b/vms/man2help.c @@ -68,14 +68,14 @@ pf->dnam.naml$l_long_defname = NULL; //inputfile; pf->dnam.naml$l_long_defname_size = 0;//strlen( inputfile ); pf->dnam.naml$l_long_filename = inputfile; -pf->dnam.naml$l_long_filename_size = strlen( inputfile); +pf->dnam.naml$l_long_filename_size = strlen( inputfile ); pf->dnam.naml$l_long_expand = pf->expanded_filename; pf->dnam.naml$l_long_expand_alloc = NAM$C_MAXRSS ; pf->dnam.naml$b_nop |= NAML$M_SYNCHK | NAML$M_PWD; -status = sys$parse( &pf->dfab, 0,0); +status = sys$parse( &pf->dfab, 0, 0 ); if ( !(status&1) ){ free( pf ); return( status ); @@ -137,7 +137,7 @@ manPtr addman( manPtr *manroot,char *filename ) { manPtr m,f; -m = calloc( 1, sizeof( man) ); +m = calloc( 1, sizeof( man ) ); if ( !m ) return( NULL ); m->filename = strdup( filename ); @@ -159,7 +159,7 @@ manPtr m,n; for( m = *manroot; m ; m = n ){ free( m->filename ); n = m->next; - free ( m ); + free( m ); } *manroot = NULL; } @@ -180,11 +180,11 @@ while(1){ r = addman( manroot, gevonden ); if ( r == NULL ) return(2); }else{ - if ( !( status&1)) break; + if ( !( status&1 ) ) break; } } -lib$find_file_end( &ffindex); +lib$find_file_end( &ffindex ); if ( status == RMS$_NMF) status = 1; @@ -207,14 +207,14 @@ uit = calloc( 1, maxlen + 1 ); if ( in == NULL || uit == NULL ) return(2); -man = fopen( filespec, "r"); +man = fopen( filespec, "r" ); if ( man == NULL ) return(vaxc$errno); for( len = 0; !feof( man ) && len < maxlen ; len += thislen ){ thislen = fread( in + len, 1, maxlen - len, man ); } -fclose (man); +fclose(man); m = in; h = uit; @@ -404,7 +404,7 @@ if ( (return_status&2) ){ free( m ); free( h ); -return ( 1); +return ( 1 ); } /*--------------------------------------------*/