diff options
| author | Roy Marples <roy@marples.name> | 2017-10-21 03:28:52 +0100 |
|---|---|---|
| committer | Roy Marples <roy@marples.name> | 2017-10-21 03:28:52 +0100 |
| commit | f85b3c3136d6a06565825917f9b8f57eb08f5698 (patch) | |
| tree | 0bad8e58b026675fd9b0bf07583253e4c0729d3e | |
| parent | 4dbccdb1698d48c14ca6ccdbc37837a54effaad5 (diff) | |
| download | dhcpcd-ui-f85b3c3136d6a06565825917f9b8f57eb08f5698.tar.xz | |
Stop using iostream, stdio is smaller binary.
| -rw-r--r-- | src/dhcpcd-qt/dhcpcd-qt.cpp | 4 | ||||
| -rw-r--r-- | src/dhcpcd-qt/dhcpcd-singleton.cpp | 20 |
2 files changed, 13 insertions, 11 deletions
diff --git a/src/dhcpcd-qt/dhcpcd-qt.cpp b/src/dhcpcd-qt/dhcpcd-qt.cpp index c09e5b1..c82f2eb 100644 --- a/src/dhcpcd-qt/dhcpcd-qt.cpp +++ b/src/dhcpcd-qt/dhcpcd-qt.cpp @@ -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) { diff --git a/src/dhcpcd-qt/dhcpcd-singleton.cpp b/src/dhcpcd-qt/dhcpcd-singleton.cpp index 42ebd28..4dccca9 100644 --- a/src/dhcpcd-qt/dhcpcd-singleton.cpp +++ b/src/dhcpcd-qt/dhcpcd-singleton.cpp @@ -26,12 +26,12 @@ #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; |
