[LTP] [PATCH v1] minmax: fix type warnings
Edward Liaw
edliaw@google.com
Thu Sep 15 22:51:08 CEST 2022
Hey Petr, Cyril,
I'm second-guessing how to handle the off_t and int comparisons in
mem/mmapstress01 and 10. Would it have been better to do the following?
diff --git a/testcases/kernel/mem/mmapstress/mmapstress01.c
b/testcases/kernel/mem/mmapstress/mmapstress01.c
index f425c223d..934e83006 100644
--- a/testcases/kernel/mem/mmapstress/mmapstress01.c
+++ b/testcases/kernel/mem/mmapstress/mmapstress01.c
@@ -143,7 +143,6 @@ int main(int argc, char *argv[])
pid_t pid;
uchar_t *buf = NULL;
unsigned int seed;
- int pagesize = sysconf(_SC_PAGE_SIZE);
float alarmtime = 0;
struct sigaction sa;
unsigned i;
@@ -154,8 +153,10 @@ int main(int argc, char *argv[])
time_t t;
#ifdef LARGE_FILE
off64_t bytes_left;
+ off64_t pagesize = sysconf(_SC_PAGE_SIZE);
#else /* LARGE_FILE */
off_t bytes_left;
+ off_t pagesize = sysconf(_SC_PAGE_SIZE);
#endif /* LARGE_FILE */
const char *filename = "mmapstress01.out";
@@ -310,7 +311,7 @@ int main(int argc, char *argv[])
anyfail();
}
for (bytes_left = filesize; bytes_left; bytes_left -= c) {
- write_cnt = MIN(pagesize, (int)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/mmapstress10.c
b/testcases/kernel/mem/mmapstress/mmapstress10.c
index 53f02c1f6..1756f7081 100644
--- a/testcases/kernel/mem/mmapstress/mmapstress10.c
+++ b/testcases/kernel/mem/mmapstress/mmapstress10.c
@@ -171,7 +171,6 @@ int main(int argc, char *argv[])
pid_t wr_pid = 0;
uchar_t *buf = NULL;
unsigned int seed;
- int pagesize = sysconf(_SC_PAGE_SIZE);
float alarmtime = 0;
struct sigaction sa;
unsigned i;
@@ -182,8 +181,10 @@ int main(int argc, char *argv[])
time_t t;
#ifdef LARGE_FILE
off64_t bytes_left;
+ off64_t pagesize = sysconf(_SC_PAGE_SIZE);
#else /* LARGE_FILE */
off_t bytes_left;
+ off_t pagesize = sysconf(_SC_PAGE_SIZE);
#endif /* LARGE_FILE */
progname = *argv;
@@ -360,7 +361,7 @@ int main(int argc, char *argv[])
}
for (bytes_left = filesize; bytes_left; bytes_left -= c) {
- write_cnt = MIN(pagesize, (int)bytes_left);
+ write_cnt = MIN(pagesize, bytes_left);
if ((c = write(fd, (char *)buf, write_cnt)) != write_cnt) {
if (c == -1) {
perror("write error");
Thanks,
Edward
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20220915/4be7a09d/attachment-0001.htm>
More information about the ltp
mailing list