From owner-svn-src-head@freebsd.org Fri Aug 4 07:57:14 2017 Return-Path: Delivered-To: svn-src-head@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 6E354DCB88D for ; Fri, 4 Aug 2017 07:57:14 +0000 (UTC) (envelope-from oliver.pinter@hardenedbsd.org) Received: from mail-vk0-x233.google.com (mail-vk0-x233.google.com [IPv6:2607:f8b0:400c:c05::233]) (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 1B8F78260B for ; Fri, 4 Aug 2017 07:57:14 +0000 (UTC) (envelope-from oliver.pinter@hardenedbsd.org) Received: by mail-vk0-x233.google.com with SMTP id x10so3322997vkd.0 for ; Fri, 04 Aug 2017 00:57:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hardenedbsd-org.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=3cDoNpd7MRlqrHmgXoSEqI2O5G3XxwKv12EtIjFMHi0=; b=jtXIy3Psvq3b2kEfi0GhLwJOhhX50rF+weoH1xWV0orgGBYVK5U0RWEqhDLHX5Bneu CaLnfAbovWvSMLkIv7KjmXmGA+1kjggCQvWbanVlc3u9oLDZ6qHLzfu6fDlMm9Tc4lTX Hui8pCBrxVaiyguZ8sQVmxYZMtgMLvxccmEjO0ngklExJN5NU8Y6EJShGy73BNOf/l6x eWJ5q7zoXNooXPFsW3Vv0qC1zpCu37QoS2dFHBCc0L56174Lai4TCi7M5kvst1jZWjBT aWh/Nh5V/sZFK+SpXEKMxVTzdffL5Fpi2nqeT9lRtaRbE3QfzO1D8tDK7utMtVtxp438 vYtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=3cDoNpd7MRlqrHmgXoSEqI2O5G3XxwKv12EtIjFMHi0=; b=Vajyh9NkGZCINas68lWx66OkxsGDex2EulKOzkbbHIYod+BQ0DxX21O+SqfkW0pi2B l+h9WL3PnaVwaTw5w60ngj5g6yNBKCe19eN9QN8PxBXNK1HlCYB+YuJK04kQTa0kICVo CsgiYnXqOTdS3JTo6eSW0qoY+k0qRC9D0dTXzTHugEqKUOXKfHr4spkXswBlqRLg+ZoW vOTr0QwGEhQM1I3H0xkHdPJxSRt7vsglLSlF7lq+bhflMO1u0ivZ98SioQGm47Sch5qZ q5xOcYcAUiy+7Uv8QoTXwn+vZcvrVuNX0Jeww6zLMzoPw/1kMl8ZU0RTh21c6b5RMpqe oVfA== X-Gm-Message-State: AHYfb5ho3+D05Mgtn6CEye09efzUdQoHxC+Gy2HJMVA26ySjJJKhbmPC 1v7ym471afiY6o2MgXZTEK/NdJV6ZEEa X-Received: by 10.31.106.129 with SMTP id f123mr930880vkc.74.1501833433203; Fri, 04 Aug 2017 00:57:13 -0700 (PDT) MIME-Version: 1.0 Received: by 10.103.8.70 with HTTP; Fri, 4 Aug 2017 00:57:12 -0700 (PDT) In-Reply-To: <201708040423.v744NOix022999@repo.freebsd.org> References: <201708040423.v744NOix022999@repo.freebsd.org> From: Oliver Pinter Date: Fri, 4 Aug 2017 09:57:12 +0200 Message-ID: Subject: Re: svn commit: r322041 - head/sys/kern To: Alan Cox Cc: "src-committers@freebsd.org" , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.23 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Aug 2017 07:57:14 -0000 On Friday, August 4, 2017, Alan Cox wrote: > Author: alc > Date: Fri Aug 4 04:23:23 2017 > New Revision: 322041 > URL: https://svnweb.freebsd.org/changeset/base/322041 > > Log: > In case readers are misled by expressions that combine multiplication and > division, add parentheses to make the precedence explicit. > > Submitted by: Doug Moore > > Requested by: imp > Reviewed by: imp > MFC after: 1 week > X-MFC after: r321840 > Differential Revision: https://reviews.freebsd.org/D11815 > > Modified: > head/sys/kern/subr_blist.c > > Modified: head/sys/kern/subr_blist.c > ============================================================ > ================== > --- head/sys/kern/subr_blist.c Fri Aug 4 04:20:11 2017 (r322040) > +++ head/sys/kern/subr_blist.c Fri Aug 4 04:23:23 2017 (r322041) > @@ -110,6 +110,7 @@ __FBSDID("$FreeBSD$"); > #define bitcount64(x) __bitcount64((uint64_t)(x)) > #define malloc(a,b,c) calloc(a, 1) > #define free(a,b) free(a) > +#define CTASSERT(expr) Is this dummy define intended? > > #include > > @@ -142,6 +143,8 @@ static void blst_radix_print(blmeta_t *scan, daddr_t b > static MALLOC_DEFINE(M_SWAP, "SWAP", "Swap space"); > #endif > > +CTASSERT(BLIST_BMAP_RADIX % BLIST_META_RADIX == 0); > + > /* > * For a subtree that can represent the state of up to 'radix' blocks, the > * number of leaf nodes of the subtree is L=radix/BLIST_BMAP_RADIX. If > 'm' > @@ -151,17 +154,19 @@ static MALLOC_DEFINE(M_SWAP, "SWAP", "Swap space"); > * in the 'meta' functions that process subtrees. Since integer division > * discards remainders, we can express this computation as > * skip = (m * m**h) / (m - 1) > - * skip = (m * radix / BLIST_BMAP_RADIX) / (m - 1) > - * and if m divides BLIST_BMAP_RADIX, we can simplify further to > - * skip = radix / (BLIST_BMAP_RADIX / m * (m - 1)) > - * so that a simple integer division is enough for the calculation. > + * skip = (m * (radix / BLIST_BMAP_RADIX)) / (m - 1) > + * and since m divides BLIST_BMAP_RADIX, we can simplify further to > + * skip = (radix / (BLIST_BMAP_RADIX / m)) / (m - 1) > + * skip = radix / ((BLIST_BMAP_RADIX / m) * (m - 1)) > + * so that simple integer division by a constant can safely be used for > the > + * calculation. > */ > static inline daddr_t > radix_to_skip(daddr_t radix) > { > > return (radix / > - (BLIST_BMAP_RADIX / BLIST_META_RADIX * (BLIST_META_RADIX - > 1))); > + ((BLIST_BMAP_RADIX / BLIST_META_RADIX) * (BLIST_META_RADIX - > 1))); > } > > /* > _______________________________________________ > svn-src-head@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/svn-src-head > To unsubscribe, send any mail to "svn-src-head-unsubscribe@freebsd.org > " >