[LTP] [PATCH v5 1/3] syscalls/modify_ldt: Add lapi/ldt.h
Ricardo B. Marlière
rbm@suse.com
Tue Apr 1 12:45:09 CEST 2025
Hello Petr!
On Tue Apr 1, 2025 at 7:29 AM -03, Petr Vorel wrote:
> Hi Ricardo, Andrea,
>
>> +++ b/include/lapi/ldt.h
>> @@ -0,0 +1,34 @@
>> +// SPDX-License-Identifier: GPL-2.0-or-later
>> +/*
>> + * Copyright (c) 2025 SUSE LLC Ricardo B. Marlière <rbm@suse.com>
>> + */
>> +
>> +#ifndef LAPI_LDT_H__
>> +#define LAPI_LDT_H__
>> +
>> +#include "config.h"
>> +#include "lapi/syscalls.h"
>> +#include <asm/ldt.h>
>> +
>> +static int modify_ldt(int func, void *ptr, unsigned long bytecount)
> FYI if this in a header it should be 'static inline'. That would be worth to fix.
>
> We have a lot of 'static inline' in lapi headers. IMHO this is a good approach
> for these feature specific syscalls, although Martin Doucha tried to get rid of
> some static inline (moving them to C files in lib/) to avoid compilation problems.
>
> But again, this is worth for some generic files long enough e.g.
> lib/tst_netlink.c or lib/tst_netdevice.c.
>
> Also static inline makes code to grow, but adding new C source to LTP libs makes
> IMHO bigger code size increase (besides we don't care about LTP size anyway,
> otherwise we would change linking similar to busybox - single binary providing
> many functions).
Thanks for your review, I will address your points in the next revision :)
>
>> +{
>> + return tst_syscall(__NR_modify_ldt, func, ptr, bytecount);
>> +}
>> +
>> +static int safe_modify_ldt(const char *file, const int lineno, int func,
>> + void *ptr, unsigned long bytecount)
>> +{
> And here as well.
>
> Kind regards,
> Petr
>
>> + int rval;
>> +
>> + rval = modify_ldt(func, ptr, bytecount);
>> + if (rval == -1)
>> + tst_brk_(file, lineno, TBROK | TERRNO,
>> + "modify_ldt(%d, %p, %lu)", func, ptr, bytecount);
>> +
>> + return rval;
>> +}
>> +
>> +#define SAFE_MODIFY_LDT(func, ptr, bytecount) \
>> + safe_modify_ldt(__FILE__, __LINE__, (func), (ptr), (bytecount))
>> +
>> +#endif /* LAPI_LDT_H__ */
More information about the ltp
mailing list