Re: [PATCH] genetlink: fix unsigned int comparison with less than zero

2 messages, 2 authors, 2016-11-13 · open the first message on its own page

Re: [PATCH] genetlink: fix unsigned int comparison with less than zero

From: Johannes Berg <johannes@sipsolutions.net>
Date: 2016-11-12 21:37:29

On Thu, 2016-11-10 at 09:11 -0800, Cong Wang wrote:
On Thu, Nov 10, 2016 at 7:57 AM, Colin King <colin.king@canonical.com
quoted
wrote:

From: Colin Ian King <redacted>

family->id is unsigned, so the less than zero check for
failure return from idr_alloc is never true and so the error exit
is never handled.  Instead, assign err and check if this is less
than zero since this is a signed integer.
Why family->id can't be just signed int? For me it should be.
I suppose it could be, since family IDs are allocated in a 16-bit range
anyway. But family IDs can also never actually be negative, so having
an unsigned int in the struct makes sense too.

I tend to think this patch is fine.

johannes

Re: [PATCH] genetlink: fix unsigned int comparison with less than zero

From: Cong Wang <hidden>
Date: 2016-11-13 05:25:28

On Sat, Nov 12, 2016 at 1:37 PM, Johannes Berg
[off-list ref] wrote:
On Thu, 2016-11-10 at 09:11 -0800, Cong Wang wrote:
quoted
On Thu, Nov 10, 2016 at 7:57 AM, Colin King <colin.king@canonical.com
quoted
wrote:

From: Colin Ian King <redacted>

family->id is unsigned, so the less than zero check for
failure return from idr_alloc is never true and so the error exit
is never handled.  Instead, assign err and check if this is less
than zero since this is a signed integer.
Why family->id can't be just signed int? For me it should be.
I suppose it could be, since family IDs are allocated in a 16-bit range
anyway. But family IDs can also never actually be negative, so having
an unsigned int in the struct makes sense too.
All idr_* API's accept int, rather than unsigned int. This is my point.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help