chiark / gitweb /
Link: port to new ethtool ETHTOOL_xLINKSETTINGS
[elogind.git] / src / basic / io-util.c
index 3ec8d61236922cb036ed30c7550c893ba7c0f586..cc6dfa8c1b94a29bcaf36cdb139be8dc09467178 100644 (file)
@@ -33,6 +33,11 @@ int flush_fd(int fd) {
                 .events = POLLIN,
         };
 
                 .events = POLLIN,
         };
 
+        /* Read from the specified file descriptor, until POLLIN is not set anymore, throwing away everything
+         * read. Note that some file descriptors (notable IP sockets) will trigger POLLIN even when no data can be read
+         * (due to IP packet checksum mismatches), hence this function is only safe to be non-blocking if the fd used
+         * was set to non-blocking too. */
+
         for (;;) {
                 char buf[LINE_MAX];
                 ssize_t l;
         for (;;) {
                 char buf[LINE_MAX];
                 ssize_t l;
@@ -249,7 +254,7 @@ ssize_t sparse_write(int fd, const void *p, size_t sz, size_t run_length) {
                 } else if (n > 0)
                         q += n;
                 else
                 } else if (n > 0)
                         q += n;
                 else
-                        q ++;
+                        q++;
         }
 
         if (q > w) {
         }
 
         if (q > w) {