[PATCH 6/7] tools: allow setting of transit net

Julian Orth ju.orth at gmail.com
Sat Sep 8 16:18:18 CEST 2018


On 9/8/18 4:09 PM, Aaron Jones wrote:
> On 08/09/18 12:18, Julian Orth wrote:
>> +static bool parse_transit_net(struct wgdevice *device, const char *arg)
>> +{
>> +	/* U32 arg -> PID */
>> +	if (isdigit(*arg)) {
>> +		char *end;
>> +		unsigned long pid = strtoul(arg, &end, 10);
>> +		if (!*end && pid <= UINT32_MAX) {
> 
> This condition will always be true on a 32-bit system (for a valid
> integer). I'd prefer strtoull() and `unsigned long long' but given
> that a valid file descriptor won't ever go that high... eh. shrug. But
> you'll still get a compiler diagnostic for it.

Even with clang's -Weverything I don't get a warning when I compile the 
following:

#include <stdint.h>

int f(unsigned int i);

int f(unsigned int i)
{
	return i <= UINT32_MAX;
}

I don't see why it would be different for unsigned long on a 32-bit system.


More information about the WireGuard mailing list