Fix review comments #51

Merged
Bogdan Nagirniak merged 15 commits from BLEN-430 into hydra-render 2023-06-08 18:10:55 +02:00
2 changed files with 11 additions and 12 deletions
Showing only changes of commit 4fa69acdd9 - Show all commits

View File

@ -21,16 +21,15 @@ static std::string cache_image_file(Image *image,
ImageUser *iuser,
bool check_exist)
{
std::string file_path(FILE_MAX, 0);
char file_path[FILE_MAX];
char file_name[32];
snprintf(file_name, 32, "img_%016llx.hdr", (uintptr_t)image);
BLI_path_join(file_path.data(),
file_path.capacity(),
snprintf(file_name, sizeof(file_name), "img_%016llx.hdr", (uintptr_t)image);
DagerD marked this conversation as resolved
Review

add same sizeof(...) to other places with snprintf()

add same `sizeof(...)` to other places with `snprintf()`
BLI_path_join(file_path, sizeof(file_path),
BKE_tempdir_session(),
"hydra_image_cache",
file_name);
if (check_exist && BLI_exists(file_path.c_str())) {
if (check_exist && BLI_exists(file_path)) {
return file_path;
}
@ -38,16 +37,16 @@ static std::string cache_image_file(Image *image,
ImageSaveOptions opts;
opts.im_format.imtype = R_IMF_IMTYPE_RADHDR;
if (BKE_image_save_options_init(&opts, main, scene_delegate->scene, image, iuser, true, false)) {
STRNCPY(opts.filepath, file_path.c_str());
ReportList reports;
if (!BKE_image_save(&reports, main, image, iuser, &opts)) {
file_path = "";
if (BKE_image_save_options_init(&opts, main, scene_delegate->scene, image, iuser, false, false))
{
STRNCPY(opts.filepath, file_path);
if (!BKE_image_save(nullptr, main, image, iuser, &opts)) {
memset(file_path, 0, sizeof(file_path));
};
}
BKE_image_save_options_free(&opts);
CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 2, "%s -> %s", image->id.name, file_path.c_str());
CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 2, "%s -> %s", image->id.name, file_path);
return file_path;
}

View File

@ -126,7 +126,7 @@ bool InstancerData::update_visibility()
char name[16];
for (auto &l_inst : light_instances_.values()) {
for (int i = 0; i < l_inst.count; ++i) {
snprintf(name, 16, "L_%08x", i);
snprintf(name, sizeof(name), "L_%08x", i);
change_tracker.MarkRprimDirty(l_inst.data->prim_id.AppendElementString(name),
pxr::HdChangeTracker::DirtyVisibility);
}