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

Re: [Nbd] [PATCH 2/2] nbd-server: narrow the scope of a function-local variable



Thanks, both applied.

(I can't run "make check" right now, because the automake people broke
the way "make check" is being called for some weird reason. I'll have to
fix that later, but both seem straightforward enough, so...)

On 01-06-13 20:20, Tuomas Räsänen wrote:
> It's better to keep variables strictly inside their usage scope than in
> more wider scope to avoid unintentional variable shadowing and leaking.
> 
> Signed-off-by: Tuomas Räsänen <tuomasjjrasanen@...1261...>
> ---
>  nbd-server.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/nbd-server.c b/nbd-server.c
> index f3c78bd..392ed9f 100644
> --- a/nbd-server.c
> +++ b/nbd-server.c
> @@ -2365,7 +2365,6 @@ void serveloop(GArray* servers) {
>  	socklen_t addrinlen=sizeof(addrin);
>  	int i;
>  	int max;
> -	int sock;
>  	fd_set mset;
>  	fd_set rset;
>  
> @@ -2379,6 +2378,7 @@ void serveloop(GArray* servers) {
>  	max=0;
>  	FD_ZERO(&mset);
>  	for(i=0;i<servers->len;i++) {
> +		int sock;
>  		if((sock=(g_array_index(servers, SERVER, i)).socket) >= 0) {
>  			FD_SET(sock, &mset);
>  			max=sock>max?sock:max;
> 

-- 
This end should point toward the ground if you want to go to space.

If it starts pointing toward space you are having a bad problem and you
will not go to space today.

  -- http://xkcd.com/1133/



Reply to: