summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2013-05-13 09:59:32 +0200
committerHans de Goede <hdegoede@redhat.com>2013-05-13 09:59:32 +0200
commit65b99a49dc4d5d4cf16ba880d3377196e96f1bc5 (patch)
tree3f1d2d3e8672a07a4f54e258739c60527febf386
parentc7e8bfe7f88ea11b31ebe115a629fb1cc903f7bc (diff)
usbredirserver/testclient: Error check fcntl calls
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
-rw-r--r--usbredirserver/usbredirserver.c14
-rw-r--r--usbredirtestclient/usbredirtestclient.c14
2 files changed, 23 insertions, 5 deletions
diff --git a/usbredirserver/usbredirserver.c b/usbredirserver/usbredirserver.c
index c45a27c..d2765c6 100644
--- a/usbredirserver/usbredirserver.c
+++ b/usbredirserver/usbredirserver.c
@@ -189,7 +189,7 @@ static void quit_handler(int sig)
int main(int argc, char *argv[])
{
- int o, server_fd = -1;
+ int o, flags, server_fd = -1;
char *endptr, *delim;
int port = 4000;
int usbbus = -1;
@@ -307,8 +307,16 @@ int main(int argc, char *argv[])
break;
}
- fcntl(client_fd, F_SETFL,
- (long)fcntl(client_fd, F_GETFL) | O_NONBLOCK);
+ flags = fcntl(client_fd, F_GETFL);
+ if (flags == -1) {
+ perror("fcntl F_GETFL");
+ break;
+ }
+ flags = fcntl(client_fd, F_SETFL, flags | O_NONBLOCK);
+ if (flags == -1) {
+ perror("fcntl F_SETFL O_NONBLOCK");
+ break;
+ }
/* Try to find the specified usb device */
if (usbvendor != -1) {
diff --git a/usbredirtestclient/usbredirtestclient.c b/usbredirtestclient/usbredirtestclient.c
index a9123da..42b16dc 100644
--- a/usbredirtestclient/usbredirtestclient.c
+++ b/usbredirtestclient/usbredirtestclient.c
@@ -189,7 +189,7 @@ static void quit_handler(int sig)
int main(int argc, char *argv[])
{
- int o;
+ int o, flags;
char *endptr, *server;
struct addrinfo *r, *res, hints;
struct sigaction act;
@@ -265,7 +265,17 @@ int main(int argc, char *argv[])
exit(1);
}
- fcntl(client_fd, F_SETFL, (long)fcntl(client_fd, F_GETFL) | O_NONBLOCK);
+ flags = fcntl(client_fd, F_GETFL);
+ if (flags == -1) {
+ perror("fcntl F_GETFL");
+ exit(1);
+ }
+ flags = fcntl(client_fd, F_SETFL, flags | O_NONBLOCK);
+ if (flags == -1) {
+ perror("fcntl F_SETFL O_NONBLOCK");
+ exit(1);
+ }
+
parser = usbredirparser_create();
if (!parser) {
exit(1);