summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2009-12-06 22:23:11 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2009-12-06 22:23:11 +0100
commit4ceb3715a3a6b752009627b0dc6a1974664c03a1 (patch)
tree8c96d097e7e63f905925419a8a65c814d407605f /lib
parentf66aa07338bbc8a8a80264ec5be3ae25b677d94a (diff)
downloadabrt-4ceb3715a3a6b752009627b0dc6a1974664c03a1.tar.gz
abrt-4ceb3715a3a6b752009627b0dc6a1974664c03a1.tar.xz
abrt-4ceb3715a3a6b752009627b0dc6a1974664c03a1.zip
remove std::string usage from class CABRTException.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/Plugins/Bugzilla.cpp2
-rw-r--r--lib/Plugins/FileTransfer.cpp6
-rw-r--r--lib/Plugins/Firefox.cpp4
-rw-r--r--lib/Plugins/KerneloopsReporter.cpp2
-rw-r--r--lib/Plugins/KerneloopsScanner.cpp2
-rw-r--r--lib/Plugins/Logger.cpp2
-rw-r--r--lib/Plugins/SOSreport.cpp7
-rw-r--r--lib/Plugins/SQLite3.cpp8
-rw-r--r--lib/Plugins/TicketUploader.cpp13
-rw-r--r--lib/Utils/ABRTException.cpp15
-rw-r--r--lib/Utils/DebugDump.cpp26
-rw-r--r--lib/Utils/Makefile.am3
-rw-r--r--lib/Utils/abrt_xmlrpc.cpp2
13 files changed, 53 insertions, 39 deletions
diff --git a/lib/Plugins/Bugzilla.cpp b/lib/Plugins/Bugzilla.cpp
index f17f9a7..8a318d3 100644
--- a/lib/Plugins/Bugzilla.cpp
+++ b/lib/Plugins/Bugzilla.cpp
@@ -52,7 +52,7 @@ void ctx::login(const char* login, const char* passwd)
std::string errmsg = ssprintf("Can't login. Check Edit->Plugins->Bugzilla and /etc/abrt/plugins/Bugzilla.conf. Server said: %s", env.fault_string);
xmlrpc_env_clean(&env);
error_msg("%s", errmsg.c_str()); // show error in daemon log
- throw CABRTException(EXCEP_PLUGIN, errmsg);
+ throw CABRTException(EXCEP_PLUGIN, errmsg.c_str());
}
}
diff --git a/lib/Plugins/FileTransfer.cpp b/lib/Plugins/FileTransfer.cpp
index 868f54d..8fff3a9 100644
--- a/lib/Plugins/FileTransfer.cpp
+++ b/lib/Plugins/FileTransfer.cpp
@@ -79,12 +79,12 @@ void CFileTransfer::SendFile(const char *pURL, const char *pFilename)
f = fopen(pFilename, "r");
if (!f)
{
- throw CABRTException(EXCEP_PLUGIN, ssprintf("Can't open archive file '%s'", pFilename));
+ throw CABRTException(EXCEP_PLUGIN, "Can't open archive file '%s'", pFilename);
}
if (fstat(fileno(f), &buf) == -1)
{
fclose(f);
- throw CABRTException(EXCEP_PLUGIN, ssprintf("Can't stat archive file '%s'", pFilename));
+ throw CABRTException(EXCEP_PLUGIN, "Can't stat archive file '%s'", pFilename);
}
curl = curl_easy_init();
if (!curl)
@@ -282,7 +282,7 @@ void CFileTransfer::CreateArchive(const char *pArchiveName, const char *pDir)
}
else
{
- throw CABRTException(EXCEP_PLUGIN, "Unknown/unsupported archive type " + m_sArchiveType);
+ throw CABRTException(EXCEP_PLUGIN, "Unknown/unsupported archive type %s", m_sArchiveType.c_str());
}
}
diff --git a/lib/Plugins/Firefox.cpp b/lib/Plugins/Firefox.cpp
index 68dbd39..2a35dc1 100644
--- a/lib/Plugins/Firefox.cpp
+++ b/lib/Plugins/Firefox.cpp
@@ -100,7 +100,7 @@ static pid_t ExecVP(char** pArgs, uid_t uid, std::string& pOutput)
struct passwd* pw = getpwuid(uid);
if (!pw)
{
- throw CABRTException(EXCEP_PLUGIN, std::string(__func__) + ": cannot get GID for UID.");
+ throw CABRTException(EXCEP_PLUGIN, "%s: can't get GID for UID", __func__);
}
xpipe(pipeout);
@@ -662,7 +662,7 @@ Another application is holding the yum lock, cannot continue
fclose(pipeout_fp);
kill(child, SIGTERM);
wait(NULL);
- throw CABRTException(EXCEP_PLUGIN, std::string(__func__) + ": cannot install debuginfos for " + pPackage);
+ throw CABRTException(EXCEP_PLUGIN, "%s: can't install debuginfos for %s", __func__, pPackage);
}
#endif
}
diff --git a/lib/Plugins/KerneloopsReporter.cpp b/lib/Plugins/KerneloopsReporter.cpp
index a1fd3f1..376db25 100644
--- a/lib/Plugins/KerneloopsReporter.cpp
+++ b/lib/Plugins/KerneloopsReporter.cpp
@@ -111,7 +111,7 @@ std::string CKerneloopsReporter::Report(const map_crash_report_t& pCrashReport,
if (ret) {
/* FIXME: be more informative */
- throw CABRTException(EXCEP_PLUGIN, std::string("CKerneloopsReporter::Report(): Report has not been sent..."));
+ throw CABRTException(EXCEP_PLUGIN, "CKerneloopsReporter::Report(): Report has not been sent");
}
return "Kernel oops report was uploaded.";
}
diff --git a/lib/Plugins/KerneloopsScanner.cpp b/lib/Plugins/KerneloopsScanner.cpp
index 3831f9e..128e083 100644
--- a/lib/Plugins/KerneloopsScanner.cpp
+++ b/lib/Plugins/KerneloopsScanner.cpp
@@ -109,7 +109,7 @@ void CKerneloopsScanner::SaveOopsToDebugDump()
}
catch (CABRTException& e)
{
- throw CABRTException(EXCEP_PLUGIN, std::string(__func__) + ": " + e.what());
+ throw CABRTException(EXCEP_PLUGIN, "%s: %s", __func__, e.what());
}
oopsList.pop_back();
}
diff --git a/lib/Plugins/Logger.cpp b/lib/Plugins/Logger.cpp
index 7267b64..9f261a3 100644
--- a/lib/Plugins/Logger.cpp
+++ b/lib/Plugins/Logger.cpp
@@ -84,7 +84,7 @@ std::string CLogger::Report(const map_crash_report_t& pCrashReport,
return "file://" + m_sLogPath;
}
- throw CABRTException(EXCEP_PLUGIN, "CLogger::Report(): Cannot open file: " + m_sLogPath);
+ throw CABRTException(EXCEP_PLUGIN, "Can't open file '%s'", m_sLogPath);
}
PLUGIN_INFO(REPORTER,
diff --git a/lib/Plugins/SOSreport.cpp b/lib/Plugins/SOSreport.cpp
index 65d01a7..6f23165 100644
--- a/lib/Plugins/SOSreport.cpp
+++ b/lib/Plugins/SOSreport.cpp
@@ -104,10 +104,9 @@ void CActionSOSreport::Run(const char *pActionDir, const char *pArgs)
if (copy_file(sosreport_filename.c_str(), sosreport_dd_filename.c_str()) < 0)
{
throw CABRTException(EXCEP_PLUGIN,
- ssprintf("Can't copy '%s' to '%s'",
- sosreport_filename.c_str(),
- sosreport_dd_filename.c_str()
- )
+ "Can't copy '%s' to '%s'",
+ sosreport_filename.c_str(),
+ sosreport_dd_filename.c_str()
);
}
}
diff --git a/lib/Plugins/SQLite3.cpp b/lib/Plugins/SQLite3.cpp
index 866b985..d95c273 100644
--- a/lib/Plugins/SQLite3.cpp
+++ b/lib/Plugins/SQLite3.cpp
@@ -107,7 +107,7 @@ static void get_table(vector_database_rows_t& pTable,
string errstr = ssprintf("Error in SQL:'%s' error: %s", sql, err);
free(sql);
sqlite3_free(err);
- throw CABRTException(EXCEP_PLUGIN, errstr);
+ throw CABRTException(EXCEP_PLUGIN, errstr.c_str());
}
VERB2 log("%d rows returned by SQL:%s", nrow, sql);
free(sql);
@@ -152,7 +152,7 @@ static void execute_sql(sqlite3 *db, const char *fmt, ...)
string errstr = ssprintf("Error in SQL:'%s' error: %s", sql, err);
free(sql);
sqlite3_free(err);
- throw CABRTException(EXCEP_PLUGIN, errstr);
+ throw CABRTException(EXCEP_PLUGIN, errstr.c_str());
}
VERB2 log("%d rows affected by SQL:%s", sqlite3_changes(db), sql);
free(sql);
@@ -262,7 +262,7 @@ void CSQLite3::Connect()
{
if (ret != SQLITE_CANTOPEN)
{
- throw CABRTException(EXCEP_PLUGIN, ssprintf("CheckDB: Can't open database: %s", sqlite3_errmsg(m_pDB)));
+ throw CABRTException(EXCEP_PLUGIN, "Can't open database: %s", sqlite3_errmsg(m_pDB));
}
ret = sqlite3_open_v2(m_sDBPath.c_str(),
@@ -272,7 +272,7 @@ void CSQLite3::Connect()
);
if (ret != SQLITE_OK)
{
- throw CABRTException(EXCEP_PLUGIN, ssprintf("Can't create database: %s", sqlite3_errmsg(m_pDB)));
+ throw CABRTException(EXCEP_PLUGIN, "Can't create database: %s", sqlite3_errmsg(m_pDB));
}
}
diff --git a/lib/Plugins/TicketUploader.cpp b/lib/Plugins/TicketUploader.cpp
index 847efdc..687e706 100644
--- a/lib/Plugins/TicketUploader.cpp
+++ b/lib/Plugins/TicketUploader.cpp
@@ -117,12 +117,12 @@ void CTicketUploader::SendFile(const char *pURL, const char *pFilename)
FILE* f = fopen(pFilename, "r");
if (!f)
{
- throw CABRTException(EXCEP_PLUGIN, ssprintf("Can't open archive file '%s'", pFilename));
+ throw CABRTException(EXCEP_PLUGIN, "Can't open archive file '%s'", pFilename);
}
struct stat buf;
- if (fstat(fileno(f), &buf) == -1)
+ if (fstat(fileno(f), &buf) == -1) /* TODO: never fails */
{
- throw CABRTException(EXCEP_PLUGIN, ssprintf("Can't stat archive file '%s'", pFilename));
+ throw CABRTException(EXCEP_PLUGIN, "Can't stat archive file '%s'", pFilename);
}
CURL* curl = curl_easy_init();
if (!curl)
@@ -225,10 +225,9 @@ string CTicketUploader::Report(const map_crash_report_t& pCrashReport,
if (copy_file(it->second[CD_CONTENT].c_str(), ofile_name.c_str()) < 0)
{
throw CABRTException(EXCEP_PLUGIN,
- ssprintf("Can't copy '%s' to '%s'",
- it->second[CD_CONTENT].c_str(),
- ofile_name.c_str()
- )
+ "Can't copy '%s' to '%s'",
+ it->second[CD_CONTENT].c_str(),
+ ofile_name.c_str()
);
}
}
diff --git a/lib/Utils/ABRTException.cpp b/lib/Utils/ABRTException.cpp
new file mode 100644
index 0000000..aa6c99d
--- /dev/null
+++ b/lib/Utils/ABRTException.cpp
@@ -0,0 +1,15 @@
+#include "ABRTException.h"
+
+CABRTException::CABRTException(abrt_exception_t type, const char* fmt, ...)
+{
+ m_type = type;
+ va_list ap;
+ va_start(ap, fmt);
+ m_what = xvasprintf(fmt, ap);
+ va_end(ap);
+}
+
+CABRTException::CABRTException(const CABRTException& rhs):
+ m_type(rhs.m_type),
+ m_what(xstrdup(rhs.m_what))
+{}
diff --git a/lib/Utils/DebugDump.cpp b/lib/Utils/DebugDump.cpp
index 3e226f9..b1db169 100644
--- a/lib/Utils/DebugDump.cpp
+++ b/lib/Utils/DebugDump.cpp
@@ -77,7 +77,7 @@ void CDebugDump::Open(const char *pDir)
m_sDebugDumpDir = RemoveBackSlashes(pDir);
if (!ExistFileDir(m_sDebugDumpDir.c_str()))
{
- throw CABRTException(EXCEP_DD_OPEN, m_sDebugDumpDir + " does not exist");
+ throw CABRTException(EXCEP_DD_OPEN, "'%s' does not exist", m_sDebugDumpDir.c_str());
}
Lock();
m_bOpened = true;
@@ -222,7 +222,7 @@ void CDebugDump::Create(const char *pDir, int64_t uid)
m_sDebugDumpDir = RemoveBackSlashes(pDir);
if (ExistFileDir(m_sDebugDumpDir.c_str()))
{
- throw CABRTException(EXCEP_DD_OPEN, ssprintf("'%s' already exists", m_sDebugDumpDir.c_str()));
+ throw CABRTException(EXCEP_DD_OPEN, "'%s' already exists", m_sDebugDumpDir.c_str());
}
Lock();
@@ -232,13 +232,13 @@ void CDebugDump::Create(const char *pDir, int64_t uid)
{
UnLock();
m_bOpened = false;
- throw CABRTException(EXCEP_DD_OPEN, ssprintf("Can't create dir '%s'", pDir));
+ throw CABRTException(EXCEP_DD_OPEN, "Can't create dir '%s'", pDir);
}
if (chmod(m_sDebugDumpDir.c_str(), 0700) == -1)
{
UnLock();
m_bOpened = false;
- throw CABRTException(EXCEP_DD_OPEN, ssprintf("Can't change mode of '%s'", pDir));
+ throw CABRTException(EXCEP_DD_OPEN, "Can't change mode of '%s'", pDir);
}
struct passwd* pw = getpwuid(uid);
gid_t gid = pw ? pw->pw_gid : uid;
@@ -272,7 +272,7 @@ static void DeleteFileDir(const char *pDir)
if (errno != EISDIR)
{
closedir(dir);
- throw CABRTException(EXCEP_DD_DELETE, ssprintf("Can't remove dir %s", fullPath.c_str()));
+ throw CABRTException(EXCEP_DD_DELETE, "Can't remove dir %s", fullPath.c_str());
}
DeleteFileDir(fullPath.c_str());
}
@@ -280,7 +280,7 @@ static void DeleteFileDir(const char *pDir)
closedir(dir);
if (remove(pDir) == -1)
{
- throw CABRTException(EXCEP_DD_DELETE, ssprintf("Can't remove dir %s", pDir));
+ throw CABRTException(EXCEP_DD_DELETE, "Can't remove dir %s", pDir);
}
}
@@ -325,7 +325,7 @@ static void LoadTextFile(const char *pPath, std::string& pData)
FILE *fp = fopen(pPath, "r");
if (!fp)
{
- throw CABRTException(EXCEP_DD_LOAD, ssprintf("Can't open file '%s'", pPath));
+ throw CABRTException(EXCEP_DD_LOAD, "Can't open file '%s'", pPath);
}
pData = "";
int ch;
@@ -348,13 +348,13 @@ static void SaveBinaryFile(const char *pPath, const char* pData, unsigned pSize)
int fd = open(pPath, O_WRONLY | O_TRUNC | O_CREAT, 0666);
if (fd < 0)
{
- throw CABRTException(EXCEP_DD_SAVE, ssprintf("Can't open file '%s'", pPath));
+ throw CABRTException(EXCEP_DD_SAVE, "Can't open file '%s'", pPath);
}
unsigned r = full_write(fd, pData, pSize);
close(fd);
if (r != pSize)
{
- throw CABRTException(EXCEP_DD_SAVE, ssprintf("Can't save file '%s'", pPath));
+ throw CABRTException(EXCEP_DD_SAVE, "Can't save file '%s'", pPath);
}
}
@@ -362,7 +362,7 @@ void CDebugDump::LoadText(const char* pName, std::string& pData)
{
if (!m_bOpened)
{
- throw CABRTException(EXCEP_DD_OPEN, "CDebugDump::LoadText(): DebugDump is not opened.");
+ throw CABRTException(EXCEP_DD_OPEN, "DebugDump is not opened");
}
std::string fullPath = concat_path_file(m_sDebugDumpDir.c_str(), pName);
LoadTextFile(fullPath.c_str(), pData);
@@ -372,7 +372,7 @@ void CDebugDump::SaveText(const char* pName, const char* pData)
{
if (!m_bOpened)
{
- throw CABRTException(EXCEP_DD_OPEN, "CDebugDump::SaveText(): DebugDump is not opened.");
+ throw CABRTException(EXCEP_DD_OPEN, "DebugDump is not opened");
}
std::string fullPath = concat_path_file(m_sDebugDumpDir.c_str(), pName);
SaveBinaryFile(fullPath.c_str(), pData, strlen(pData));
@@ -381,7 +381,7 @@ void CDebugDump::SaveBinary(const char* pName, const char* pData, unsigned pSize
{
if (!m_bOpened)
{
- throw CABRTException(EXCEP_DD_OPEN, "CDebugDump::SaveBinary(): DebugDump is not opened.");
+ throw CABRTException(EXCEP_DD_OPEN, "DebugDump is not opened");
}
std::string fullPath = concat_path_file(m_sDebugDumpDir.c_str(), pName);
SaveBinaryFile(fullPath.c_str(), pData, pSize);
@@ -400,7 +400,7 @@ void CDebugDump::InitGetNextFile()
m_pGetNextFileDir = opendir(m_sDebugDumpDir.c_str());
if (m_pGetNextFileDir == NULL)
{
- throw CABRTException(EXCEP_DD_OPEN, "Can't open dir " + m_sDebugDumpDir);
+ throw CABRTException(EXCEP_DD_OPEN, "Can't open dir '%s'", m_sDebugDumpDir.c_str());
}
}
diff --git a/lib/Utils/Makefile.am b/lib/Utils/Makefile.am
index 297007a..9618751 100644
--- a/lib/Utils/Makefile.am
+++ b/lib/Utils/Makefile.am
@@ -17,7 +17,8 @@ libABRTUtils_la_SOURCES = \
popen_and_save_output.cpp \
stringops.cpp \
dirsize.cpp \
- DebugDump.h DebugDump.cpp
+ DebugDump.h DebugDump.cpp \
+ ABRTException.cpp
libABRTUtils_la_CPPFLAGS = \
-Wall -Werror \
-I$(srcdir)/../../inc \
diff --git a/lib/Utils/abrt_xmlrpc.cpp b/lib/Utils/abrt_xmlrpc.cpp
index 11c431b..7205316 100644
--- a/lib/Utils/abrt_xmlrpc.cpp
+++ b/lib/Utils/abrt_xmlrpc.cpp
@@ -13,7 +13,7 @@ void throw_if_xml_fault_occurred(xmlrpc_env *env)
xmlrpc_env_clean(env); // this is needed ONLY if fault_occurred
xmlrpc_env_init(env); // just in case user catches ex and _continues_ to use env
error_msg("%s", errmsg.c_str()); // show error in daemon log
- throw CABRTException(EXCEP_PLUGIN, errmsg);
+ throw CABRTException(EXCEP_PLUGIN, errmsg.c_str());
}
}