From: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH 1/3] Add SAFE_SEMCTL() and SAFE_SEMGET() macro
Date: Wed, 23 Dec 2020 16:20:01 +0800 [thread overview]
Message-ID: <5FE2FDB1.9090402@cn.fujitsu.com> (raw)
In-Reply-To: <1608626908-8117-1-git-send-email-zhufy.jy@cn.fujitsu.com>
Hi Feiyu
> +int safe_semctl(const char *file, const int lineno, int semid, int semnum,
> + int cmd, ...)
> +{
> + int rval;
> + va_list va;
> + union semun un;
> +
> + va_start(va, cmd);
> +
> + un = va_arg(va, union semun);
> +
> + va_end(va);
> +
> + rval = semctl(semid, semnum, cmd, un);
> +
> + if (rval == -1) {
> + tst_brk_(file, lineno, TBROK | TERRNO,
> + "semctl(%i, %i, %i,...) failed", semid, semnum, cmd);
> + } else if (ret_check(cmd, rval)) {
It looks good to me,
Reviewed-by:Yang Xu <xuyang2018.jy@cn.fujitsucom.com>
BTW, we can add some cmds in ret_check function in separate patch.
From semctl man-pages, it looks like SETALL/SETVAL also return 0 on
success. Also for shmctl man-pages, SHM_LOCK/SHM_UNLOCK also return 0 on
success. When we write these new cases in future, these cmds should be
added into ret_check function.
Best Regards
Yang Xu
> + tst_brk_(file, lineno, TBROK | TERRNO,
> + "Invalid semctl(%i, %i, %i,...) return value %d", semid,
> + semnum, cmd, rval);
> + }
> +
> + return rval;
> +}
> --
prev parent reply other threads:[~2020-12-23 8:20 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-22 8:48 [LTP] [PATCH 1/3] Add SAFE_SEMCTL() and SAFE_SEMGET() macro Feiyu Zhu
2020-12-22 8:48 ` [LTP] [PATCH 2/3] lapi/sem.h: Add SEM_STAT_ANY Feiyu Zhu
2020-12-23 8:29 ` Yang Xu
2020-12-22 8:48 ` [LTP] [PATCH 3/3] syscalls/ipc: semctl09: add a test for SEM_STAT_ANY Feiyu Zhu
2020-12-23 8:57 ` Yang Xu
2020-12-23 8:20 ` Yang Xu [this message]
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=5FE2FDB1.9090402@cn.fujitsu.com \
--to=xuyang2018.jy@cn.fujitsu.com \
--cc=ltp@lists.linux.it \
/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