From: Li Wang <liwang@redhat.com>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH 1/3] include: replace min/max macro by the new definition
Date: Fri, 11 Mar 2022 13:46:01 +0800 [thread overview]
Message-ID: <20220311054603.57328-2-liwang@redhat.com> (raw)
In-Reply-To: <20220311054603.57328-1-liwang@redhat.com>
Signed-off-by: Li Wang <liwang@redhat.com>
---
include/ipcmsg.h | 2 --
include/libnewipc.h | 1 -
testcases/kernel/mem/mmapstress/mmapstress01.c | 3 +--
testcases/kernel/mem/mmapstress/mmapstress09.c | 1 -
testcases/kernel/mem/mmapstress/mmapstress10.c | 3 +--
testcases/kernel/security/cap_bound/cap_bounds_r.c | 3 +--
testcases/kernel/security/cap_bound/cap_bounds_rw.c | 7 +++----
testcases/kernel/syscalls/ipc/msgstress/msgstress01.c | 2 +-
testcases/kernel/syscalls/ipc/msgstress/msgstress02.c | 2 +-
9 files changed, 8 insertions(+), 16 deletions(-)
diff --git a/include/ipcmsg.h b/include/ipcmsg.h
index d89894b72..3b3fa32c0 100644
--- a/include/ipcmsg.h
+++ b/include/ipcmsg.h
@@ -43,8 +43,6 @@ void setup(void);
#define NR_MSGQUEUES 16 /* MSGMNI as defined in linux/msg.h */
-#define min(a, b) (((a) < (b)) ? (a) : (b))
-
typedef struct mbuf { /* a generic message structure */
long mtype;
char mtext[MSGSIZE + 1]; /* add 1 here so the message can be 1024 */
diff --git a/include/libnewipc.h b/include/libnewipc.h
index 9eec31763..1e126ca1c 100644
--- a/include/libnewipc.h
+++ b/include/libnewipc.h
@@ -31,7 +31,6 @@
#define MSGSIZE 1024
#define MSGTYPE 1
#define NR_MSGQUEUES 16
-#define min(a, b) (((a) < (b)) ? (a) : (b))
#define SEM_RD 0400
#define SEM_ALT 0200
diff --git a/testcases/kernel/mem/mmapstress/mmapstress01.c b/testcases/kernel/mem/mmapstress/mmapstress01.c
index 3b4b1ac24..c16b50a6d 100644
--- a/testcases/kernel/mem/mmapstress/mmapstress01.c
+++ b/testcases/kernel/mem/mmapstress/mmapstress01.c
@@ -95,7 +95,6 @@ void ok_exit();
#undef roundup
#endif
#define roundup(x, y) ((((x)+((y)-1))/(y))*(y))
-#define min(x, y) (((x) < (y)) ? (x) : (y))
extern time_t time(time_t *);
extern char *ctime(const time_t *);
@@ -311,7 +310,7 @@ int main(int argc, char *argv[])
anyfail();
}
for (bytes_left = filesize; bytes_left; bytes_left -= c) {
- write_cnt = min(pagesize, bytes_left);
+ write_cnt = MIN(pagesize, bytes_left);
if ((c = write(fd, buf, write_cnt)) != write_cnt) {
if (c == -1) {
perror("write error");
diff --git a/testcases/kernel/mem/mmapstress/mmapstress09.c b/testcases/kernel/mem/mmapstress/mmapstress09.c
index 2c710df1e..0a8da0006 100644
--- a/testcases/kernel/mem/mmapstress/mmapstress09.c
+++ b/testcases/kernel/mem/mmapstress/mmapstress09.c
@@ -78,7 +78,6 @@ void ok_exit();
#undef roundup
#endif
#define roundup(x, y) ((((x)+((y)-1))/(y))*(y))
-#define min(x, y) (((x) < (y)) ? (x) : (y))
extern time_t time(time_t *);
extern char *ctime(const time_t *);
diff --git a/testcases/kernel/mem/mmapstress/mmapstress10.c b/testcases/kernel/mem/mmapstress/mmapstress10.c
index 26ea98bc1..28b4f1e91 100644
--- a/testcases/kernel/mem/mmapstress/mmapstress10.c
+++ b/testcases/kernel/mem/mmapstress/mmapstress10.c
@@ -106,7 +106,6 @@ void ok_exit();
#undef roundup
#endif
#define roundup(x, y) ((((x)+((y)-1))/(y))*(y))
-#define min(x, y) (((x) < (y)) ? (x) : (y))
#define SIZE_MAX UINT_MAX
@@ -361,7 +360,7 @@ int main(int argc, char *argv[])
}
for (bytes_left = filesize; bytes_left; bytes_left -= c) {
- write_cnt = min(pagesize, bytes_left);
+ write_cnt = MIN(pagesize, bytes_left);
if ((c = write(fd, (char *)buf, write_cnt)) != write_cnt) {
if (c == -1) {
perror("write error");
diff --git a/testcases/kernel/security/cap_bound/cap_bounds_r.c b/testcases/kernel/security/cap_bound/cap_bounds_r.c
index d7c2bf0ae..28f320fd9 100644
--- a/testcases/kernel/security/cap_bound/cap_bounds_r.c
+++ b/testcases/kernel/security/cap_bound/cap_bounds_r.c
@@ -85,9 +85,8 @@ int main(void)
* We could test using kernel API, but that's what we're
* testing... So let's take an insanely high value */
#define INSANE 63
-#define max(x,y) (x > y ? x : y)
#if HAVE_DECL_PR_CAPBSET_READ
- ret = prctl(PR_CAPBSET_READ, max(INSANE, CAP_LAST_CAP + 1));
+ ret = prctl(PR_CAPBSET_READ, MAX(INSANE, CAP_LAST_CAP + 1));
#else
errno = ENOSYS;
ret = -1;
diff --git a/testcases/kernel/security/cap_bound/cap_bounds_rw.c b/testcases/kernel/security/cap_bound/cap_bounds_rw.c
index 503853c5b..a0d2111d6 100644
--- a/testcases/kernel/security/cap_bound/cap_bounds_rw.c
+++ b/testcases/kernel/security/cap_bound/cap_bounds_rw.c
@@ -115,18 +115,17 @@ int main(void)
* We could test using kernel API, but that's what we're
* testing... So let's take an insanely high value */
#define INSANE 63
-#define max(x,y) (x > y ? x : y)
#if HAVE_DECL_PR_CAPBSET_DROP
- ret = prctl(PR_CAPBSET_DROP, max(INSANE, CAP_LAST_CAP + 1));
+ ret = prctl(PR_CAPBSET_DROP, MAX(INSANE, CAP_LAST_CAP + 1));
#else
errno = ENOSYS;
ret = -1;
#endif
if (ret != -1) {
tst_resm(TFAIL, "prctl(PR_CAPBSET_DROP, %d) returned %d",
- max(INSANE, CAP_LAST_CAP + 1), ret);
+ MAX(INSANE, CAP_LAST_CAP + 1), ret);
tst_resm(TINFO, " %d is should not exist",
- max(INSANE, CAP_LAST_CAP + 1));
+ MAX(INSANE, CAP_LAST_CAP + 1));
tst_exit();
}
for (i = 0; i <= cap_last_cap; i++) {
diff --git a/testcases/kernel/syscalls/ipc/msgstress/msgstress01.c b/testcases/kernel/syscalls/ipc/msgstress/msgstress01.c
index 0a660c042..84e338437 100644
--- a/testcases/kernel/syscalls/ipc/msgstress/msgstress01.c
+++ b/testcases/kernel/syscalls/ipc/msgstress/msgstress01.c
@@ -280,7 +280,7 @@ void setup(void)
* that are not necessary for this test.
* That's why we define NR_MSGQUEUES as a high boundary for it.
*/
- MSGMNI = min(nr_msgqs, NR_MSGQUEUES);
+ MSGMNI = MIN(nr_msgqs, NR_MSGQUEUES);
}
void cleanup(void)
diff --git a/testcases/kernel/syscalls/ipc/msgstress/msgstress02.c b/testcases/kernel/syscalls/ipc/msgstress/msgstress02.c
index e15131043..a0f894b05 100644
--- a/testcases/kernel/syscalls/ipc/msgstress/msgstress02.c
+++ b/testcases/kernel/syscalls/ipc/msgstress/msgstress02.c
@@ -385,7 +385,7 @@ void setup(void)
* that are not necessary for this test.
* That's why we define NR_MSGQUEUES as a high boundary for it.
*/
- MSGMNI = min(nr_msgqs, NR_MSGQUEUES);
+ MSGMNI = MIN(nr_msgqs, NR_MSGQUEUES);
}
void cleanup(void)
--
2.31.1
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2022-03-11 5:46 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-11 5:46 [LTP] [PATCH 0/3] refine the MIN/MAX macros Li Wang
2022-03-11 5:46 ` Li Wang [this message]
2022-03-23 10:19 ` [LTP] [PATCH 1/3] include: replace min/max macro by the new definition Petr Vorel
2022-03-24 2:52 ` Li Wang
2022-03-11 5:46 ` [LTP] [PATCH 2/3] lib: adding unnecessary pointer comparison Li Wang
2022-03-23 10:22 ` Petr Vorel
2022-03-11 5:46 ` [LTP] [PATCH 3/3] minmax: ensure the comparison numbers have compatible type Li Wang
2022-03-11 8:52 ` Li Wang
2022-03-23 13:33 ` 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=20220311054603.57328-2-liwang@redhat.com \
--to=liwang@redhat.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