Re: [PATCH 2/3] tools/nolibc: add support for getrlimit/setrlimit

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Thomas,

> +int test_rlimit(void)
> +{
> +	struct rlimit rlim = {
> +		.rlim_cur = 1 << 20,
> +		.rlim_max = 1 << 20,
> +	};
> +	int ret;
> +
> +	ret = setrlimit(RLIMIT_CORE, &rlim);
> +	if (ret)
> +		return -1;
> +
> +	rlim.rlim_cur = 0;
> +	rlim.rlim_max = 0;
> +
> +	ret = getrlimit(RLIMIT_CORE, &rlim);
> +	if (ret)
> +		return -1;
> +
> +	if (rlim.rlim_cur != 1 << 20)
> +		return -1;
> +	if (rlim.rlim_max != 1 << 20)
> +		return -1;

I think you should used two different values here for cur and max so
that you can also detect stupid API bugs such as a union being used
instead of a struct, or copy-pastes in the implementation etc. For
example using 1<<20 and 1<<21 should do the trick.

Otherwise Ack-by me for the whole series, of course.

Thanks,
Willy




[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux