[Issue#] LINUXWRT-127
[Problem] Cppcheck reports some warnings.
[Cause] N/A
[Solution] N/A
[Verification] Run cppcheck on wrt-installer (with
--suppress=incorrectStringBooleanError) or check cppcheck.txt generated
by buildbot (ignore warnigs like "A boolean comparison with the string literal
... is always true").
Useful could be installation of rpm on target and checking that is all
right still.
Change-Id: Idf0533e5ef7f1de1f127b3b3fea3418ad34e1680
20 files changed:
break;
default:
Assert(false);
break;
default:
Assert(false);
}
}
} // namespace Unicode
}
}
} // namespace Unicode
break;
default:
LogError("Error in Access tag - unknown standard.");
break;
default:
LogError("Error in Access tag - unknown standard.");
ConfigParserData::AccessInfo accessInfo(m_strIRIOrigin,
m_bSubDomainAccess);
ConfigParserData::AccessInfo accessInfo(m_strIRIOrigin,
m_bSubDomainAccess);
- std::pair <ConfigParserData::AccessInfoSet::iterator, bool> ret =
+ //std::pair <ConfigParserData::AccessInfoSet::iterator, bool> ret =
m_data.accessInfoSet.insert(accessInfo);
}
m_data.accessInfoSet.insert(accessInfo);
}
break;
default:
LogError("Error in Access tag - unknown standard.");
break;
default:
LogError("Error in Access tag - unknown standard.");
explicit BoxSizeParser(
ConfigParserData::LiveboxInfo::BoxContentInfo& data) :
ElementParser(),
explicit BoxSizeParser(
ConfigParserData::LiveboxInfo::BoxContentInfo& data) :
ElementParser(),
+ m_properNamespace(false),
namespace Jobs {
Job::Job(InstallationType installType) :
namespace Jobs {
Job::Job(InstallationType installType) :
m_installationType(installType),
m_UndoType(false),
m_paused(false)
m_installationType(installType),
m_UndoType(false),
m_paused(false)
PluginInstallTask::PluginInstallTask(PluginInstallerContext *inCont) :
DPL::TaskDecl<PluginInstallTask>(this),
m_context(inCont),
PluginInstallTask::PluginInstallTask(PluginInstallerContext *inCont) :
DPL::TaskDecl<PluginInstallTask>(this),
m_context(inCont),
m_dataFromConfigXML(true)
{
AddStep(&PluginInstallTask::stepCheckPluginPath);
m_dataFromConfigXML(true)
{
AddStep(&PluginInstallTask::stepCheckPluginPath);
default:
LogDebug("Unknown owner type of cert");
certData[i]->owner = UNKNOWN;
default:
LogDebug("Unknown owner type of cert");
certData[i]->owner = UNKNOWN;
}
switch (it->type) {
case WrtDB::WidgetCertificateData::ENDENTITY:
}
switch (it->type) {
case WrtDB::WidgetCertificateData::ENDENTITY:
default:
LogError("Unknown type of cert");
certData[i]->type = ENDENTITY;
default:
LogError("Unknown type of cert");
certData[i]->type = ENDENTITY;
}
certData[i]->chain_id = it->chainId;
}
certData[i]->chain_id = it->chainId;
}
LogDebug("Registerign widget in ace");
}
LogDebug("Registerign widget in ace");
- ace_return_t retval = ACE_ACE_UNKNOWN_ERROR;
- retval = ace_register_widget(
+ ace_return_t retval = ace_register_widget(
static_cast<ace_widget_handle_t>(widgetHandle), &wi, certData);
//clean up - WidgetInfo
static_cast<ace_widget_handle_t>(widgetHandle), &wi, certData);
//clean up - WidgetInfo
JobContextBase<WidgetInstallationStruct>(installerStruct),
m_exceptionCaught(Exceptions::Success)
{
JobContextBase<WidgetInstallationStruct>(installerStruct),
m_exceptionCaught(Exceptions::Success)
{
- struct timeval tv;
- gettimeofday(&tv, NULL);
- srand(time(NULL) + tv.tv_usec);
-
m_installerContext.m_quiet = m_jobStruct.m_quiet;
ConfigureResult result = PrePareInstallation(widgetPath);
m_installerContext.m_quiet = m_jobStruct.m_quiet;
ConfigureResult result = PrePareInstallation(widgetPath);
// TODO : generate name move to wrt-commons
std::string allowedString("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
std::ostringstream genName;
// TODO : generate name move to wrt-commons
std::string allowedString("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
std::ostringstream genName;
+ struct timeval tv;
+ gettimeofday(&tv, NULL);
+ unsigned int seed = time(NULL) + tv.tv_usec;
- genName << "_" << allowedString[rand() % allowedString.length()];
+ genName << "_" << allowedString[rand_r(&seed) % allowedString.length()];
name = DPL::FromUTF8String(genName.str());
LogDebug("name was generated by WRT");
}
name = DPL::FromUTF8String(genName.str());
LogDebug("name was generated by WRT");
}
LogInfo("Widget model exists. tizen app id: " << tzAppid);
// Check running state
LogInfo("Widget model exists. tizen app id: " << tzAppid);
// Check running state
- int retval = APP_MANAGER_ERROR_NONE;
- retval = app_manager_is_running(DPL::ToUTF8String(
+ int retval = app_manager_is_running(DPL::ToUTF8String(
tzAppid).c_str(), &isRunning);
if (APP_MANAGER_ERROR_NONE != retval) {
LogError("Fail to get running state");
tzAppid).c_str(), &isRunning);
if (APP_MANAGER_ERROR_NONE != retval) {
LogError("Fail to get running state");
namespace WidgetInstall {
TaskCertificates::TaskCertificates(InstallerContext& context) :
DPL::TaskDecl<TaskCertificates>(this),
namespace WidgetInstall {
TaskCertificates::TaskCertificates(InstallerContext& context) :
DPL::TaskDecl<TaskCertificates>(this),
+ m_context(context),
+ m_pkgHandle(NULL)
{
AddStep(&TaskCertificates::StepSetCertiInfo);
AddAbortStep(&TaskCertificates::StepAbortCertiInfo);
{
AddStep(&TaskCertificates::StepSetCertiInfo);
AddAbortStep(&TaskCertificates::StepAbortCertiInfo);
namespace WidgetInstall {
TaskEncryptResource::TaskEncryptResource(InstallerContext& context) :
DPL::TaskDecl<TaskEncryptResource>(this),
namespace WidgetInstall {
TaskEncryptResource::TaskEncryptResource(InstallerContext& context) :
DPL::TaskDecl<TaskEncryptResource>(this),
+ m_context(context),
+ m_resEnc(NULL)
{
AddStep(&TaskEncryptResource::StepEncryptResource);
}
{
AddStep(&TaskEncryptResource::StepEncryptResource);
}
<< " with error: "
<< strerror(ftsent->fts_errno));
ThrowMsg(Exceptions::InternalError, "Error reading file");
<< " with error: "
<< strerror(ftsent->fts_errno));
ThrowMsg(Exceptions::InternalError, "Error reading file");
- struct dirent* dEntry = NULL;
+ struct dirent dEntry;
+ struct dirent *dEntryResult;
+ int return_code;
+
do {
struct stat statInfo;
do {
struct stat statInfo;
- if ((dEntry = readdir(dir)) != NULL) {
- std::string fileName = dEntry->d_name;
+ return_code = readdir_r(dir, &dEntry, &dEntryResult);
+ if (dEntryResult != NULL && return_code == 0) {
+ std::string fileName = dEntry.d_name;
std::string fullName = source + "/" + fileName;
if (stat(fullName.c_str(), &statInfo) != 0) {
std::string fullName = source + "/" + fileName;
if (stat(fullName.c_str(), &statInfo) != 0) {
outfile.close();
infile.close();
}
outfile.close();
infile.close();
}
+ } while (dEntryResult != NULL && return_code == 0);
closedir(dir);
return true;
}
closedir(dir);
return true;
}
namespace WidgetInstall {
TaskFileManipulation::TaskFileManipulation(InstallerContext& context) :
DPL::TaskDecl<TaskFileManipulation>(this),
namespace WidgetInstall {
TaskFileManipulation::TaskFileManipulation(InstallerContext& context) :
DPL::TaskDecl<TaskFileManipulation>(this),
+ m_context(context),
+ m_extHandle(NULL)
{
if (INSTALL_LOCATION_TYPE_EXTERNAL !=
m_context.locationType)
{
if (INSTALL_LOCATION_TYPE_EXTERNAL !=
m_context.locationType)
TaskManifestFile::TaskManifestFile(InstallerContext &inCont) :
DPL::TaskDecl<TaskManifestFile>(this),
TaskManifestFile::TaskManifestFile(InstallerContext &inCont) :
DPL::TaskDecl<TaskManifestFile>(this),
+ m_context(inCont),
+ writer(NULL)
{
if (false == m_context.existingWidgetInfo.isExist) {
AddStep(&TaskManifestFile::stepCopyIconFiles);
{
if (false == m_context.existingWidgetInfo.isExist) {
AddStep(&TaskManifestFile::stepCopyIconFiles);
for (WrtDB::WidgetRegisterInfo::LocalizedIconList::const_reverse_iterator
icon = icons.rbegin();
icon != icons.rend();
for (WrtDB::WidgetRegisterInfo::LocalizedIconList::const_reverse_iterator
icon = icons.rbegin();
icon != icons.rend();
{
FOREACH(locale, icon->availableLocales)
{
{
FOREACH(locale, icon->availableLocales)
{
ThrowMsg(Exceptions::InternalError, path);
}
ThrowMsg(Exceptions::InternalError, path);
}
- struct dirent* d_ent;
- do {
- if ((d_ent = readdir(dir))) {
- if (strcmp(d_ent->d_name, ".") == 0 ||
- strcmp(d_ent->d_name, "..") == 0)
- {
- continue;
- }
- std::string file_name = d_ent->d_name;
- list.push_back(file_name);
+ struct dirent entry;
+ struct dirent *result;
+ int return_code;
+ errno = 0;
+ for (return_code = readdir_r(dir, &entry, &result);
+ result != NULL && return_code == 0;
+ return_code = readdir_r(dir, &entry, &result))
+ {
+ if (strcmp(entry.d_name, ".") == 0 ||
+ strcmp(entry.d_name, "..") == 0)
+ {
+ continue;
+ std::string file_name = entry.d_name;
+ list.push_back(file_name);
+ }
+
+ if (return_code != 0 || errno != 0) {
+ LogError("readdir_r() failed with " << DPL::GetErrnoString());
+ }
+
if (-1 == TEMP_FAILURE_RETRY(closedir(dir))) {
LogError("Failed to close dir: " << path << " with error: "
<< DPL::GetErrnoString());
if (-1 == TEMP_FAILURE_RETRY(closedir(dir))) {
LogError("Failed to close dir: " << path << " with error: "
<< DPL::GetErrnoString());
for (WrtDB::WidgetRegisterInfo::LocalizedIconList::const_reverse_iterator
icon = icons.rbegin();
icon != icons.rend();
for (WrtDB::WidgetRegisterInfo::LocalizedIconList::const_reverse_iterator
icon = icons.rbegin();
icon != icons.rend();
{
FOREACH(locale, icon->availableLocales)
{
{
FOREACH(locale, icon->availableLocales)
{
LiveBoxInfo liveBox;
DPL::Optional<WrtDB::ConfigParserData::LiveboxInfo> ConfigInfo = *it;
DPL::String appid = m_context.widgetConfig.tzAppid;
LiveBoxInfo liveBox;
DPL::Optional<WrtDB::ConfigParserData::LiveboxInfo> ConfigInfo = *it;
DPL::String appid = m_context.widgetConfig.tzAppid;
if (ConfigInfo->m_liveboxId != L"") {
if (ConfigInfo->m_liveboxId != L"") {
- found = ConfigInfo->m_liveboxId.find_last_of(L".");
+ size_t found = ConfigInfo->m_liveboxId.find_last_of(L".");
if (found != std::string::npos) {
if (0 == ConfigInfo->m_liveboxId.compare(0, found, appid)) {
liveBox.setLiveboxId(ConfigInfo->m_liveboxId);
if (found != std::string::npos) {
if (0 == ConfigInfo->m_liveboxId.compare(0, found, appid)) {
liveBox.setLiveboxId(ConfigInfo->m_liveboxId);
/* Find all .so files and store their names in list */
DIR *dir;
/* Find all .so files and store their names in list */
DIR *dir;
struct stat st;
LogDebug("Opening plugins directory");
dir = opendir(m_npsource.c_str());
struct stat st;
LogDebug("Opening plugins directory");
dir = opendir(m_npsource.c_str());
ThrowMsg(Exceptions::InternalError, "Unable to read plugins directory");
}
std::string tempname;
ThrowMsg(Exceptions::InternalError, "Unable to read plugins directory");
}
std::string tempname;
+ struct dirent entry;
+ struct dirent *result;
+ int return_code;
+ errno = 0;
const std::string ext(".so");
/* Listing directory and checking entries found inside */
const std::string ext(".so");
/* Listing directory and checking entries found inside */
- while ((entry = readdir(dir)) != NULL) {
- tempname = m_npsource + "/" + entry->d_name;
+ for (return_code = readdir_r(dir, &entry, &result);
+ result != NULL && return_code == 0;
+ return_code = readdir_r(dir, &entry, &result))
+ {
+ tempname = m_npsource + "/" + entry.d_name;
if (lstat(tempname.c_str(), &st) != 0) {
LogWarning(
"Failed to call \"lstat\" (errno:" << errno
if (lstat(tempname.c_str(), &st) != 0) {
LogWarning(
"Failed to call \"lstat\" (errno:" << errno
}
/* Directories other than "." and ".." should not be found*/
if (S_ISDIR(st.st_mode)) {
}
/* Directories other than "." and ".." should not be found*/
if (S_ISDIR(st.st_mode)) {
- if (strncmp(entry->d_name, "..", 2) != 0
- && strncmp(entry->d_name, ".", 1) != 0)
+ if (strncmp(entry.d_name, "..", 2) != 0
+ && strncmp(entry.d_name, ".", 1) != 0)
{
LogError("Directory detected instead of plugin file: "
{
LogError("Directory detected instead of plugin file: "
/* Subdirectories inside plugins/ARCH are not supported */
if (-1 == TEMP_FAILURE_RETRY(closedir(dir))) {
LogError(
/* Subdirectories inside plugins/ARCH are not supported */
if (-1 == TEMP_FAILURE_RETRY(closedir(dir))) {
LogError(
- tempname = std::string(entry->d_name);
+ tempname = std::string(entry.d_name);
/* Check whether file extension is ".so" */
if (tempname.compare(tempname.size() - ext.size(), ext.size(),
ext) == 0)
/* Check whether file extension is ".so" */
if (tempname.compare(tempname.size() - ext.size(), ext.size(),
ext) == 0)
LogWarning("Non-plugin file found: " << tempname);
}
}
LogWarning("Non-plugin file found: " << tempname);
}
}
+ if (return_code != 0 || errno != 0) {
+ LogError("readdir_r() failed with " << DPL::GetErrnoString());
+ }
+ errno = 0;
if (-1 == TEMP_FAILURE_RETRY(closedir(dir))) {
LogError("Failed to close dir: " << m_npsource << " with error: "
<< DPL::GetErrnoString());
if (-1 == TEMP_FAILURE_RETRY(closedir(dir))) {
LogError("Failed to close dir: " << m_npsource << " with error: "
<< DPL::GetErrnoString());
/* Copy plugins from widget package into
* .netscape/plugins in widget's target directory */
for (std::list<std::string>::const_iterator it = m_nplugins.begin();
/* Copy plugins from widget package into
* .netscape/plugins in widget's target directory */
for (std::list<std::string>::const_iterator it = m_nplugins.begin();
- it != m_nplugins.end(); it++)
+ it != m_nplugins.end(); ++it)
{
LogDebug("Copying plugin file: " << (*it));
source = m_npsource + "/" + (*it);
{
LogDebug("Copying plugin file: " << (*it));
source = m_npsource + "/" + (*it);
FILE *temp = fopen(infoPath.str().c_str(), "w+");
if (temp != NULL) {
fputs(m_context.locations->getWidgetSource().c_str(), temp);
FILE *temp = fopen(infoPath.str().c_str(), "w+");
if (temp != NULL) {
fputs(m_context.locations->getWidgetSource().c_str(), temp);
- if (-1 == fsync(temp->_fileno)) {
- fclose(temp);
+ int ret = fsync(temp->_fileno);
+ fclose(temp);
+ if (-1 == ret) {
ThrowMsg(Exceptions::InternalError, "Fail to fsync for recovery.");
}
ThrowMsg(Exceptions::InternalError, "Fail to fsync for recovery.");
}
m_context.installInfo = infoPath.str();
m_context.installInfo = infoPath.str();
void TaskUpdateFiles::StepCreateBackupFolder()
{
LogDebug("StepCreateBackupFolder");
void TaskUpdateFiles::StepCreateBackupFolder()
{
LogDebug("StepCreateBackupFolder");
- std::ostringstream backDirPath;
std::string srcBuPath = m_context.locations->getBackupSourceDir();
LogDebug("backup resource directory path : " << srcBuPath);
std::string srcBuPath = m_context.locations->getBackupSourceDir();
LogDebug("backup resource directory path : " << srcBuPath);
- do {
- if ((dirent = readdir(pkgDir))) {
- std::string dirName = dirent->d_name;
- std::string absFileName = dirPath + "/" + dirName;
- if (stat(absFileName.c_str(), &statInfo) != 0) {
- ThrowMsg(Exceptions::InternalError, "Error occurs read file");
- }
+ struct dirent dirent;
+ struct dirent *result;
+ int return_code;
+ errno = 0;
+ for (return_code = readdir_r(pkgDir, &dirent, &result);
+ result != NULL && return_code == 0;
+ return_code = readdir_r(pkgDir, &dirent, &result))
+ {
+ std::string dirName = dirent.d_name;
+ std::string absFileName = dirPath + "/" + dirName;
+ if (stat(absFileName.c_str(), &statInfo) != 0) {
+ ThrowMsg(Exceptions::InternalError, "Error occurs read file");
+ }
- if (S_ISDIR(statInfo.st_mode)) {
- if (strcmp(dirent->d_name, ".") == 0 || strcmp(dirent->d_name,
- "..") == 0)
- {
- continue;
- }
- ReadDirList(absFileName, list, subLen);
+ if (S_ISDIR(statInfo.st_mode)) {
+ if (strcmp(dirent.d_name, ".") == 0 || strcmp(dirent.d_name,
+ "..") == 0)
+ {
+ continue;
-
- list.insert(absFileName.substr(subLen));
+ ReadDirList(absFileName, list, subLen);
+
+ list.insert(absFileName.substr(subLen));
+ }
+ if (return_code != 0 || errno != 0) {
+ LogError("readdir_r() failed with " << DPL::GetErrnoString());
+ }
+ errno = 0;
//closing the directory
if (-1 == TEMP_FAILURE_RETRY(closedir(pkgDir))) {
LogError("Failed to close dir: " << dirPath << " with error: "
//closing the directory
if (-1 == TEMP_FAILURE_RETRY(closedir(pkgDir))) {
LogError("Failed to close dir: " << dirPath << " with error: "
- do {
- errno = 0;
- if ((dirent = readdir(localeDir))) {
- DPL::String dirName = DPL::FromUTF8String(dirent->d_name);
- std::string absoluteDirName = localePath + "/";
- absoluteDirName += dirent->d_name;
-
- if (stat(absoluteDirName.c_str(), &statStruct) != 0) {
- LogError("stat() failed with " << DPL::GetErrnoString());
- continue;
- }
+ struct dirent dirent;
+ struct dirent *result;
+ int return_code;
+ errno = 0;
+ for (return_code = readdir_r(localeDir, &dirent, &result);
+ result != NULL && return_code == 0;
+ return_code = readdir_r(localeDir, &dirent, &result))
+ {
+ DPL::String dirName = DPL::FromUTF8String(dirent.d_name);
+ std::string absoluteDirName = localePath + "/";
+ absoluteDirName += dirent.d_name;
- if (S_ISDIR(statStruct.st_mode)) {
- //Yes, we ignore current, parent & hidden directories
- if (dirName[0] != L'.') {
- LogDebug("Adding locale directory \"" << dirName << "\"");
- m_localeFolders.insert(dirName);
- }
+ if (stat(absoluteDirName.c_str(), &statStruct) != 0) {
+ LogError("stat() failed with " << DPL::GetErrnoString());
+ continue;
+ }
+
+ if (S_ISDIR(statStruct.st_mode)) {
+ //Yes, we ignore current, parent & hidden directories
+ if (dirName[0] != L'.') {
+ LogDebug("Adding locale directory \"" << dirName << "\"");
+ m_localeFolders.insert(dirName);
- if (errno != 0) {
- LogError("readdir() failed with " << DPL::GetErrnoString());
+ if (return_code != 0 || errno != 0) {
+ LogError("readdir_r() failed with " << DPL::GetErrnoString());
}
if (-1 == TEMP_FAILURE_RETRY(closedir(localeDir))) {
}
if (-1 == TEMP_FAILURE_RETRY(closedir(localeDir))) {
//TODO: rewrite this madness
std::string cfgAbsPath;
DIR* dir = NULL;
//TODO: rewrite this madness
std::string cfgAbsPath;
DIR* dir = NULL;
- struct dirent* ptr = NULL;
dir = opendir(_currentPath.c_str());
if (dir == NULL) {
dir = opendir(_currentPath.c_str());
if (dir == NULL) {
return false;
}
bool has_config_xml = false;
return false;
}
bool has_config_xml = false;
+ struct dirent ptr;
+ struct dirent *result;
+ int return_code;
- while ((ptr = readdir(dir)) != NULL) { //Find configuration file, based on
- // its name
- if (ptr->d_type == DT_REG) {
- if (!strcmp(ptr->d_name, WRT_WIDGET_CONFIG_FILE_NAME)) {
- std::string dName(ptr->d_name);
+
+ //Find configuration file, based on its name
+ for (return_code = readdir_r(dir, &ptr, &result);
+ result != NULL && return_code == 0;
+ return_code = readdir_r(dir, &ptr, &result))
+ {
+ if (ptr.d_type == DT_REG) {
+ if (!strcmp(ptr.d_name, WRT_WIDGET_CONFIG_FILE_NAME)) {
+ std::string dName(ptr.d_name);
WrtUtilJoinPaths(cfgAbsPath, _currentPath, dName);
//Parse widget configuration file
WrtUtilJoinPaths(cfgAbsPath, _currentPath, dName);
//Parse widget configuration file
+ if (errno != 0) {
+ LogError("readdir_r() failed with " << DPL::GetErrnoString());
+ }
+ errno = 0;
if (-1 == TEMP_FAILURE_RETRY(closedir(dir))) {
LogError("Failed to close dir: " << _currentPath << " with error: "
<< DPL::GetErrnoString());
if (-1 == TEMP_FAILURE_RETRY(closedir(dir))) {
LogError("Failed to close dir: " << _currentPath << " with error: "
<< DPL::GetErrnoString());
//check if deferred
//TODO if widget to be updated, then remove it from Deferred list?
//check if deferred
//TODO if widget to be updated, then remove it from Deferred list?
- int ret = APP_MANAGER_ERROR_NONE;
- ret = app_manager_is_running(m_context.tzAppid.c_str(), &isRunning);
+ int ret = app_manager_is_running(m_context.tzAppid.c_str(), &isRunning);
if (APP_MANAGER_ERROR_NONE != ret) {
LogError("Fail to get running state");
ThrowMsg(Exceptions::PlatformAPIFailure,
if (APP_MANAGER_ERROR_NONE != ret) {
LogError("Fail to get running state");
ThrowMsg(Exceptions::PlatformAPIFailure,
try {
WrtDB::WidgetDAOReadOnly dao(m_context.widgetConfig.tzAppid);
TizenAppId tzAppid = dao.getTizenAppId();
try {
WrtDB::WidgetDAOReadOnly dao(m_context.widgetConfig.tzAppid);
TizenAppId tzAppid = dao.getTizenAppId();
- const char *devCap = "";
int result = handle_access_control_conf_forWAC(
DPL::ToUTF8String(tzAppid).c_str(),
NULL,
int result = handle_access_control_conf_forWAC(
DPL::ToUTF8String(tzAppid).c_str(),
NULL,
#include <widget_install/task_commons.h>
#include <widget_install/task_commons.h>
-WidgetLocation::DirectoryDeletor::DirectoryDeletor()
-{
- m_dirpath = Jobs::WidgetInstall::createTempPath();
-}
+WidgetLocation::DirectoryDeletor::DirectoryDeletor() :
+ m_dirpath(Jobs::WidgetInstall::createTempPath())
+{}
-WidgetLocation::DirectoryDeletor::DirectoryDeletor(std::string tempPath)
-{
- m_dirpath = tempPath;
-}
+WidgetLocation::DirectoryDeletor::DirectoryDeletor(std::string tempPath) :
+ m_dirpath(tempPath)
+{}
WidgetLocation::DirectoryDeletor::~DirectoryDeletor()
{
WidgetLocation::DirectoryDeletor::~DirectoryDeletor()
{
WrtInstaller::WrtInstaller(int argc, char **argv) :
Application(argc, argv, "backend", false),
DPL::TaskDecl<WrtInstaller>(this),
WrtInstaller::WrtInstaller(int argc, char **argv) :
Application(argc, argv, "backend", false),
DPL::TaskDecl<WrtInstaller>(this),
+ m_installPolicy(WRT_WIM_NOT_INSTALLED),
m_packagePath(),
m_handle(-1),
m_initialized(false),
m_packagePath(),
m_handle(-1),
m_initialized(false),
}
LogInfo("Plugin DIRECTORY IS" << PLUGIN_PATH);
}
LogInfo("Plugin DIRECTORY IS" << PLUGIN_PATH);
- struct dirent* libdir;
-
- errno = 0;
std::list<std::string> pluginsPaths;
std::list<std::string> pluginsPaths;
-
- while ((libdir = readdir(dir)) != 0) {
- if (strcmp(libdir->d_name, ".") == 0 ||
- strcmp(libdir->d_name, "..") == 0)
+ struct dirent libdir;
+ struct dirent *result;
+ int return_code;
+ errno = 0;
+ for (return_code = readdir_r(dir, &libdir, &result);
+ result != NULL && return_code == 0;
+ return_code = readdir_r(dir, &libdir, &result))
+ {
+ if (strcmp(libdir.d_name, ".") == 0 ||
+ strcmp(libdir.d_name, "..") == 0)
{
continue;
}
std::string path = PLUGIN_PATH;
path += "/";
{
continue;
}
std::string path = PLUGIN_PATH;
path += "/";
- path += libdir->d_name;
pluginsPaths.push_back(path);
}
pluginsPaths.push_back(path);
}
+ if (return_code != 0 || errno != 0) {
+ LogError("readdir_r() failed with " << DPL::GetErrnoString());
+ }
+
//set nb of plugins to install
//this value indicate how many callbacks are expected
m_numPluginsToInstall = pluginsPaths.size();
//set nb of plugins to install
//this value indicate how many callbacks are expected
m_numPluginsToInstall = pluginsPaths.size();
void* userdata)
{
WrtInstaller *This = static_cast<WrtInstaller*>(userdata);
void* userdata)
{
WrtInstaller *This = static_cast<WrtInstaller*>(userdata);
- std::stringstream percentStr;
LogInfo(" progress: " << percent <<
" description: " << description);
LogInfo(" progress: " << percent <<
" description: " << description);
void* userdata)
{
WrtInstaller *This = static_cast<WrtInstaller*>(userdata);
void* userdata)
{
WrtInstaller *This = static_cast<WrtInstaller*>(userdata);
- std::stringstream percentStr;
LogInfo(" progress: " << percent <<
" description: " << description);
LogInfo(" progress: " << percent <<
" description: " << description);
}
LogInfo("Plugin DIRECTORY IS" << PLUGIN_PATH);
}
LogInfo("Plugin DIRECTORY IS" << PLUGIN_PATH);
+ struct dirent libdir;
+ struct dirent *result;
+ int return_code;
errno = 0;
std::list<std::string> pluginsPaths;
errno = 0;
std::list<std::string> pluginsPaths;
- while ((libdir = readdir(dir)) != 0) {
- if (strcmp(libdir->d_name, ".") == 0 ||
- strcmp(libdir->d_name, "..") == 0)
+ for (return_code = readdir_r(dir, &libdir, &result);
+ result != NULL && return_code == 0;
+ return_code = readdir_r(dir, &libdir, &result))
+ {
+ if (strcmp(libdir.d_name, ".") == 0 ||
+ strcmp(libdir.d_name, "..") == 0)
{
continue;
}
std::string path = PLUGIN_PATH;
path += "/";
{
continue;
}
std::string path = PLUGIN_PATH;
path += "/";
- path += libdir->d_name;
plugin_install_progress_cb);
}
plugin_install_progress_cb);
}
+ if (return_code != 0 || errno != 0) {
+ LogError("readdir_r() failed with " << DPL::GetErrnoString());
+ }
+
+ errno = 0;
if (-1 == TEMP_FAILURE_RETRY(closedir(dir))) {
LogError("Failed to close dir: " << PLUGIN_PATH << " with error: "
<< DPL::GetErrnoString());
if (-1 == TEMP_FAILURE_RETRY(closedir(dir))) {
LogError("Failed to close dir: " << PLUGIN_PATH << " with error: "
<< DPL::GetErrnoString());
}
EXPORT_API WrtErrStatus wrt_get_widget_by_guid(std::string & tzAppid,
}
EXPORT_API WrtErrStatus wrt_get_widget_by_guid(std::string & tzAppid,
- const std::string guid)
+ const std::string & guid)
{
try {
LogInfo("[WRT-API] GETTING WIDGET PACKAGE NAME BY WidgetID : "
{
try {
LogInfo("[WRT-API] GETTING WIDGET PACKAGE NAME BY WidgetID : "
WrtDB::WidgetDAOReadOnly dao(widget_guid);
tzAppid = DPL::ToUTF8String(dao.getTzAppId());
return WRT_SUCCESS;
WrtDB::WidgetDAOReadOnly dao(widget_guid);
tzAppid = DPL::ToUTF8String(dao.getTzAppId());
return WRT_SUCCESS;
- } catch (WidgetDAOReadOnly::Exception::WidgetNotExist) {
+ } catch (WidgetDAOReadOnly::Exception::WidgetNotExist&) {
LogError("Error package name is not found");
return WRT_ERROR_PKGNAME_NOT_FOUND;
} catch (const DPL::Exception& ex) {
LogError("Error package name is not found");
return WRT_ERROR_PKGNAME_NOT_FOUND;
} catch (const DPL::Exception& ex) {
* @return error code
*/
WrtErrStatus wrt_get_widget_by_guid(std::string &tzAppid,
* @return error code
*/
WrtErrStatus wrt_get_widget_by_guid(std::string &tzAppid,
- const std::string guid);
+ const std::string &guid);
#ifdef __cplusplus
}
#endif
#ifdef __cplusplus
}
#endif
}
char buffer[1024] = "";
}
char buffer[1024] = "";
- int ret;
- while ((ret = fread_unlocked(buffer,
- sizeof(char),
- sizeof(buffer)/sizeof(char),
- filehandle)) > 0)
+ while ( fread_unlocked(buffer, sizeof(char),
+ sizeof(buffer)/sizeof(char), filehandle) > 0 )