From: Petr Vorel <pvorel@suse.cz>
To: Wei Gao <wegao@suse.com>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v9 1/2] lib: Extend tst_assert_ulong() with enum flags
Date: Wed, 2 Sep 2026 11:04:18 +0200 [thread overview]
Message-ID: <20260902090418.GA910767@pevik> (raw)
In-Reply-To: <20260831081638.19539-2-wegao@suse.com>
Hi Wei,
> Introduce enum tst_assert_flags (including TST_ASSERT_NONE,
> TST_ASSERT_SATURATED_INT, and TST_ASSERT_TRUNC_32BIT) to
> tst_assert_ulong(). This enables type-safe handling of 32-bit
> compat-mode truncation and clamping behaviors on 64-bit kernels
> when verifying sysfs/procfs limits.
> Signed-off-by: Wei Gao <wegao@suse.com>
> ---
> include/tst_assert.h | 36 +++++++++++++++++++++++++++++++-----
> lib/tst_assert.c | 26 ++++++++++++++++++++------
> 2 files changed, 51 insertions(+), 11 deletions(-)
> diff --git a/include/tst_assert.h b/include/tst_assert.h
> index dcb62dfea..9154b7249 100644
> --- a/include/tst_assert.h
> +++ b/include/tst_assert.h
> @@ -21,14 +21,40 @@ void tst_assert_int(const char *file, const int lineno,
> #define TST_ASSERT_FILE_INT(path, prefix, val) \
> tst_assert_file_int(__FILE__, __LINE__, path, prefix, val)
> -/*
> - * Same as tst_assert_int() but for unsigned long.
> +/**
> + * enum tst_assert_flags - Flags for tst_assert_ulong().
nit: I'd use "Bitwise flags" as you write below.
> + *
> + * @TST_ASSERT_NONE: No flags, default direct comparison.
> + * @TST_ASSERT_SATURATED_INT: Clamps the value at %INT_MAX if it exceeds it.
> + * @TST_ASSERT_TRUNC_32BIT: Keeps only the low 32 bits of the read value,
> + * truncating any higher bits.
> + */
> +enum tst_assert_flags {
> + TST_ASSERT_NONE = 0x00,
IMHO TST_ASSERT_NONE is overkill, I'd just use 0. But others might have a
different opinion.
> + TST_ASSERT_SATURATED_INT = 0x01,
> + TST_ASSERT_TRUNC_32BIT = 0x02,
Also, I'd use decimal numbers instead of hexadecimal when we have just 3 values
(specially 0x00 looks really strange).
The rest LGTM.
Reviewed-by: Petr Vorel <pvorel@suse.cz>
Kind regards,
Petr
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2026-09-02 9:04 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-31 8:16 [LTP] [PATCH v9 0/2] shmctl03: Fix 32-bit compat mode failure Wei Gao via ltp
2026-08-31 8:16 ` [LTP] [PATCH v9 1/2] lib: Extend tst_assert_ulong() with enum flags Wei Gao via ltp
2026-08-31 9:00 ` [LTP] " linuxtestproject.agent
2026-09-02 9:04 ` Petr Vorel [this message]
2026-08-31 8:16 ` [LTP] [PATCH v9 2/2] shmctl03: Fix 32-bit compat mode failure Wei Gao via ltp
2026-09-02 9:06 ` Petr Vorel
2026-09-02 9:18 ` Petr Vorel
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=20260902090418.GA910767@pevik \
--to=pvorel@suse.cz \
--cc=ltp@lists.linux.it \
--cc=wegao@suse.com \
/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