[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <87v7sj3dlx.ffs@tglx>
Date: Sat, 08 Mar 2025 13:34:34 +0100
From: Thomas Gleixner <tglx@...utronix.de>
To: Dmitry Vyukov <dvyukov@...gle.com>, krisman@...labora.com,
luto@...nel.org, peterz@...radead.org, keescook@...omium.org,
gregory.price@...verge.com
Cc: Dmitry Vyukov <dvyukov@...gle.com>, Marco Elver <elver@...gle.com>,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 2/3] selftests: Fix errno checking in
syscall_user_dispatch test
On Mon, Feb 24 2025 at 09:45, Dmitry Vyukov wrote:
>
> Also use EXPECT/ASSERT consistently. Currently there is an inconsistent mix
> without obvious reasons for usage of one or another.
>
> Signed-off-by: Dmitry Vyukov <dvyukov@...gle.com>
As Gregory said, this should be the first patch in the series with a
proper Fixes tag.
> /* Invalid op */
> op = -1;
> - prctl(PR_SET_SYSCALL_USER_DISPATCH, op, 0, 0, &sel);
> - ASSERT_EQ(EINVAL, errno);
> + EXPECT_EQ(-1, prctl(PR_SET_SYSCALL_USER_DISPATCH, op, 0, 0, &sel));
> + EXPECT_EQ(EINVAL, errno);
Seriously?
Something like:
static void prctl_invalid(unsigned long op, unsigned long offs, unsigned long len,
void *sel, int err)
{
EXPECT_EQ(-1, prctl(PR_SET_SYSCALL_USER_DISPATCH, op, offs, len, 0, (unsigned long)sel));
EXPECT_EQ(err, errno);
}
static void prctl_valid(unsigned long op, unsigned long offs, unsigned long len,
void *sel)
{
EXPECT_EQ(0, prctl(PR_SET_SYSCALL_USER_DISPATCH, op, offs, len, 0, (unsigned long)sel));
}
....
/* Invalid op */
prctl_invalid(-1, 0, 0, &sel, -EINVAL);
/* offset != 0 */
prctl_invalid(PR_SYS_DISPATCH_OFF, 1, 0, NULL, -EINVAL);
....
/* The odd valid test in bad_prctl_param() */
prctl_valid(PR_SYS_DISPATCH_OFF, 0, 0, NULL);
But that's not enough macro uglyness sprinkled all over the place and
too readable, right?
Thanks,
tglx
Powered by blists - more mailing lists