Stop using iostream, stdio is smaller binary.
authorRoy Marples <roy@marples.name>
Sat, 21 Oct 2017 02:28:52 +0000 (03:28 +0100)
committerRoy Marples <roy@marples.name>
Sat, 21 Oct 2017 02:28:52 +0000 (03:28 +0100)
src/dhcpcd-qt/dhcpcd-qt.cpp
src/dhcpcd-qt/dhcpcd-singleton.cpp

index c09e5b1ff43bb33335aa7ef6bcdc2f14f36375a3..c82f2eb836ee42de60e61659d365fcc51d6960ea 100644 (file)
@@ -222,14 +222,14 @@ void DhcpcdQt::updateOnline(bool showIf)
                msg = dhcpcd_if_message(i, NULL);
                if (msg) {
                        if (showIf)
-                               qDebug() << msg;
+                               qDebug("%s", msg);
                        if (msgs.isEmpty())
                                msgs = QString::fromLatin1(msg);
                        else
                                msgs += '\n' + QString::fromLatin1(msg);
                        free(msg);
                } else if (showIf)
-                       qDebug() << i->ifname << i->reason;
+                       qDebug("%s: %s", i->ifname, i->reason);
        }
 
        if (onLine != isOn || carrier != isCarrier) {
index 42ebd28f522505250279cf93ce3891ff12efe516..4dccca982d1a45a318b6b00a574718ba95d4ff2f 100644 (file)
 
 #include <sys/stat.h>
 #include <sys/file.h>
+#include <errno.h>
 #include <fcntl.h>
+#include <stdio.h>
 #include <string.h>
 #include <unistd.h>
 
-#include <cerrno>
-#include <iostream>
 #include <string>
 
 #include "dhcpcd.h"
@@ -61,8 +61,8 @@ bool DhcpcdSingleton::lock()
        if (mkdir(file.c_str(), DHCPCD_TMP_DIR_PERM) == -1 &&
            errno != EEXIST)
        {
-               cerr << "dhcpcd-qt: " << "mkdir: " << file << ": "
-                   << strerror(errno) << endl;
+               fprintf(stderr, "dhcpcd-qt: mkdir: %s: %s\n",
+                   file.c_str(), strerror(errno));
                return false;
        }
 
@@ -75,14 +75,16 @@ bool DhcpcdSingleton::lock()
        file += ".lock";
        fd = open(file.c_str(), O_WRONLY | O_CREAT | O_NONBLOCK, 0664);
        if (fd == -1) {
-               cerr << "dhcpcd-qt: " << "open: " << file << ": "
-                   << strerror(errno) << endl;
+               fprintf(stderr, "dhcpcd-qt: open: %s: %s\n",
+                   file.c_str(), strerror(errno));
                return false;
        }
        if (flock(fd, LOCK_EX | LOCK_NB) == -1) {
-               if (errno != EAGAIN)
-                       cerr << "dhcpcd-qt: " << "flock: " << file << ": "
-                           << strerror(errno) << endl;
+               if (errno == EAGAIN)
+                       fprintf(stderr, "dhcpcd-qt: already running\n");
+               else
+                       fprintf(stderr, "dhcpcd-qt: flock: %s: %s\n",
+                           file.c_str(), strerror(errno));
                return false;
        }
        return true;