From owner-svn-src-all@freebsd.org Tue Aug 30 22:41:10 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1C9C3BC9D77; Tue, 30 Aug 2016 22:41:10 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: from mail-wm0-x234.google.com (mail-wm0-x234.google.com [IPv6:2a00:1450:400c:c09::234]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id A2C2A76D; Tue, 30 Aug 2016 22:41:09 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: by mail-wm0-x234.google.com with SMTP id w2so7779090wmd.0; Tue, 30 Aug 2016 15:41:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=k2Bd2kXvsnp60X/+s3ZMMyXw87++5yZ/DDeMr53cTds=; b=VZ9zoYndBQ/grbPySmMVhUC1Dyn5KZ2Z6+73g0MHFtfuDGWvbqxEm+Ql30b0E/hs7M 0pFwQL+VuHSPHthVoGleGkFAHbpGHTy1VB0MMVlS66cjrz0c1dc3q0c2aHXgKWM3OigI LDqTVEq6f6ti7NnA5Nwk4SWqGxCTZazHzWLNuKP5YqbTd3TyErGCDAPOV1lcC62E6itB t7yU5wDDU6msQ/oH5zhfgxBrIeaLUauAjWXECv4QV7skJFgd0nydL9hFdRyCKjdYtZWQ HgeFfbSqqfRelG2Dk2lPjLQwqKgwhJY1+LGBxp71YxR7ttFZ9SAZlVNZwqZZHRsp5XgS J6Qg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=k2Bd2kXvsnp60X/+s3ZMMyXw87++5yZ/DDeMr53cTds=; b=ACH5kGOaIVtNCuxvZ3fmLwNlD5zc0H9BBNeM/pRF6yiPywqWWLc4xjPyLe3+7Y+7vT ViZWLMZVNxgp+NJZTukzLgUQzfcFOcXwBYtmlLHH0n1KzwSuW2wZ5WYbIGEXPOGsF6f3 NRop7mid0v6E4hmpqdDbZKFoKOcle7hCaCxjCsf5BBdjPfpRg73j1xnbIAtWmDBkr16E CGjoy0u8hptrYI/HaagOIWCjl1VRikhxHzWWWKFTV1z0YEtWU7uEGsJS/3TmARMrDsIJ +jQLPbMCxf2TniGafzA5TF4Wg33oK642i87HrEWrDddMBrBLpNGsD79BJ3TxB4lAawkc mqDA== X-Gm-Message-State: AE9vXwPv31GHJDlHbt7w+TFoaWTEamBqdrVMSAG76WiqtHQm9bkrcXO/wxy35d+Mr6Q0fA== X-Received: by 10.28.182.136 with SMTP id g130mr6292867wmf.21.1472596867914; Tue, 30 Aug 2016 15:41:07 -0700 (PDT) Received: from dft-labs.eu (n1x0n-1-pt.tunnel.tserv5.lon1.ipv6.he.net. [2001:470:1f08:1f7::2]) by smtp.gmail.com with ESMTPSA id bw9sm41565468wjc.33.2016.08.30.15.41.06 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Tue, 30 Aug 2016 15:41:07 -0700 (PDT) Date: Wed, 31 Aug 2016 00:41:05 +0200 From: Mateusz Guzik To: Conrad Meyer Cc: Mateusz Guzik , src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r305091 - head/sys/sys Message-ID: <20160830224104.GA16151@dft-labs.eu> References: <201608302148.u7ULmAKm073958@repo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.22 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, 30 Aug 2016 22:41:10 -0000 On Tue, Aug 30, 2016 at 03:35:39PM -0700, Conrad Meyer wrote: > On Tue, Aug 30, 2016 at 2:48 PM, Mateusz Guzik wrote: > > Author: mjg > > Date: Tue Aug 30 21:48:10 2016 > > New Revision: 305091 > > URL: https://svnweb.freebsd.org/changeset/base/305091 > > > > Log: > > fd: simplify fd testing in fget_locked by casting to u_int > > > > Modified: > > head/sys/sys/filedesc.h > > > > Modified: head/sys/sys/filedesc.h > > ============================================================================== > > --- head/sys/sys/filedesc.h Tue Aug 30 21:43:57 2016 (r305090) > > +++ head/sys/sys/filedesc.h Tue Aug 30 21:48:10 2016 (r305091) > > @@ -201,7 +201,7 @@ fget_locked(struct filedesc *fdp, int fd > > > > FILEDESC_LOCK_ASSERT(fdp); > > > > - if (fd < 0 || fd > fdp->fd_lastfile) > > + if ((u_int)fd > fdp->fd_lastfile) > > return (NULL); > > > > return (fdp->fd_ofiles[fd].fde_file); > > > > > I notice that fd_lastfile is an 'int'. Won't this trigger warnings > about the differing signedness of the two sides of the comparison? > Should fd_lastfile just be u_int as well? (If not (there is some > valid negative value), this change may be invalid.) > It is -1 just after inception and is supposed to grow immediately after. That is, the table with -1 should never be accessible. But now that you mention it I agree this is bad style. This unnecessarily differs from the check in fget_unlocked so I'll just unify it. -- Mateusz Guzik