Using ARRAY_SIZE replace sizeof()/sizeof()
Signed-off-by: Wei,Jiangang <[email protected]>
---
testcases/kernel/syscalls/setreuid/setreuid02.c | 2 +-
testcases/kernel/syscalls/setreuid/setreuid03.c | 2 +-
testcases/kernel/syscalls/setreuid/setreuid04.c | 3 +--
testcases/kernel/syscalls/setreuid/setreuid05.c | 2 +-
testcases/kernel/syscalls/sysctl/sysctl01.c | 4 +---
testcases/kernel/syscalls/sysctl/sysctl03.c | 9 ++++-----
testcases/kernel/syscalls/sysctl/sysctl04.c | 3 +--
testcases/kernel/syscalls/sysctl/sysctl05.c | 4 +---
8 files changed, 11 insertions(+), 18 deletions(-)
diff --git a/testcases/kernel/syscalls/setreuid/setreuid02.c
b/testcases/kernel/syscalls/setreuid/setreuid02.c
index 9cc0333..1257046 100644
--- a/testcases/kernel/syscalls/setreuid/setreuid02.c
+++ b/testcases/kernel/syscalls/setreuid/setreuid02.c
@@ -58,7 +58,7 @@ static struct test_data_t {
&bin.pw_uid, &neg_one, &bin, &root, "After setreuid(bin, -1)"}, {
&root.pw_uid, &neg_one, &root, &root, "After setreuid(-1, root)"},};
-int TST_TOTAL = sizeof(test_data) / sizeof(test_data[0]);
+int TST_TOTAL = ARRAY_SIZE(test_data);
static void setup(void);
static void cleanup(void);
diff --git a/testcases/kernel/syscalls/setreuid/setreuid03.c
b/testcases/kernel/syscalls/setreuid/setreuid03.c
index 2533908..34fa606 100644
--- a/testcases/kernel/syscalls/setreuid/setreuid03.c
+++ b/testcases/kernel/syscalls/setreuid/setreuid03.c
@@ -83,7 +83,7 @@ static struct test_data_t {
&nobody.pw_uid, &bin.pw_uid, &fail, &nobody, &nobody,
"After setreuid(nobody, bin),"},};
-int TST_TOTAL = sizeof(test_data) / sizeof(test_data[0]);
+int TST_TOTAL = ARRAY_SIZE(test_data);
static void setup(void);
static void cleanup(void);
diff --git a/testcases/kernel/syscalls/setreuid/setreuid04.c
b/testcases/kernel/syscalls/setreuid/setreuid04.c
index f05f61d..2080f47 100644
--- a/testcases/kernel/syscalls/setreuid/setreuid04.c
+++ b/testcases/kernel/syscalls/setreuid/setreuid04.c
@@ -54,8 +54,7 @@ struct test_data_t {
&nobody.pw_uid, &nobody.pw_uid, &nobody, &nobody,
"After setreuid(-1, -1),"},};
-/*int TST_TOTAL = sizeof(test_data)/sizeof(test_data[0]);*/
-int TST_TOTAL = 2;
+int TST_TOTAL = ARRAY_SIZE(test_data);
static void setup(void);
static void cleanup(void);
diff --git a/testcases/kernel/syscalls/setreuid/setreuid05.c
b/testcases/kernel/syscalls/setreuid/setreuid05.c
index d6c4c6f..98436d3 100644
--- a/testcases/kernel/syscalls/setreuid/setreuid05.c
+++ b/testcases/kernel/syscalls/setreuid/setreuid05.c
@@ -76,7 +76,7 @@ struct test_data_t {
&neg_one, &bin.pw_uid, &fail, &daemonpw, &daemonpw,
"After setreuid(-1, bin),"},};
-int TST_TOTAL = sizeof(test_data) / sizeof(test_data[0]);
+int TST_TOTAL = ARRAY_SIZE(test_data);
static void setup(void);
static void cleanup(void);
diff --git a/testcases/kernel/syscalls/sysctl/sysctl01.c
b/testcases/kernel/syscalls/sysctl/sysctl01.c
index fe62905..de6c6aa 100644
--- a/testcases/kernel/syscalls/sysctl/sysctl01.c
+++ b/testcases/kernel/syscalls/sysctl/sysctl01.c
@@ -66,8 +66,6 @@ static int sysctl(int *name, int nlen, void *oldval, size_t *
oldlenp,
return syscall(__NR__sysctl, &args);
}
-#define SIZE(x) sizeof(x)/sizeof(x[0])
-
struct utsname buf;
char osname[BUFSIZ];
size_t osnamelth;
@@ -115,7 +113,7 @@ int main(int ac, char **av)
for (i = 0; i < TST_TOTAL; ++i) {
- osnamelth = SIZE(osname);
+ osnamelth = ARRAY_SIZE(osname);
switch (i) {
case 0:
diff --git a/testcases/kernel/syscalls/sysctl/sysctl03.c
b/testcases/kernel/syscalls/sysctl/sysctl03.c
index 88890b6..52e8ce6 100644
--- a/testcases/kernel/syscalls/sysctl/sysctl03.c
+++ b/testcases/kernel/syscalls/sysctl/sysctl03.c
@@ -86,7 +86,6 @@ int sysctl(int *name, int nlen, void *oldval, size_t *
oldlenp,
return syscall(__NR__sysctl, &args);
}
-#define SIZE(x) sizeof(x)/sizeof(x[0])
#define OSNAMESZ 100
void setup(void);
@@ -123,9 +122,9 @@ int main(int ac, char **av)
tst_count = 0;
strcpy(osname, "Linux");
- osnamelth = SIZE(osname);
+ osnamelth = ARRAY_SIZE(osname);
- TEST(sysctl(name, SIZE(name), 0, 0, osname, osnamelth));
+ TEST(sysctl(name, ARRAY_SIZE(name), 0, 0, osname, osnamelth));
if (TEST_RETURN != -1) {
tst_resm(TFAIL, "sysctl(2) succeeded unexpectedly");
@@ -142,7 +141,7 @@ int main(int ac, char **av)
}
}
- osnamelth = SIZE(osname);
+ osnamelth = ARRAY_SIZE(osname);
if ((ltpuser = getpwnam("nobody")) == NULL) {
tst_brkm(TBROK, cleanup, "getpwnam() failed");
}
@@ -158,7 +157,7 @@ int main(int ac, char **av)
}
if (pid == 0) {
- TEST(sysctl(name, SIZE(name), 0, 0, osname, osnamelth));
+ TEST(sysctl(name, ARRAY_SIZE(name), 0, 0, osname,
osnamelth));
if (TEST_RETURN != -1) {
tst_resm(TFAIL, "call succeeded unexpectedly");
diff --git a/testcases/kernel/syscalls/sysctl/sysctl04.c
b/testcases/kernel/syscalls/sysctl/sysctl04.c
index ff63364..cb2ca65 100644
--- a/testcases/kernel/syscalls/sysctl/sysctl04.c
+++ b/testcases/kernel/syscalls/sysctl/sysctl04.c
@@ -67,7 +67,6 @@ int sysctl(int *name, int nlen, void *oldval, size_t *
oldlenp,
return syscall(__NR__sysctl, &args);
}
-#define SIZE(x) sizeof(x)/sizeof(x[0])
#define OSNAMESZ 100
void setup(void);
@@ -98,7 +97,7 @@ int main(int ac, char **av)
setup();
- osnamelth = SIZE(osname);
+ osnamelth = ARRAY_SIZE(osname);
for (lc = 0; TEST_LOOPING(lc); lc++) {
diff --git a/testcases/kernel/syscalls/sysctl/sysctl05.c
b/testcases/kernel/syscalls/sysctl/sysctl05.c
index e6f09b2..eb7fed9 100644
--- a/testcases/kernel/syscalls/sysctl/sysctl05.c
+++ b/testcases/kernel/syscalls/sysctl/sysctl05.c
@@ -69,8 +69,6 @@ int sysctl(int *name, int nlen, void *oldval, size_t *
oldlenp,
return syscall(__NR__sysctl, &args);
}
-#define SIZE(x) sizeof(x)/sizeof(x[0])
-
char osname[BUFSIZ];
size_t osnamelth;
@@ -117,7 +115,7 @@ int main(int ac, char **av)
for (i = 0; i < TST_TOTAL; ++i) {
- osnamelth = SIZE(osname);
+ osnamelth = ARRAY_SIZE(osname);
TEST(sysctl(testcases[i].name, testcases[i].size,
testcases[i].oldval, testcases[i].oldlen,
--
1.9.3
------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list