From 10485fedae8a6760ec8c8cd8451311da491bd172 Mon Sep 17 00:00:00 2001 From: Solomon Peachy Date: Sat, 2 Feb 2013 11:34:39 -0500 Subject: [PATCH] [selphy] Make sure we're using blocking I/O, and fix warnings. --- selphy_print.c | 17 +++++++++++++++-- selphy_print_common.h | 2 +- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/selphy_print.c b/selphy_print.c index 25d22cd..8315a6b 100644 --- a/selphy_print.c +++ b/selphy_print.c @@ -307,8 +307,8 @@ static int find_and_enumerate(struct libusb_context *ctx, libusb_get_string_descriptor_ascii(dev, desc.iSerialNumber, serial, STR_LEN_MAX); } - if (!strlen(serial)) - strcpy(serial, "NONE"); + if (!strlen((char*)serial)) + strcpy((char*)serial, "NONE"); DEBUG("%s%sPID: %04X Product: '%s' Serial: '%s'\n", (!valid) ? "UNRECOGNIZED: " : "", @@ -405,6 +405,19 @@ int main (int argc, char **argv) } } + /* Ensure we're using BLOCKING I/O */ + i = fcntl(data_fd, F_GETFL, 0); + if (i < 0) { + perror("ERROR:Can't open input"); + exit(1); + } + i &= ~O_NONBLOCK; + i = fcntl(data_fd, F_SETFL, 0); + if (i < 0) { + perror("ERROR:Can't open input"); + exit(1); + } + /* Start parsing URI 'selphy://PID/SERIAL' */ if (strncmp(URI_PREFIX, uri, strlen(URI_PREFIX))) { ERROR("Invalid URI prefix (%s)\n", uri); diff --git a/selphy_print_common.h b/selphy_print_common.h index 0b6c1be..a5eaefa 100644 --- a/selphy_print_common.h +++ b/selphy_print_common.h @@ -25,7 +25,7 @@ * */ -#define VERSION "0.43" +#define VERSION "0.44" #define DEBUG( ... ) fprintf(stderr, "DEBUG: " __VA_ARGS__ ) #define ERROR( ... ) fprintf(stderr, "ERROR: " __VA_ARGS__ )