LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Julia Lawall <julia.lawall@lip6.fr>
To: Himanshu Jha <himanshujha199640@gmail.com>
Cc: Sasha Levin <sashal@kernel.org>,
	Shayenne da Luz Moura <shayenneluzmoura@gmail.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Hans de Goede <hdegoede@redhat.com>,
	Michael Thayer <michael.thayer@oracle.com>,
	devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org,
	outreachy-kernel@googlegroups.com
Subject: Re: [Outreachy kernel] [RESEND PATCH 2/2] staging: vboxvideo: Use unsigned int instead bool
Date: Sun, 28 Oct 2018 09:47:15 +0100 (CET)	[thread overview]
Message-ID: <alpine.DEB.2.21.1810280932030.2450@hadrien> (raw)
In-Reply-To: <20181028075209.GA1938@himanshu-Vostro-3559>

> The "possible alignement issues" in CHECK report is difficult to figure
> out by just doing a glance analysis. :)
>
> Linus also suggested to use bool as the base type i.e., `bool x:1` but
> again sizeof(_Bool) is implementation defined ranging from 1-4 bytes.

If bool x:1 has the size of bool, then wouldn't int x:1 have the size of
int?  But my little experiments suggest that the size is the smallest that
fits the requested bits and alignment chosen by the compiler, regardless of
the type.

bool x:1 has the advantage that anything that is not 0 is considered true.
So for bool x:1, x = 4 is true, while for int x:1, x = 4 is false.

But the :1 adds instructions, so at least for only one bool, where little
space is saved, it is probably not worth it.

julia

  reply	other threads:[~2018-10-28  8:47 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-26 19:03 [RESEND PATCH 0/2] staging: vboxvideo: Remove chekpatch issues Shayenne da Luz Moura
2018-10-26 19:04 ` [RESEND PATCH 1/2] staging: vboxvideo: Change uint32_t to u32 Shayenne da Luz Moura
2018-10-28 11:02   ` Hans de Goede
2018-10-26 19:04 ` [RESEND PATCH 2/2] staging: vboxvideo: Use unsigned int instead bool Shayenne da Luz Moura
2018-10-26 20:42   ` [Outreachy kernel] " Sasha Levin
2018-10-26 20:54     ` Julia Lawall
2018-10-27 21:59       ` Joe Perches
2018-10-28  5:41         ` Julia Lawall
2018-10-28  7:52     ` Himanshu Jha
2018-10-28  8:47       ` Julia Lawall [this message]
2018-10-28 11:20         ` Himanshu Jha
2018-10-28 11:46           ` Julia Lawall
2018-10-30 20:18             ` Shayenne Moura
2018-10-30 20:25               ` Julia Lawall
2018-10-30 20:33                 ` Shayenne Moura

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.DEB.2.21.1810280932030.2450@hadrien \
    --to=julia.lawall@lip6.fr \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=hdegoede@redhat.com \
    --cc=himanshujha199640@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michael.thayer@oracle.com \
    --cc=outreachy-kernel@googlegroups.com \
    --cc=sashal@kernel.org \
    --cc=shayenneluzmoura@gmail.com \
    --subject='Re: [Outreachy kernel] [RESEND PATCH 2/2] staging: vboxvideo: Use unsigned int instead bool' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).