sysctl: add overflow detection to proc_get_long()
Quoted 4 lines
Quoted 2 lines
Yecchh... First of all, the cast back to unsigned long long is completely pointless. What's more,
Sorry, seriously asking: why?
In C everything is casted to the same type before doing an operation, in this case comparison
Quoted 3 lines
This was meant to handle the case where
sizeof(unsigned long long) != sizeof(unsigned long) and I just looked at_kstrtoul()which does the same:
Second cast is unnecessary. I don't remember why I did 2 casts.
Quoted 7 lines · Alexey Dobriyan
Quoted 1 line
Quoted 1 line
Yecchh... First of all, the cast back to unsigned long long is
completely
Quoted 3 lines
Quoted 1 line
pointless. What's more,
Sorry, seriously asking: why?
In C everything is casted to the same type before doing an operation,
Oh, ok that's what we're talking about. I thought the whole check is pointless. I didn't read careful enough apparently.
Tbh, even if the second cast is not necessary it makes implicit behavior explicit.
I've also seen this form more than the one without the explicit cast. But I won't fight it. If other people prefer it without the second cast; fine.
Quoted 8 lines
in this case comparison
Quoted 2 lines
This was meant to handle the case where
sizeof(unsigned long long) != sizeof(unsigned long) and I just lookedat
Quoted 1 line
_kstrtoul()which does the same:Second cast is unnecessary. I don't remember why I did 2 casts.