diff --git a/include/tabby/printer.h b/include/tabby/printer.h index 8c754f6..dc1d3e6 100644 --- a/include/tabby/printer.h +++ b/include/tabby/printer.h @@ -36,8 +36,7 @@ typedef struct _tabby_printer_packet { */ int tabby_printer_packet_recv(int fd, tabby_printer_packet *header, - void *body, - uint16_t *checksum); + void *body); /* * For sending printer data packets to a Game Boy Printer diff --git a/src/printer.c b/src/printer.c index a1bdd6d..54464dd 100644 --- a/src/printer.c +++ b/src/printer.c @@ -26,8 +26,7 @@ static uint16_t checksum(tabby_printer_packet *header, void *body) { int tabby_printer_packet_recv(int fd, tabby_printer_packet *header, - void *body, - uint16_t *sum) { + void *body) { ssize_t len; size_t i = 0, @@ -35,9 +34,9 @@ int tabby_printer_packet_recv(int fd, uint8_t value; - memset(header, '\0', sizeof(*header)); + uint16_t sum = 0; - *sum = 0; + memset(header, '\0', sizeof(*header)); while ((len = read(fd, &value, 1)) >= 0) { if (i == 0) { @@ -72,12 +71,12 @@ int tabby_printer_packet_recv(int fd, } else if (b < header->size) { ((uint8_t *)body)[b++] = value; } else if (b == header->size) { - *sum = value; + sum = value; b++; } else if (b == header->size + 1) { - *sum |= value << 8; + sum |= value << 8; - if (checksum(header, body) != *sum) { + if (checksum(header, body) != sum) { errno = EIO; goto error_io;