From a7245651f2b0c57ceb3e721ed2769117c454d13f Mon Sep 17 00:00:00 2001 From: Mitchell Livingston Date: Mon, 21 Dec 2009 22:03:19 +0000 Subject: [PATCH] avoid an extra comparison caused by macro expansion --- libtransmission/fdlimit.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libtransmission/fdlimit.c b/libtransmission/fdlimit.c index 10c4456a4..974de8af7 100644 --- a/libtransmission/fdlimit.c +++ b/libtransmission/fdlimit.c @@ -832,7 +832,8 @@ tr_fdSetPeerLimit( tr_session * session, int socketLimit ) const int NOFILE_BUFFER = 512; const int open_max = sysconf( _SC_OPEN_MAX ); getrlimit( RLIMIT_NOFILE, &rlim ); - rlim.rlim_cur = MIN( MAX( 1024, open_max ), rlim.rlim_max ); + rlim.rlim_cur = MAX( 1024, open_max ); + rlim.rlim_cur = MIN( rlim.rlim_cur, rlim.rlim_max ); setrlimit( RLIMIT_NOFILE, &rlim ); tr_dbg( "setrlimit( RLIMIT_NOFILE, %d )", (int)rlim.rlim_cur ); gFd->socketLimit = MIN( socketLimit, (int)rlim.rlim_cur - NOFILE_BUFFER );