diff --git a/tools/qp.c b/tools/qp.c index e0cb662d..55b0c98e 100644 --- a/tools/qp.c +++ b/tools/qp.c @@ -7,6 +7,7 @@ #include #include +#include #include #include @@ -103,17 +104,9 @@ int main(int argc, char *argv[]) if (fd < 0) return errno; - struct stat st; - int i = fstat(fd, &st); - if (i) { - close(fd); - return i; - } - - msgsize = st.st_size; - msgdata = mmap(NULL, msgsize, PROT_READ, MAP_SHARED, fd, 0); + msgdata = mmap_fd(fd, &msgsize); - if (msgdata == MAP_FAILED) + if (msgdata == NULL) return errno; send_data(need_recode(msgdata, msgsize));