diff --git a/src/common/ioutil.c b/src/common/ioutil.c index 6dbc3c5..6a8309a 100644 --- a/src/common/ioutil.c +++ b/src/common/ioutil.c @@ -31,8 +31,6 @@ int build_allocation_map(struct bitset * allocation_map, int fd) for (offset = 0; offset < allocation_map->size; ) { - unsigned int i; - fiemap->fm_start = offset; fiemap->fm_length = max_length; @@ -49,7 +47,7 @@ int build_allocation_map(struct bitset * allocation_map, int fd) return 0; /* it's up to the caller to free the map */ } else { - for ( i = 0; i < fiemap->fm_mapped_extents; i++ ) { + for ( unsigned int i = 0; i < fiemap->fm_mapped_extents; i++ ) { bitset_set_range( allocation_map, fiemap->fm_extents[i].fe_logical, fiemap->fm_extents[i].fe_length ); diff --git a/src/common/self_pipe.c b/src/common/self_pipe.c index 12bc3f2..0999b11 100644 --- a/src/common/self_pipe.c +++ b/src/common/self_pipe.c @@ -51,7 +51,6 @@ struct self_pipe * self_pipe_create(void) { struct self_pipe *sig = xmalloc( sizeof( struct self_pipe ) ); int fds[2]; - int fcntl_err; if ( NULL == sig ) { return NULL; } @@ -62,7 +61,7 @@ struct self_pipe * self_pipe_create(void) } if ( fcntl( fds[0], F_SETFL, O_NONBLOCK ) || fcntl( fds[1], F_SETFL, O_NONBLOCK ) ) { - fcntl_err = errno; + int fcntl_err = errno; while( close( fds[0] ) == -1 && errno == EINTR ); while( close( fds[1] ) == -1 && errno == EINTR ); free( sig ); diff --git a/src/common/serve.c b/src/common/serve.c index 93e6014..649bd5e 100644 --- a/src/common/serve.c +++ b/src/common/serve.c @@ -233,7 +233,6 @@ int tryjoin_client_thread( struct client_tbl_entry *entry, int (*joinfunc)(pthre int was_closed = 0; void * status=NULL; - int join_errno; if (entry->thread != 0) { char s_client_address[128]; @@ -241,7 +240,7 @@ int tryjoin_client_thread( struct client_tbl_entry *entry, int (*joinfunc)(pthre sockaddr_address_string( &entry->address.generic, &s_client_address[0], 128 ); debug( "%s(%p,...)", joinfunc == pthread_join ? "joining" : "tryjoining", entry->thread ); - join_errno = joinfunc(entry->thread, &status); + int join_errno = joinfunc(entry->thread, &status); /* join_errno can legitimately be ESRCH if the thread is * already dead, but the client still needs tidying up. */ @@ -598,7 +597,6 @@ int server_accept( struct server * params ) { NULLCHECK( params ); debug("accept loop starting"); - int client_fd; union mysockaddr client_address; fd_set fds; socklen_t socklen=sizeof(client_address); @@ -638,7 +636,7 @@ int server_accept( struct server * params ) } if ( FD_ISSET( params->server_fd, &fds ) ){ - client_fd = accept( params->server_fd, &client_address.generic, &socklen ); + int client_fd = accept( params->server_fd, &client_address.generic, &socklen ); if ( params->allow_new_clients ) { debug("Accepted nbd client socket fd %d", client_fd); @@ -741,11 +739,11 @@ void server_join_clients( struct server * serve ) { for (i=0; i < serve->max_nbd_clients; i++) { pthread_t thread_id = serve->nbd_client[i].thread; - int err = 0; if (thread_id != 0) { debug( "joining thread %p", thread_id ); - if ( 0 == (err = pthread_join( thread_id, &status ) ) ) { + int err = pthread_join( thread_id, &status ); + if ( 0 == err ) { serve->nbd_client[i].thread = 0; } else { warn( "Error %s (%i) joining thread %p", strerror( err ), err, thread_id ); diff --git a/src/common/sockutil.c b/src/common/sockutil.c index 001f3a3..1377958 100644 --- a/src/common/sockutil.c +++ b/src/common/sockutil.c @@ -39,7 +39,6 @@ const char* sockaddr_address_string( const struct sockaddr* sa, char* dest, size struct sockaddr_un* un = ( struct sockaddr_un* ) sa; unsigned short real_port = ntohs( in->sin_port ); // common to in and in6 - size_t size; const char* ret = NULL; memset( dest, 0, len ); @@ -57,7 +56,7 @@ const char* sockaddr_address_string( const struct sockaddr* sa, char* dest, size } if ( NULL != ret && real_port > 0 && sa->sa_family != AF_UNIX ) { - size = strlen( dest ); + size_t size = strlen( dest ); snprintf( dest + size, len - size, " port %d", real_port ); }