[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <873661285.9347975.1643538017855.JavaMail.zimbra@uliege.be>
Date: Sun, 30 Jan 2022 11:20:17 +0100 (CET)
From: Justin Iurman <justin.iurman@...ege.be>
To: Jakub Kicinski <kuba@...nel.org>
Cc: netdev@...r.kernel.org, davem@...emloft.net,
yoshfuji@...ux-ipv6.org, dsahern@...nel.org
Subject: Re: [PATCH net-next 1/2] uapi: ioam: Insertion frequency
>>> diff --git a/include/uapi/linux/ioam6_iptunnel.h
>>> b/include/uapi/linux/ioam6_iptunnel.h
>>> index 829ffdfcacca..462758cdba14 100644
>>> --- a/include/uapi/linux/ioam6_iptunnel.h
>>> +++ b/include/uapi/linux/ioam6_iptunnel.h
>>> @@ -30,6 +30,15 @@ enum {
>>> enum {
>>> IOAM6_IPTUNNEL_UNSPEC,
>>>
>>> + /* Insertion frequency:
>>> + * "k over n" packets (0 < k <= n)
>>> + * [0.0001% ... 100%]
>>> + */
>>> +#define IOAM6_IPTUNNEL_FREQ_MIN 1
>>> +#define IOAM6_IPTUNNEL_FREQ_MAX 1000000
>>
>> If min is 1 why not make the value unsigned?
>
> The atomic_t type is just a wrapper for a signed int, so I didn't want
> to have to convert from signed to unsigned. I agree it'd sound better to
> have unsigned here, though.
Sorry, I figured out a cast is fine thanks to [1] which says:
"[...] the kernel uses -fno-strict-overflow
(which implies -fwrapv) and defines signed overflow to behave like
2s-complement.
Therefore, an explicitly unsigned variant of the atomic ops is strictly
unnecessary and we can simply cast, there is no UB. [...]"
[1] https://www.kernel.org/doc/Documentation/atomic_t.txt
Powered by blists - more mailing lists