[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87h8c98q4l.fsf@codeaurora.org>
Date: Mon, 11 Mar 2019 16:03:38 +0200
From: Kalle Valo <kvalo@...eaurora.org>
To: ga58taw@...um.de
Cc: Julius Niedworok <julius.n@....net>,
linux-wireless@...r.kernel.org, david@...hat.com, nc@....in.tum.de,
Johannes Berg <johannes@...solutions.net>,
"David S. Miller" <davem@...emloft.net>, netdev@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH RFC v2] mac80211: debugfs option to force TX status frames
ga58taw@...um.de writes:
> On Thu, Mar 07, 2019 at 05:42:04PM +0200, Kalle Valo wrote:
>> > + len = scnprintf(buf, sizeof(buf), "%d\n", (int)local->force_tx_status);
>>
>> I wonder about the cast, is it guaranteed that a bool is always of the
>> same size as an int?
>
> Why is this a problem? If a bool is smaller than an int, the compiler
> emits code that will prepend the value of force_tx_status with zeros.
Let's say that a bool is a byte and int is four bytes. If you use "%d" I
would guess that in that case scnprintf() writes 4 bytes, meaning that 3
bytes will be overwriting either padding or some other field in the
struct.
But I'm no compiler expert so I'm not going to argue about this anymore.
I just wanted to point out that that the cast looks dangerous and I
would not do it.
--
Kalle Valo
Powered by blists - more mailing lists