Skip to content

Commit

Permalink
tools: use mmap_fd() in qpencode instead of open coding it
Browse files Browse the repository at this point in the history
  • Loading branch information
DerDakon committed Sep 30, 2023
1 parent 10aa357 commit fbd422a
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions tools/qp.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include <fmt.h>
#include <netio.h>
#include <mmap.h>
#include <qremote/qrdata.h>
#include <sstring.h>

Expand Down Expand Up @@ -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));
Expand Down

0 comments on commit fbd422a

Please sign in to comment.