Browse code

don't print errno twice

when passing the M_ERRNO flag to msg(), the latter will already
print the errno message (in a form of a string and number) for us,
hence there is no need to explicitly print it a second time.

Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20170713080527.13299-2-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg15057.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>

Antonio Quartulli authored on 2017/07/13 17:05:27
Showing 2 changed files
... ...
@@ -159,7 +159,7 @@ platform_nice(int niceval)
159 159
         errno = 0;
160 160
         if (nice(niceval) < 0 && errno != 0)
161 161
         {
162
-            msg(M_WARN | M_ERRNO, "WARNING: nice %d failed: %s", niceval, strerror(errno));
162
+            msg(M_WARN | M_ERRNO, "WARNING: nice %d failed", niceval);
163 163
         }
164 164
         else
165 165
         {
... ...
@@ -2563,8 +2563,7 @@ open_tun(const char *dev, const char *dev_type, const char *dev_node, struct tun
2563 2563
 
2564 2564
         if (ioctl(tt->fd, TUNGIFINFO, &info) < 0)
2565 2565
         {
2566
-            msg(M_WARN | M_ERRNO, "Can't get interface info: %s",
2567
-                strerror(errno));
2566
+            msg(M_WARN | M_ERRNO, "Can't get interface info");
2568 2567
         }
2569 2568
 
2570 2569
 #ifdef IFF_MULTICAST /* openbsd 4.x doesn't have this */
... ...
@@ -2573,8 +2572,7 @@ open_tun(const char *dev, const char *dev_type, const char *dev_node, struct tun
2573 2573
 
2574 2574
         if (ioctl(tt->fd, TUNSIFINFO, &info) < 0)
2575 2575
         {
2576
-            msg(M_WARN | M_ERRNO, "Can't set interface info: %s",
2577
-                strerror(errno));
2576
+            msg(M_WARN | M_ERRNO, "Can't set interface info");
2578 2577
         }
2579 2578
     }
2580 2579
 }
... ...
@@ -2663,7 +2661,7 @@ open_tun(const char *dev, const char *dev_type, const char *dev_node, struct tun
2663 2663
             i = 1;
2664 2664
             if (ioctl(tt->fd, TUNSIFHEAD, &i) < 0)      /* multi-af mode on */
2665 2665
             {
2666
-                msg(M_WARN | M_ERRNO, "ioctl(TUNSIFHEAD): %s", strerror(errno));
2666
+                msg(M_WARN | M_ERRNO, "ioctl(TUNSIFHEAD)");
2667 2667
             }
2668 2668
         }
2669 2669
     }
... ...
@@ -2796,12 +2794,12 @@ open_tun(const char *dev, const char *dev_type, const char *dev_node, struct tun
2796 2796
 
2797 2797
         if (ioctl(tt->fd, TUNSIFMODE, &i) < 0)
2798 2798
         {
2799
-            msg(M_WARN | M_ERRNO, "ioctl(TUNSIFMODE): %s", strerror(errno));
2799
+            msg(M_WARN | M_ERRNO, "ioctl(TUNSIFMODE)");
2800 2800
         }
2801 2801
         i = 1;
2802 2802
         if (ioctl(tt->fd, TUNSIFHEAD, &i) < 0)
2803 2803
         {
2804
-            msg(M_WARN | M_ERRNO, "ioctl(TUNSIFHEAD): %s", strerror(errno));
2804
+            msg(M_WARN | M_ERRNO, "ioctl(TUNSIFHEAD)");
2805 2805
         }
2806 2806
     }
2807 2807
 }