- Replace strerror with strerror_r to make thread safe.
Signed-off-by: hyeonseok lee <hs89.lee@samsung.com>
status =
ml_tensors_data_get_tensor_data(data, 0, (void **)&raw_data, &data_size);
if (status != ML_ERROR_NONE) {
- LOG_E("get tensor data failed: reason %s", strerror(status));
+ const size_t error_buflen = 100;
+ char error_buf[error_buflen];
+ LOG_E("get tensor data failed: reason %s",
+ strerror_r(status, error_buf, error_buflen));
goto RESUME;
}
LOG_D("creating thread to run model");
status = pthread_create(&ad->tid_writer, NULL, data_run_model, (void *)ad);
if (status < 0) {
- LOG_E("creating pthread failed %s", strerror(errno));
+ const size_t error_buflen = 100;
+ char error_buf[error_buflen];
+ LOG_E("creating pthread failed %s",
+ strerror_r(errno, error_buf, error_buflen));
goto RESTORE_CB;
}
status = pthread_join(ad->tid_writer, NULL);
if (status < 0) {
- LOG_E("joining writing thread failed %s", strerror(errno));
+ const size_t error_buflen = 100;
+ char error_buf[error_buflen];
+ LOG_E("joining writing thread failed %s",
+ strerror_r(errno, error_buf, error_buflen));
pthread_cancel(ad->tid_writer);
}
status = pthread_create(&infer_thread, NULL, infer_, data);
if (status != 0) {
- LOG_E("creating pthread failed %s", strerror(errno));
+ const size_t error_buflen = 100;
+ char error_buf[error_buflen];
+ LOG_E("creating pthread failed %s",
+ strerror_r(errno, error_buf, error_buflen));
return;
}
status = pthread_detach(infer_thread);
if (status < 0) {
- LOG_E("detaching reading thread failed %s", strerror(errno));
+ const size_t error_buflen = 100;
+ char error_buf[error_buflen];
+ LOG_E("detaching reading thread failed %s",
+ strerror_r(errno, error_buf, error_buflen));
pthread_cancel(infer_thread);
}
}
presenter_on_back_button_press);
status = pthread_create(&train_thread, NULL, train_, (void *)ad);
if (status < 0) {
- LOG_E("creating pthread failed %s", strerror(errno));
+ const size_t error_buflen = 100;
+ char error_buf[error_buflen];
+ LOG_E("creating pthread failed %s",
+ strerror_r(errno, error_buf, error_buflen));
return;
}
status = pthread_detach(train_thread);
if (status < 0) {
- LOG_E("detaching reading thread failed %s", strerror(errno));
+ const size_t error_buflen = 100;
+ char error_buf[error_buflen];
+ LOG_E("detaching reading thread failed %s",
+ strerror_r(errno, error_buf, error_buflen));
pthread_cancel(train_thread);
}
}
/********************* app related methods **************************/
static bool app_create(void *data) {
- /* Hook to take necessary actions before main event loop starts
+ /** Hook to take necessary actions before main event loop starts
Initialize UI resources and application's data
If this function returns true, the main loop of application starts
If this function returns false, the application is terminated */
/// @note below logic assumes a single input and the fine label is used
auto fill_one_sample = [this](float *input_, float *label_, int index) {
+ const size_t error_buflen = 100;
+ char error_buf[error_buflen];
NNTR_THROW_IF(!file.good(), std::invalid_argument)
- << "file is not good, reason: " << std::strerror(errno);
+ << "file is not good, reason: "
+ << strerror_r(errno, error_buf, error_buflen);
file.seekg(index * Cifar100DataLoader::SampleSize, std::ios_base::beg);
uint8_t current_label;
<< FUNC_TAG << "Verifying serialized model failed";
std::ofstream os(out, std::ios_base::binary);
+ const size_t error_buflen = 100;
+ char error_buf[error_buflen];
NNTR_THROW_IF(!os.good(), std::invalid_argument)
- << FUNC_TAG << "failed to open, reason: " << strerror(errno);
+ << FUNC_TAG
+ << "failed to open, reason: " << strerror_r(errno, error_buf, error_buflen);
os.write((char *)builder.GetBufferPointer(), builder.GetSize());
os.close();
}
auto config_realpath_char = getRealpath(config.c_str(), nullptr);
if (config_realpath_char == nullptr) {
+ const size_t error_buflen = 100;
+ char error_buf[error_buflen];
ml_loge("failed to resolve config path to absolute path, reason: %s",
- strerror(errno));
+ strerror_r(errno, error_buf, error_buflen));
return ML_ERROR_INVALID_PARAMETER;
}
std::string config_realpath(config_realpath_char);
char *ptr = static_cast<char *>(
mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, off));
+ const size_t error_buflen = 100;
+ char error_buf[error_buflen];
NNTR_THROW_IF(ptr == (void *)-1, std::runtime_error)
- << "SwapDevice: mmap: " << std::string(strerror(errno));
+ << "SwapDevice: mmap: "
+ << std::string(strerror_r(errno, error_buf, error_buflen));
void *buf = static_cast<void *>(ptr + diff);
mapped[buf] = std::make_pair(ptr, len);
auto info = mapped[ptr];
ret = munmap(std::get<void *>(info), std::get<size_t>(info));
+ const size_t error_buflen = 100;
+ char error_buf[error_buflen];
NNTR_THROW_IF(ret == -1, std::runtime_error)
- << "SwapDevice: munmap: " << std::string(strerror(errno));
+ << "SwapDevice: munmap: "
+ << std::string(strerror_r(errno, error_buf, error_buflen));
mapped.erase(ptr);
void IniWrapper::erase_ini() const noexcept {
if (remove(getIniName().c_str())) {
- std::cerr << "remove ini " << getIniName()
- << "failed, reason: " << strerror(errno);
+ const size_t error_buflen = 100;
+ char error_buf[error_buflen];
+ std::cerr << "remove ini " << getIniName() << "failed, reason: "
+ << strerror_r(errno, error_buf, error_buflen);
}
}
T checkedOpenStream(const std::string &path, std::ios_base::openmode mode) {
T model_file(path, mode);
if (!model_file.good()) {
+ const size_t error_buflen = 100;
+ char error_buf[error_buflen];
std::stringstream ss;
ss << "[parseutil] requested file not opened, file path: " << path
- << " reason: " << std::strerror(errno);
+ << " reason: " << strerror_r(errno, error_buf, error_buflen);
if (errno == EPERM || errno == EACCES) {
throw nntrainer::exception::permission_denied(ss.str().c_str());
} else {