Re: [PATCH RFC v2] mac80211: debugfs option to force TX status frames
From: Kalle Valo <hidden>
Date: 2019-03-11 14:03:49
Also in:
linux-wireless, lkml
From: Kalle Valo <hidden>
Date: 2019-03-11 14:03:49
Also in:
linux-wireless, lkml
ga58taw@mytum.de writes:
On Thu, Mar 07, 2019 at 05:42:04PM +0200, Kalle Valo wrote:quoted
quoted
+ 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