From owner-svn-src-all@FreeBSD.ORG Tue Feb 17 16:01:01 2015 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id EE8888C5; Tue, 17 Feb 2015 16:01:01 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D9D4B94E; Tue, 17 Feb 2015 16:01:01 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t1HG11Ss089338; Tue, 17 Feb 2015 16:01:01 GMT (envelope-from pfg@FreeBSD.org) Received: (from pfg@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t1HG11pU089337; Tue, 17 Feb 2015 16:01:01 GMT (envelope-from pfg@FreeBSD.org) Message-Id: <201502171601.t1HG11pU089337@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: pfg set sender to pfg@FreeBSD.org using -f From: "Pedro F. Giffuni" Date: Tue, 17 Feb 2015 16:01:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r278905 - head/lib/libc/gen X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Feb 2015 16:01:02 -0000 Author: pfg Date: Tue Feb 17 16:01:00 2015 New Revision: 278905 URL: https://svnweb.freebsd.org/changeset/base/278905 Log: ulimit(3): simplify. rlim_t is at least as large as long, so we don't need the extra variable to keep the intermediate step. We don't need the volatile either. The code was tested on i386 and amd64. Suggested by: bde X-MFC with: r278803 Modified: head/lib/libc/gen/ulimit.c Modified: head/lib/libc/gen/ulimit.c ============================================================================== --- head/lib/libc/gen/ulimit.c Tue Feb 17 15:19:58 2015 (r278904) +++ head/lib/libc/gen/ulimit.c Tue Feb 17 16:01:00 2015 (r278905) @@ -33,7 +33,6 @@ #include #include #include -#include #include long @@ -41,8 +40,7 @@ ulimit(int cmd, ...) { struct rlimit limit; va_list ap; - volatile intmax_t targ; - long arg; + rlim_t arg; if (cmd == UL_GETFSIZE) { if (getrlimit(RLIMIT_FSIZE, &limit) == -1) @@ -53,18 +51,18 @@ ulimit(int cmd, ...) return ((long)limit.rlim_cur); } else if (cmd == UL_SETFSIZE) { va_start(ap, cmd); - targ = arg = va_arg(ap, long); + arg = va_arg(ap, long); va_end(ap); - if (targ < 0) - targ = LONG_MAX; - if (targ > RLIM_INFINITY / 512) - targ = RLIM_INFINITY / 512; - limit.rlim_max = limit.rlim_cur = targ * 512; + if (arg < 0) + arg = LONG_MAX; + if (arg > RLIM_INFINITY / 512) + arg = RLIM_INFINITY / 512; + limit.rlim_max = limit.rlim_cur = arg * 512; /* The setrlimit() function sets errno to EPERM if needed. */ if (setrlimit(RLIMIT_FSIZE, &limit) == -1) return (-1); - return ((long)targ); + return ((long)arg); } else { errno = EINVAL; return (-1);