Re: [PATCH 1/6] Staging: hv: mousevsc: Make boolean states boolean

From: Joe Perches
Date: Wed Oct 26 2011 - 19:59:44 EST


On Thu, 2011-10-27 at 01:50 +0200, Greg KH wrote:
> On Wed, Oct 26, 2011 at 03:46:51PM -0700, Joe Perches wrote:
> > On Wed, 2011-10-26 at 08:07 +0200, Greg KH wrote:
> > > On Tue, Oct 25, 2011 at 05:03:47PM -0700, Joe Perches wrote:
> > > > On Tue, 2011-10-25 at 17:19 -0700, K. Y. Srinivasan wrote:
> > > > > Make some state that is boolean in nature, a boolean variable.
> > > > []
> > > > > diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c
> > > > []
> > > > @@ -148,7 +148,7 @@ struct mousevsc_prt_msg {
> > > > > */
> > > > > struct mousevsc_dev {
> > > > > struct hv_device *device;
> > > > > - unsigned char init_complete;
> > > > > + bool init_complete;
> > > > > struct mousevsc_prt_msg protocol_req;
> > > > > struct mousevsc_prt_msg protocol_resp;
> > > > > /* Synchronize the request/response if needed */
> > > > > @@ -159,7 +159,7 @@ struct mousevsc_dev {
> > > > > unsigned char *report_desc;
> > > > > u32 report_desc_size;
> > > > > struct hv_input_dev_info hid_dev_info;
> > > > > - int connected;
> > > > > + bool connected;
> > > > > struct hid_device *hid_device;
> > > > > };
> > > > One of the bools should be moved to be adjacent to the other.
> > > For a mouse driver, it really doesn't matter.
> > 'course it doesn't matter, just like whitespace
> > doesn't matter. It's just done for form's sake.
> Not at all.
> Whitespace does matter, there is documented proof of that.
> The fact that you want to move a bool to a different part of a structure
> really is only your personal choice. It doesn't matter for size or
> layout to make this code work better at all to do this.

Just as what you suggest is your opinion.

Whether or not 4 or 8 extra/wasted bytes in
a struct is important or not is arguable.

I think disaggregating bools is akin to
disaggregating bitfields.

Not necessarily wrong, just odd.

cheers, Joe

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/