mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Willy Tarreau <w@1wt.eu>
To: "Thomas Weißschuh" <linux@weissschuh.net>
Cc: Shuah Khan <shuah@kernel.org>,
	linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org
Subject: Re: [PATCH 2/3] tools/nolibc: add support for getrlimit/setrlimit
Date: Sun, 26 Nov 2023 10:28:28 +0100	[thread overview]
Message-ID: <20231126092828.GB7407@1wt.eu> (raw)
In-Reply-To: <20231123-nolibc-rlimit-v1-2-a428b131de2a@weissschuh.net>

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

  reply	other threads:[~2023-11-26  9:28 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-22 23:21 [PATCH 0/3] tools/nolibc: rlimit support Thomas Weißschuh
2023-11-22 23:21 ` [PATCH 1/3] tools/nolibc: drop custom definition of struct rusage Thomas Weißschuh
2023-11-22 23:21 ` [PATCH 2/3] tools/nolibc: add support for getrlimit/setrlimit Thomas Weißschuh
2023-11-26  9:28   ` Willy Tarreau [this message]
2023-11-26 10:42     ` Thomas Weißschuh
2023-11-22 23:21 ` [PATCH 3/3] selftests/nolibc: disable coredump via setrlimit Thomas Weißschuh

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231126092828.GB7407@1wt.eu \
    --to=w@1wt.eu \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux@weissschuh.net \
    --cc=shuah@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®