diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2009-09-18 17:32:01 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2009-09-18 17:32:01 +0200 |
commit | 64be7b89afc0822cf24aeeec588ff5f5af5fe8b4 (patch) | |
tree | 0edaf0823e11980d2040e6f2a8c837e35dc313ff | |
parent | ad8ac022a2ea7a73ecad1034cf9103d2e1bf2779 (diff) | |
download | abrt-64be7b89afc0822cf24aeeec588ff5f5af5fe8b4.tar.gz abrt-64be7b89afc0822cf24aeeec588ff5f5af5fe8b4.tar.xz abrt-64be7b89afc0822cf24aeeec588ff5f5af5fe8b4.zip |
remove a few C++-isms where they did not buy any convenience anyway
text data bss dec hex filename
182372 2624 2320 187316 2dbb4 abrt.t2/abrt-0.0.8.5/src/Daemon/.libs/abrtd
180635 2584 1968 185187 2d363 abrt.t3/abrt-0.0.8.5/src/Daemon/.libs/abrtd
34110 1340 768 36218 8d7a abrt.t2/abrt-0.0.8.5/src/CLI/.libs/abrt-cli
30202 1292 224 31718 7be6 abrt.t3/abrt-0.0.8.5/src/CLI/.libs/abrt-cli
22116 1688 376 24180 5e74 abrt.t2/abrt-0.0.8.5/src/Applet/.libs/abrt-applet
21254 1648 88 22990 59ce abrt.t3/abrt-0.0.8.5/src/Applet/.libs/abrt-applet
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | lib/Utils/DebugDump.cpp | 7 | ||||
-rw-r--r-- | src/Applet/Applet.cpp | 1 | ||||
-rw-r--r-- | src/Applet/CCApplet.cpp | 11 | ||||
-rw-r--r-- | src/CLI/CLI.cpp | 49 | ||||
-rw-r--r-- | src/Daemon/CommLayerServerSocket.cpp | 6 | ||||
-rw-r--r-- | src/Daemon/CrashWatcher.cpp | 2 | ||||
-rw-r--r-- | src/Daemon/Daemon.cpp | 1 | ||||
-rw-r--r-- | src/Daemon/PluginManager.cpp | 15 |
8 files changed, 41 insertions, 51 deletions
diff --git a/lib/Utils/DebugDump.cpp b/lib/Utils/DebugDump.cpp index 03fb7c64..4d6d92c3 100644 --- a/lib/Utils/DebugDump.cpp +++ b/lib/Utils/DebugDump.cpp @@ -106,7 +106,6 @@ static int GetAndSetLock(const char* pLockFile, const char* pPID) if (errno != EEXIST) perror_msg_and_die("Can't create lock file '%s'", pLockFile); fd = open(pLockFile, O_RDONLY); -log("opened O_RDONLY: '%s'", pLockFile); if (fd < 0) { if (errno == ENOENT) @@ -125,7 +124,6 @@ log("opened O_RDONLY: '%s'", pLockFile); continue; } pid_buf[r] = '\0'; -log("read: '%s'", pid_buf); if (strcmp(pid_buf, pPID) == 0) { log("Lock file '%s' is already locked by us", pLockFile); @@ -143,7 +141,6 @@ log("read: '%s'", pid_buf); /* The file may be deleted by now by other process. Ignore errors */ unlink(pLockFile); } -log("created O_EXCL: '%s'", pLockFile); int len = strlen(pPID); if (write(fd, pPID, len) != len) @@ -331,10 +328,8 @@ void CDebugDump::SaveKernelArchitectureRelease() void CDebugDump::SaveTime() { - std::stringstream ss; time_t t = time(NULL); - ss << t; - SaveText(FILENAME_TIME, ss.str()); + SaveText(FILENAME_TIME, to_string(t)); } static void LoadTextFile(const std::string& pPath, std::string& pData) diff --git a/src/Applet/Applet.cpp b/src/Applet/Applet.cpp index a75a1425..4d46e2d7 100644 --- a/src/Applet/Applet.cpp +++ b/src/Applet/Applet.cpp @@ -17,7 +17,6 @@ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include <iostream> #include <dbus/dbus-shared.h> #include <dbus/dbus-glib.h> #include <dbus/dbus-glib-lowlevel.h> diff --git a/src/Applet/CCApplet.cpp b/src/Applet/CCApplet.cpp index 3bd0dbca..6d841a52 100644 --- a/src/Applet/CCApplet.cpp +++ b/src/Applet/CCApplet.cpp @@ -17,10 +17,6 @@ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include <iostream> -#include <cstdarg> -#include <sstream> -#include <cstdio> #if HAVE_CONFIG_H #include <config.h> #endif @@ -199,7 +195,7 @@ void CApplet::OnAppletActivate_CB(GtkStatusIcon *status_icon,gpointer user_data) { pid_t pid = vfork(); if (pid < 0) - std::cerr << "vfork failed\n"; + perror_msg("vfork"); if (pid == 0) { /* child */ signal(SIGCHLD, SIG_DFL); /* undo SIG_IGN in abrt-applet */ @@ -207,8 +203,7 @@ void CApplet::OnAppletActivate_CB(GtkStatusIcon *status_icon,gpointer user_data) /* Did not find abrt-gui in installation directory. Oh well */ /* Trying to find it in PATH */ execlp("abrt-gui", "abrt-gui", (char*) NULL); - std::cerr << "can't exec abrt-gui\n"; - exit(1); + perror_msg_and_die("Can't exec abrt-gui"); } gtk_status_icon_set_visible(applet->m_pStatusIcon, false); } @@ -264,7 +259,7 @@ void CApplet::Disable(const char *reason) gtk_status_icon_set_from_pixbuf(m_pStatusIcon, gray_scaled); } else - std::cerr << "Cannot load icon!" << std::endl; + error_msg("Can't load icon"); SetIconTooltip(reason); ShowIcon(); } diff --git a/src/CLI/CLI.cpp b/src/CLI/CLI.cpp index f16811e7..1fd09301 100644 --- a/src/CLI/CLI.cpp +++ b/src/CLI/CLI.cpp @@ -1,4 +1,3 @@ -#include <iostream> #include <getopt.h> #include "ABRTException.h" #include "ABRTSocket.h" @@ -18,20 +17,29 @@ enum static DBusConnection* s_dbus_conn; -static void print_crash_infos(const vector_crash_infos_t& pCrashInfos, int pMode) +static void print_crash_infos(vector_crash_infos_t& pCrashInfos, int pMode) { unsigned int ii; for (ii = 0; ii < pCrashInfos.size(); ii++) { - if (pCrashInfos[ii].find(CD_REPORTED)->second[CD_CONTENT] != "1" || pMode == GET_LIST_FULL) + map_crash_info_t& info = pCrashInfos[ii]; + if (pMode == GET_LIST_FULL || info.find(CD_REPORTED)->second[CD_CONTENT] != "1") { - std::cout << ii << ".\n"; - std::cout << "\tUID : " << pCrashInfos[ii].find(CD_UID)->second[CD_CONTENT] << std::endl; - std::cout << "\tUUID : " << pCrashInfos[ii].find(CD_UUID)->second[CD_CONTENT] << std::endl; - std::cout << "\tPackage : " << pCrashInfos[ii].find(CD_PACKAGE)->second[CD_CONTENT] << std::endl; - std::cout << "\tExecutable: " << pCrashInfos[ii].find(CD_EXECUTABLE)->second[CD_CONTENT] << std::endl; - std::cout << "\tCrash time: " << pCrashInfos[ii].find(CD_TIME)->second[CD_CONTENT] << std::endl; - std::cout << "\tCrash Rate: " << pCrashInfos[ii].find(CD_COUNT)->second[CD_CONTENT] << std::endl; + printf("%u.\n" + "\tUID : %s\n" + "\tUUID : %s\n" + "\tPackage : %s\n" + "\tExecutable: %s\n" + "\tCrash time: %s\n" + "\tCrash Rate: %s\n", + ii, + info[CD_UID][CD_CONTENT].c_str(), + info[CD_UUID][CD_CONTENT].c_str(), + info[CD_PACKAGE][CD_CONTENT].c_str(), + info[CD_EXECUTABLE][CD_CONTENT].c_str(), + info[CD_TIME][CD_CONTENT].c_str(), + info[CD_COUNT][CD_CONTENT].c_str() + ); } } } @@ -43,9 +51,9 @@ static void print_crash_report(const map_crash_report_t& pCrashReport) { if (it->second[CD_TYPE] != CD_SYS) { - std::cout << std::endl << it->first << std::endl; - std::cout << "-----" << std::endl; - std::cout << it->second[CD_CONTENT] << std::endl; + printf("\n%s\n" + "-----\n" + "%s\n", it->first.c_str(), it->second[CD_CONTENT].c_str()); } } } @@ -205,12 +213,13 @@ int main(int argc, char** argv) else progname = argv[0]; /* note: message has embedded tabs */ - std::cout << "Usage: " << progname << " [OPTION]\n\n" + printf("Usage: %s [OPTION]\n\n" " --get-list print list of crashes which are not reported\n" " --get-list-full print list of all crashes\n" " --report UUID create and send a report\n" " --report-always UUID create and send a report without asking\n" - " --delete UUID delete crash\n"; + " --delete UUID delete crash\n", + progname); return 1; } if (c == -1) @@ -240,11 +249,11 @@ int main(int argc, char** argv) { map_crash_report_t cr = call_CreateReport(uuid); print_crash_report(cr); - std::cout << "\nDo you want to send the report? [y/n]: "; - std::flush(std::cout); - std::string answer = "n"; - std::cin >> answer; - if (answer == "Y" || answer == "y") + printf("\nDo you want to send the report? [y/n]: "); + fflush(NULL); + char answer[16] = "n"; + fgets(answer, sizeof(answer), stdin); + if (answer[0] == 'Y' || answer[0] == 'y') { call_Report(cr); } diff --git a/src/Daemon/CommLayerServerSocket.cpp b/src/Daemon/CommLayerServerSocket.cpp index b643aaa9..6b62928b 100644 --- a/src/Daemon/CommLayerServerSocket.cpp +++ b/src/Daemon/CommLayerServerSocket.cpp @@ -1,7 +1,5 @@ #include <sys/socket.h> #include <sys/un.h> -#include <iostream> -#include <sstream> #include "abrtlib.h" #include "CommLayerInner.h" #include "ABRTException.h" @@ -44,9 +42,7 @@ std::string CCommLayerServerSocket::GetSenderUID(int pSenderSocket) { throw CABRTException(EXCEP_ERROR, "CCommLayerServerSocket::GetSenderUID(): Error can get sender uid."); } - std::stringstream ss; - ss << creds.uid; - return ss.str(); + return to_string(creds.uid); } gboolean CCommLayerServerSocket::client_socket_cb(GIOChannel *source, GIOCondition condition, gpointer data) diff --git a/src/Daemon/CrashWatcher.cpp b/src/Daemon/CrashWatcher.cpp index 826dc9e6..5cc9dc74 100644 --- a/src/Daemon/CrashWatcher.cpp +++ b/src/Daemon/CrashWatcher.cpp @@ -17,8 +17,6 @@ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include <iostream> -#include <sstream> #include "abrtlib.h" #include "Daemon.h" #include "ABRTException.h" diff --git a/src/Daemon/Daemon.cpp b/src/Daemon/Daemon.cpp index 70f471c4..3c486279 100644 --- a/src/Daemon/Daemon.cpp +++ b/src/Daemon/Daemon.cpp @@ -21,7 +21,6 @@ #include <sys/inotify.h> #include <glib.h> #include <pthread.h> -#include <iostream> #include <string> #if HAVE_CONFIG_H #include <config.h> diff --git a/src/Daemon/PluginManager.cpp b/src/Daemon/PluginManager.cpp index be14f4ba..a36d5a85 100644 --- a/src/Daemon/PluginManager.cpp +++ b/src/Daemon/PluginManager.cpp @@ -103,17 +103,16 @@ bool LoadPluginSettings(const std::string& pPath, map_plugin_settings_t& pSettin */ static bool SavePluginSettings(const std::string& pPath, const map_plugin_settings_t& pSettings) { - std::ofstream fOut; - fOut.open(pPath.c_str()); - if (fOut.is_open()) + FILE* fOut = fopen(pPath.c_str(), "w"); + if (fOut) { - fOut << "# Settings were written by abrt." << std::endl; - map_plugin_settings_t::const_iterator it; - for (it = pSettings.begin(); it != pSettings.end(); it++) + fprintf(fOut, "# Settings were written by abrt\n"); + map_plugin_settings_t::const_iterator it = pSettings.begin(); + for (; it != pSettings.end(); it++) { - fOut << it->first << " = " << it->second << std::endl; + fprintf(fOut, "%s = %s\n", it->first.c_str(), it->second.c_str()); } - fOut.close(); + fclose(fOut); return true; } return false; |