public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: chrubis@suse.cz
To: Stanislav Kholmanskikh <stanislav.kholmanskikh@oracle.com>
Cc: vasily.isaenko@oracle.com, ltp-list@lists.sourceforge.net
Subject: Re: [LTP] [PATCH V3 2/3] fixes for 16-bit syscalls testcases
Date: Mon, 2 Sep 2013 17:23:01 +0200	[thread overview]
Message-ID: <20130902152301.GC26252@rei> (raw)
In-Reply-To: <1377782535-15955-3-git-send-email-stanislav.kholmanskikh@oracle.com>

> +/*
> + * LTP_COMPAT16_IS_DEFINED(SNAME) - if true, then __NR_SNAME
> + *   is a 16-bit version of SNAME() syscall
> + *
> + * LTP_COMPAT16_IF_DEFINED(SNAME, ...) - action to execute
> + *   if 16-bit version of SNAME syscall is supported
> + *
> + * LTP_COMPAT16_IF_UNDEFINED(SNAME) - action to execute
> + *   if 16-bit version of SNAME syscall is not supported
> + */
> +#define LTP_COMPAT16_IS_DEFINED(SNAME) \
> +	(__NR_##SNAME##32 != __LTP__NR_INVALID_SYSCALL)
> +
> +#define LTP_COMPAT16_IF_DEFINED(SNAME, ...) \
> +	return ltp_syscall(__NR_##SNAME, ##__VA_ARGS__);
> +
> +#define LTP_COMPAT16_IF_UNDEFINED(SNAME) \
> +	tst_brkm(TCONF, cleanup, \
> +		"16-bit version of %s() is not supported on your platform", \
> +		#SNAME);

What I do not like is the calling cleanup from this part of the code, it
was not passed there and the code will break badly if you name the
cleanup function differently (or create more of them, cleanup, cleanup1,
...).

What I would do here is to set errno to ENOSYS and return a failure. And
let the test that called the function handle it.

Or we can add a cleanup parameter to the all caps functions bellow.

> +int
> +SETGROUPS(size_t gidsetsize, GID_T *list16)
> +{
> +# if LTP_COMPAT16_IS_DEFINED(setgroups)
> +	LTP_COMPAT16_IF_DEFINED(setgroups, gidsetsize, list16)
> +# else
> +	LTP_COMPAT16_IF_UNDEFINED(setgroups)
> +# endif
> +}
> +
> +int
> +GETGROUPS(int gidsetsize, GID_T *list16)
> +{
> +# if LTP_COMPAT16_IS_DEFINED(getgroups)
> +	LTP_COMPAT16_IF_DEFINED(getgroups, gidsetsize, list16)
> +# else
> +	LTP_COMPAT16_IF_UNDEFINED(getgroups)
> +# endif
> +}
> +
> +#else
> +int
> +SETGROUPS(size_t size, const GID_T *list)
> +{
> +	return setgroups(size, list);
> +}
> +
> +int
> +GETGROUPS(int size, GID_T *list)
> +{
> +	return getgroups(size, list);
> +}
> +
> +#endif	/* TST_USE_COMPAT16_SYSCALL */
> +
> +#endif /* __SETGROUPS_COMPAT_16_H__ */

We can even simplify this macros. At least the innter part of SETGROUPS
and GETGROUPS could be created by a single macro:

COMPAT16_SYSCALL(setgroups, gitsetsize, list16)

#define COMPAT16_SYSCALL(sys_name, ...) \
# ifdef TST_USE_COMPAT16_SYSCALL
#  if ....
	return ltp_syscall(sys_name, ##__VA_ARGS__);
#  else
	errno = ENOSYS;
	return -1;
#  fi
# else
	return sys_name(__VA_ARGS__);
# endif

In case that the syscall and libcall params does not match we can use
only the part enclosed in the ifdef TST_USE_COMPAT16_SYSCALL.

-- 
Cyril Hrubis
chrubis@suse.cz

------------------------------------------------------------------------------
Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more!
Discover the easy way to master current and previous Microsoft technologies
and advance your career. Get an incredible 1,500+ hours of step-by-step
tutorial videos with LearnDevNow. Subscribe today and save!
http://pubads.g.doubleclick.net/gampad/clk?id=58040911&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

  parent reply	other threads:[~2013-09-02 15:22 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-16  7:10 [LTP] [PATCH] syscalls/setgroups: fix implicit SETGROUPS parameter casting Stanislav Kholmanskikh
2013-08-22 13:13 ` chrubis
     [not found]   ` <52174875.9030606@oracle.com>
2013-08-23 11:39     ` chrubis
     [not found]       ` <521B331D.7050902@oracle.com>
2013-08-26 11:30         ` chrubis
     [not found]           ` <521B4D82.2060007@oracle.com>
2013-08-26 14:16             ` chrubis
     [not found]               ` <521B6875.8010202@oracle.com>
2013-08-27  9:35                 ` [LTP] [PATCH V2 1/2] syscalls/setgroups: fix 16-bit versions of the testcases Stanislav Kholmanskikh
2013-08-27  9:35                 ` [LTP] [PATCH V2 2/2] syscalls/getgroups: added checks for 16-bit getgroups() syscall Stanislav Kholmanskikh
2013-08-27 12:16                   ` chrubis
     [not found]                     ` <521D9C44.8090607@oracle.com>
2013-08-28  9:55                       ` chrubis
     [not found]                         ` <1377782535-15955-3-git-send-email-stanislav.kholmanskikh@oracle.com>
2013-09-02 15:23                           ` chrubis [this message]
     [not found]                             ` <52259811.3000604@oracle.com>
2013-09-03 10:11                               ` [LTP] [PATCH V3 2/3] fixes for 16-bit syscalls testcases chrubis
     [not found]                                 ` <1378215677-14258-1-git-send-email-stanislav.kholmanskikh@oracle.com>
2013-09-04 13:37                                   ` [LTP] [PATCH V3.1 2/2] " chrubis
     [not found]                                     ` <1378364509-20971-1-git-send-email-stanislav.kholmanskikh@oracle.com>
2013-09-05 11:07                                       ` [LTP] [PATCH V4] 16-bit syscalls fixes chrubis
2013-09-09 12:07                                       ` chrubis
     [not found]                         ` <1377782535-15955-4-git-send-email-stanislav.kholmanskikh@oracle.com>
2013-09-02 15:28                           ` [LTP] [PATCH V3 3/3] syscalls/getgroups: added checks for 16-bit getgroups() syscall chrubis
     [not found]                         ` <1377782535-15955-2-git-send-email-stanislav.kholmanskikh@oracle.com>
2013-09-02 15:59                           ` [LTP] [PATCH V3 1/3] syscalls/utils/compat_16.mk: fix build dependencies chrubis
     [not found]                             ` <52257D67.5020900@oracle.com>
2013-09-03 11:06                               ` chrubis
2013-08-27 11:22                 ` [LTP] [PATCH] syscalls/setgroups: fix implicit SETGROUPS parameter casting chrubis

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=20130902152301.GC26252@rei \
    --to=chrubis@suse.cz \
    --cc=ltp-list@lists.sourceforge.net \
    --cc=stanislav.kholmanskikh@oracle.com \
    --cc=vasily.isaenko@oracle.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