Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 19 May 2015 09:45:49 -0400
From:      John Baldwin <jhb@freebsd.org>
To:        Pedro Giffuni <pfg@freebsd.org>
Cc:        Bruce Evans <brde@optusnet.com.au>, src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   Re: svn commit: r283088 - head/sys/ddb
Message-ID:  <2053555.dpIzi23R03@ralph.baldwin.cx>
In-Reply-To: <BA474AEC-A0A8-4FF8-8881-397E8280C72F@FreeBSD.org>
References:  <201505182227.t4IMRljx078812@svn.freebsd.org> <20150519135341.R2157@besplex.bde.org> <BA474AEC-A0A8-4FF8-8881-397E8280C72F@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tuesday, May 19, 2015 12:28:05 AM Pedro Giffuni wrote:
> >>>> Modified: head/sys/ddb/db_break.c
> >>>> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D
> >>>> --- head/sys/ddb/db_break.c=09Mon May 18 22:14:06 2015=09(r28308=
7)
> >>>> +++ head/sys/ddb/db_break.c=09Mon May 18 22:27:46 2015=09(r28308=
8)
> >>>> @@ -155,12 +155,12 @@ db_find_breakpoint_here(db_addr_t addr)
> >>>> =09return db_find_breakpoint(db_map_addr(addr), addr);
> >>>> }
> >>>>=20
> >>>> -static boolean_t=09db_breakpoints_inserted =3D TRUE;
> >>>> +static boolean_t=09db_breakpoints_inserted =3D true;
> >>>=20
> >>> This code hasn't been churned to use the boolean type.  It still =
uses
> >>> boolean_t, which is plain int.  TRUE and FALSE go with this type.=
  true
> >>> and false go with the boolean type.  This probably makes no diffe=
rence,
> >>> because TRUE happens to be implemented with the same value as tru=
e and
> >>> there are lots of implicit versions between the types.
> >>=20
> >> Yes, I noticed the return types are still ints. It doesn=E2=80=99t=
 look difficult
> >> to convert it to use a real boolean type.  In any case, I would pr=
efer to go
> >> forward (using bool) instead of reverting this change.
> >=20
> > That wuld be sideways.
> >=20
> > I forgot to mention (again) in my previous reply that boolean_t is =
a mistake
> > by me.  KNF code doesn't even use the ! operator, but uses explicit=

> > comparison with 0.  The boolean_t type and TRUE and FALSE are from =
Mach.
> > They were used mainly in ddb and vm, and are still almost never use=
d in
> > kern.  I used to like typedefs and a typedef for boolean types, and=
 didn't
> > know KNF very well, so in 1995 I moved the declaration of boolean_t=
 from
> > Mach vm code to sys/types.h to try to popularize it.  This was a mi=
stake.
> > Fortunately, it is still rarely used in core kernel code.
> >=20
> > The boolean type is also almost never used for syscalls.  In POSIX.=
1-2001,
> > <stdbool.h> is inherited from C99, but is never used for any other =
POSIX
> > API.  Using it for syscalls would mainly cause portability problems=
.
> >=20
>=20
> OK, I do understand the kernel wants to keep the C dialect somewhat l=
imited,
> and adding stdbool.h doesn=E2=80=99t buy us any type safety here.
>=20
> I=E2=80=99ll revert the change (prob. tomorrow though).

I will disagree with Bruce a bit and put my vote in for replacing boole=
an_t
with bool where it is used.  I do think that logically (if not strictly=
) your
commit is a type mismatch as TRUE/FALSE is for boolean_t and true/false=
 are
for bool.  I agree with Bruce that we probably don't want to use bool f=
or
system calls.  However, I think using bool in the kernel itself is ok a=
nd that
we should replace boolean_t with bool.

--=20
John Baldwin



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?2053555.dpIzi23R03>