Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 26 Apr 2016 16:16:15 -0500
From:      Pedro Giffuni <pfg@FreeBSD.org>
To:        Maxim Sobolev <sobomax@FreeBSD.org>
Cc:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   Re: svn: stable/10/sys: amd64/amd64 amd64/linux amd64/linux32 compat/linux dev/cxgbe/tom i386/linux vm
Message-ID:  <7d17cf67-284d-0b8f-6ab7-83422e386a21@FreeBSD.org>
In-Reply-To: <CAH7qZfv4jYGqnAhO5vKYE6QFtcSVUNMUH8uGdshOk-B2f9M5og@mail.gmail.com>
References:  <201604261739.u3QHdtSd082499@repo.freebsd.org> <CAH7qZfuK1_ZOovgfrZ2fnMhyUEO92rKbwLOD4vZGPbwDdxVf=A@mail.gmail.com> <64931143-1496-56b9-8dc7-f11cbb0c06ed@FreeBSD.org> <CAH7qZfv4jYGqnAhO5vKYE6QFtcSVUNMUH8uGdshOk-B2f9M5og@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help

Just IMHO;

It is probably too much trouble to pretend to add such checks
to the macros. People using them should know to avoid division
by zero and other issues that may happen.

Pedro.

On 04/26/16 14:59, Maxim Sobolev wrote:
> Yeah, sure no rush. Another interesting mode of failure to check in
> howmany(X, S) is KASSERT((X % S) == 0). There might be few cases when
> it's intended behaviour, but for majority of them it should be
> indication of some kind of programmatic error (i.e. missing a cast in
> sizeof and getting void * size instead of the structure size). Those
> which rely on rounding could then be separated into howmany_rup()
> and howmany_rdown() or something.
>
> On Tue, Apr 26, 2016 at 12:04 PM, Pedro Giffuni <pfg@freebsd.org
> <mailto:pfg@freebsd.org>> wrote:
>
>     Hello
>
>     On 04/26/16 13:42, Maxim Sobolev wrote:
>
>         Given the widespread use of those two macros, maybe we need
>         howmany.9
>         and roundup.9 manual pages with detailed formal description?
>         Particularly interested in how "return" supposed to be typed.
>         Another
>         thing is that would be nice is some kind of automatic
>         #error/#warning/printf/KASSERT/panic when (X < Y || Y <= 0) &
>         defined(INVARIANTS).
>
>         -Max
>
>
>     I agree, we need those documented. There's also rounddown, roundup2 and
>     rounddown2.
>
>     FWIW, I am tired of these massive replacements, and will likely take
>     a break before trying rounddown.
>
>     Pedro.
>
>         On Tue, Apr 26, 2016 at 10:39 AM, Pedro F. Giffuni
>         <pfg@freebsd.org <mailto:pfg@freebsd.org>
>         <mailto:pfg@freebsd.org <mailto:pfg@freebsd.org>>> wrote:
>
>             Author: pfg
>             Date: Tue Apr 26 17:39:54 2016
>             New Revision: 298653
>             URL: https://svnweb.freebsd.org/changeset/base/298653
>
>             Log:
>               MFC r298482:
>               Cleanup redundant parenthesis from existing
>         howmany()/roundup()
>             macro uses.
>
>               Requested by: dchagin
>
>             Modified:
>               stable/10/sys/amd64/amd64/pmap.c
>               stable/10/sys/amd64/linux/linux_sysvec.c
>               stable/10/sys/amd64/linux32/linux32_sysvec.c
>               stable/10/sys/compat/linux/linux_file.c
>               stable/10/sys/dev/cxgbe/tom/t4_tom.c
>               stable/10/sys/i386/linux/linux_sysvec.c
>               stable/10/sys/vm/vm_radix.c
>             Directory Properties:
>               stable/10/   (props changed)
>
>
>



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?7d17cf67-284d-0b8f-6ab7-83422e386a21>