RFC: small syscons and kbd patch
Andriy Gapon
avg at icyb.net.ua
Fri Dec 5 03:45:37 PST 2008
on 05/12/2008 10:50 Garrett Cooper said the following:
> On Fri, Dec 5, 2008 at 12:44 AM, Erik Trulsson <ertr1013 at student.uu.se> wrote:
>> On Fri, Dec 05, 2008 at 12:35:31AM -0800, Garrett Cooper wrote:
>>> On Thu, Dec 4, 2008 at 11:22 PM, Ed Schouten <ed at 80386.nl> wrote:
>>>> * Maksim Yevmenkin <maksim.yevmenkin at gmail.com> wrote:
>>>>> the idea was to ensure that kbd->kb_locked variable only takes values
>>>>> 0 (zero) and 1 (one).
>>>> I often use constructs like these to do that:
>>>>
>>>> foo = bar ? 1 : 0;
>>>>
>>>> Maybe !!bar is a lot shorter to write, I think the line above is a lot
>>>> easier to read.
>>> Indeed. I had no idea (and I would assume that many people wouldn't in
>>> my similar level of systems programming) what in the work you were
>>> trying to do above with that line. The one-line conditional is
>>> universal in almost all major high-level language dialects I've hit,
>>> minus Python and Tcl.
>>> -Garrett
>> The !!bar construction to map {0, not-0} to {0,1} is fairly common in C
>> programming, and I would certainly expect any experienced C programmer to
>> recognize it.
>
> (I feel like I'm getting off on a bikeshed topic, but...)
>
> 1. What dialect of C was it defined in? Is it still used in the
> standard dialect (honestly, this is the first time I've ever seen it
> before, but then again I am a younger generation user)?
I am not sure what you meant by dialect of C, just in case you meant
something different from others understood here's my personal
observation: you will quite a bit of '!!' in Linux kernel code, you
would see much much fewer of them in our code.
--
Andriy Gapon
More information about the freebsd-hackers
mailing list