Skip to content

Commit

Permalink
fix TENGINE_DUMP_DIR might not be treated as dir name (#1283)
Browse files Browse the repository at this point in the history
  • Loading branch information
gdh1995 committed Feb 17, 2022
1 parent 18166af commit 50dc355
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions source/device/cpu/cpu_dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -533,11 +533,11 @@ void extract_feature_from_tensor(const char* comment, const char* layer_name, co

const char* env_path = getenv(TENGINE_DUMP_DIR);

if (NULL != env_path && (256 - 2) > strlen(env_path))
if (NULL != env_path && '\0' != env_path[0] && (256 - 2) > strlen(env_path))
{
strcpy(save_dir, env_path);

if ('/' == save_dir[strlen(env_path)] || '\\' == save_dir[strlen(env_path)])
if ('/' == save_dir[strlen(env_path) - 1] || '\\' == save_dir[strlen(env_path) - 1])
{
#ifdef _MSC_VER
save_dir[strlen(env_path)] = '\\';
Expand Down
4 changes: 2 additions & 2 deletions source/device/opendla/odla_dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -518,11 +518,11 @@ void extract_feature_from_tensor_odla(const char* comment, const char* layer_nam

const char* env_path = getenv(TENGINE_DUMP_DIR);

if (NULL != env_path && (256 - 2) > strlen(env_path))
if (NULL != env_path && '\0' != env_path[0] && (256 - 2) > strlen(env_path))
{
strcpy(save_dir, env_path);

if ('/' == save_dir[strlen(env_path)] || '\\' == save_dir[strlen(env_path)])
if ('/' == save_dir[strlen(env_path) - 1] || '\\' == save_dir[strlen(env_path) - 1])
{
#ifdef _MSC_VER
save_dir[strlen(env_path)] = '\\';
Expand Down
4 changes: 2 additions & 2 deletions source/device/tim-vx/timvx_dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -458,11 +458,11 @@ void extract_feature_from_tensor_timvx(const char* comment, const char* layer_na

const char* env_path = getenv(TENGINE_DUMP_DIR);

if (NULL != env_path && (256 - 2) > strlen(env_path))
if (NULL != env_path && '\0' != env_path[0] && (256 - 2) > strlen(env_path))
{
strcpy(save_dir, env_path);

if ('/' == save_dir[strlen(env_path)] || '\\' == save_dir[strlen(env_path)])
if ('/' == save_dir[strlen(env_path) - 1] || '\\' == save_dir[strlen(env_path) - 1])
{
#ifdef _MSC_VER
save_dir[strlen(env_path)] = '\\';
Expand Down

0 comments on commit 50dc355

Please sign in to comment.