[libdvbpsi-devel] examples/dvbinfo/udp.c: Check setsockopt return values (CID 17231)

Jean-Paul Saman git at videolan.org
Wed Apr 16 15:53:34 CEST 2014


libdvbpsi | branch: master | Jean-Paul Saman <jpsaman at videolan.org> | Fri Apr 11 17:10:01 2014 +0200| [32087067341dfaca4c85ee26e64a37158ccd3f5a] | committer: Jean-Paul Saman

examples/dvbinfo/udp.c: Check setsockopt return values (CID 17231)

> http://git.videolan.org/gitweb.cgi/libdvbpsi.git/?a=commit;h=32087067341dfaca4c85ee26e64a37158ccd3f5a
---

 examples/dvbinfo/udp.c |   14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/examples/dvbinfo/udp.c b/examples/dvbinfo/udp.c
index 1c23fe7..030add3 100644
--- a/examples/dvbinfo/udp.c
+++ b/examples/dvbinfo/udp.c
@@ -264,12 +264,16 @@ int udp_open(const char *interface, const char *ipaddress, int port)
 
         /* Increase the receive buffer size to 1/2MB (8Mb/s during 1/2s)
          * to avoid packet loss caused in case of scheduling hiccups */
-        setsockopt (s_ctl, SOL_SOCKET, SO_RCVBUF,
-                    (void *)&(int){ 0x80000 }, sizeof (int));
-        setsockopt (s_ctl, SOL_SOCKET, SO_SNDBUF,
-                    (void *)&(int){ 0x80000 }, sizeof (int));
+        if (setsockopt (s_ctl, SOL_SOCKET, SO_RCVBUF,
+                    (void *)&(int){ 0x80000 }, sizeof (int)) < 0)
+            perror("udp setsockopt error");
 
-        setsockopt (s_ctl, SOL_SOCKET, SO_REUSEADDR, &(int){ 1 }, sizeof (int));
+        if (setsockopt (s_ctl, SOL_SOCKET, SO_SNDBUF,
+                    (void *)&(int){ 0x80000 }, sizeof (int)) < 0)
+            perror("udp setsockopt error");
+
+        if (setsockopt (s_ctl, SOL_SOCKET, SO_REUSEADDR, &(int){ 1 }, sizeof (int)) < 0)
+            perror("udp setsockopt error");
 
         result = bind(s_ctl, ptr->ai_addr, ptr->ai_addrlen);
         if (result < 0)



More information about the libdvbpsi-devel mailing list