summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2009-12-15 19:54:51 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2009-12-15 19:54:51 +0100
commit1e119f37b85b90c5a9a17fdcbc80625727b4ab66 (patch)
tree2eda8402810f7148304c3f7ee878b86c9dcb67c8 /src
parent661875fe000fd0d8469ae20d587fa84624d7f262 (diff)
downloadabrt-1e119f37b85b90c5a9a17fdcbc80625727b4ab66.tar.gz
abrt-1e119f37b85b90c5a9a17fdcbc80625727b4ab66.tar.xz
abrt-1e119f37b85b90c5a9a17fdcbc80625727b4ab66.zip
fix all instances of atoi() usage
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'src')
-rw-r--r--src/Daemon/Daemon.cpp6
-rw-r--r--src/Daemon/MiddleWare.cpp2
-rw-r--r--src/Daemon/PluginManager.cpp6
-rw-r--r--src/Daemon/Settings.cpp2
-rw-r--r--src/Hooks/CCpp.cpp27
5 files changed, 22 insertions, 21 deletions
diff --git a/src/Daemon/Daemon.cpp b/src/Daemon/Daemon.cpp
index 153363d..db55f84 100644
--- a/src/Daemon/Daemon.cpp
+++ b/src/Daemon/Daemon.cpp
@@ -216,14 +216,14 @@ static int SetUpCron()
std::string sM = "";
sH = it_c->first.substr(0, pos);
- nH = atoi(sH.c_str());
+ nH = xatou(sH.c_str());
nH = nH > 23 ? 23 : nH;
nH = nH < 0 ? 0 : nH;
nM = nM > 59 ? 59 : nM;
nM = nM < 0 ? 0 : nM;
timeout += nH * 60 * 60;
sM = it_c->first.substr(pos + 1);
- nM = atoi(sM.c_str());
+ nM = xatou(sM.c_str());
timeout += nM * 60;
}
else
@@ -231,7 +231,7 @@ static int SetUpCron()
std::string sS = "";
sS = it_c->first;
- nS = atoi(sS.c_str());
+ nS = xatou(sS.c_str());
nS = nS <= 0 ? 1 : nS;
timeout = nS;
}
diff --git a/src/Daemon/MiddleWare.cpp b/src/Daemon/MiddleWare.cpp
index eb60ce4..fd2e86b 100644
--- a/src/Daemon/MiddleWare.cpp
+++ b/src/Daemon/MiddleWare.cpp
@@ -477,7 +477,7 @@ report_status_t Report(const map_crash_report_t& pCrashReport,
if (pUID != "")
{
- home = get_home_dir(atoi(pUID.c_str()));
+ home = get_home_dir(xatoi_u(pUID.c_str()));
if (home != "")
{
oldSettings = reporter->GetSettings();
diff --git a/src/Daemon/PluginManager.cpp b/src/Daemon/PluginManager.cpp
index 82f22e8..b6a8b15 100644
--- a/src/Daemon/PluginManager.cpp
+++ b/src/Daemon/PluginManager.cpp
@@ -391,7 +391,7 @@ void CPluginManager::SetPluginSettings(const char *pName,
return;
}
- std::string home = get_home_dir(atoi(pUID.c_str()));
+ std::string home = get_home_dir(xatoi_u(pUID.c_str()));
if (home == "")
{
return;
@@ -399,7 +399,7 @@ void CPluginManager::SetPluginSettings(const char *pName,
std::string confDir = home + "/.abrt";
std::string confPath = confDir + "/" + pName + "."PLUGINS_CONF_EXTENSION;
- uid_t uid = atoi(pUID.c_str());
+ uid_t uid = xatoi_u(pUID.c_str());
struct passwd* pw = getpwuid(uid);
gid_t gid = pw ? pw->pw_gid : uid;
@@ -461,7 +461,7 @@ map_plugin_settings_t CPluginManager::GetPluginSettings(const char *pName,
/*
if (abrt_plugin->second->GetType() == REPORTER)
{
- std::string home = get_home_dir(atoi(pUID.c_str()));
+ std::string home = get_home_dir(xatoi_u(pUID.c_str()));
if (home != "")
{
LoadPluginSettings(home + "/.abrt/" + pName + "."PLUGINS_CONF_EXTENSION, ret);
diff --git a/src/Daemon/Settings.cpp b/src/Daemon/Settings.cpp
index 327851f..d89bebf 100644
--- a/src/Daemon/Settings.cpp
+++ b/src/Daemon/Settings.cpp
@@ -176,7 +176,7 @@ static void ParseCommon()
it = s_mapSectionCommon.find("MaxCrashReportsSize");
if (it != end)
{
- g_settings_nMaxCrashReportsSize = atoi(it->second.c_str());
+ g_settings_nMaxCrashReportsSize = xatoi_u(it->second.c_str());
}
it = s_mapSectionCommon.find("ActionsAndReporters");
if (it != end)
diff --git a/src/Hooks/CCpp.cpp b/src/Hooks/CCpp.cpp
index fd789cf..e38c4f7 100644
--- a/src/Hooks/CCpp.cpp
+++ b/src/Hooks/CCpp.cpp
@@ -202,25 +202,26 @@ int main(int argc, char** argv)
logmode = LOGMODE_SYSLOG;
const char* dddir = argv[1];
- pid_t pid = atoi(argv[2]);
+ pid_t pid = xatoi_u(argv[2]);
const char* signal_str = argv[3];
- int signal = atoi(argv[3]);
- uid_t uid = atoi(argv[4]);
-
- if (signal != SIGQUIT
- && signal != SIGILL
- && signal != SIGABRT
- && signal != SIGFPE
- && signal != SIGSEGV
+ int signal_no = xatoi_u(argv[3]);
+ uid_t uid = xatoi_u(argv[4]);
+
+ if (signal_no != SIGQUIT
+ && signal_no != SIGILL
+ && signal_no != SIGABRT
+ && signal_no != SIGFPE
+ && signal_no != SIGSEGV
) {
/* not an error, exit silently */
return 0;
}
- if (pid <= 0 || (int)uid < 0)
+ if (pid <= 0)
{
- error_msg_and_die("pid '%s' or uid '%s' are bogus", argv[2], argv[4]);
+ error_msg_and_die("pid '%s' is bogus", argv[2]);
}
+
char *user_pwd = get_cwd(pid); /* may be NULL on error */
int core_fd = STDIN_FILENO;
@@ -299,7 +300,7 @@ int main(int argc, char** argv)
}
char* cmdline = get_cmdline(pid); /* never NULL */
- const char *signame = strsignal(atoi(signal_str));
+ const char *signame = strsignal(signal_no);
char *reason = xasprintf("Process was terminated by signal %s (%s)", signal_str, signame ? signame : signal_str);
snprintf(path, sizeof(path), "%s/ccpp-%ld-%u", dddir, (long)time(NULL), (int)pid);
@@ -388,7 +389,7 @@ int main(int argc, char** argv)
if (isdigit(*p))
/* x1.25: go a bit up, so that usual in-daemon trimming
* kicks in first, and we don't "fight" with it. */
- setting_MaxCrashReportsSize = (unsigned long)atoi(p) * 5 / 4;
+ setting_MaxCrashReportsSize = (unsigned long)xatou(p) * 5 / 4;
continue;
}
#undef DIRECTIVE