Skip to content

Commit

Permalink
More fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
jfdelnero committed Nov 13, 2023
1 parent 8694157 commit e9860a6
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 22 deletions.
5 changes: 3 additions & 2 deletions lib_jtag_core/src/os_interface/fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ FILE *genos_fopen (const char *filename, const char *mode)
}
}

fd = genos_open (filename, rwflags|oflags, 0666);
fd = genos_open (filename, rwflags|oflags, (unsigned int)(0666));
if(fd==-1)
return NULL;

Expand Down Expand Up @@ -408,10 +408,11 @@ void * genos_find_first_file(char *folder, char *file, filefoundinfo* fileinfo)
closedir (dir);
dir=0;

return (void*)dir;
}

closedir (dir);
dir=0;;
dir=0;
}
else
{
Expand Down
45 changes: 27 additions & 18 deletions lib_jtag_core/src/os_interface/os_interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -269,24 +269,26 @@ int genos_createthread(jtag_core* jtag_ctx,void* hwcontext,THREADFUNCTION thread
#ifdef WIN32
DWORD sit;
HANDLE thread_handle;

threadinit *threadinitptr;

sit = 0;

threadinitptr=(threadinit*)malloc(sizeof(threadinit));
threadinitptr->thread=thread;
threadinitptr->jtag_ctx=jtag_ctx;
threadinitptr->hwcontext=hwcontext;
if( threadinitptr )
{
threadinitptr->thread=thread;
threadinitptr->jtag_ctx=jtag_ctx;
threadinitptr->hwcontext=hwcontext;

thread_handle = CreateThread(NULL,8*1024,&ThreadProc,threadinitptr,0,&sit);
thread_handle = CreateThread(NULL,8*1024,&ThreadProc,threadinitptr,0,&sit);

if(!thread_handle)
{
// jtag_ctx->jtagcore_print_callback(MSG_ERROR,"genos_createthread : CreateThread failed -> 0x.8X", GetLastError());
if(!thread_handle)
{
// jtag_ctx->jtagcore_print_callback(MSG_ERROR,"genos_createthread : CreateThread failed -> 0x.8X", GetLastError());
}
}

return sit;
#else

unsigned long sit;
int ret;
pthread_t threadid;
Expand Down Expand Up @@ -314,17 +316,24 @@ int genos_createthread(jtag_core* jtag_ctx,void* hwcontext,THREADFUNCTION thread
/* set the new scheduling param */
pthread_attr_setschedparam (&threadattrib, &param);

threadinitptr=(threadinit *)malloc(sizeof(threadinit));
threadinitptr->thread=thread;
threadinitptr->jtag_ctx=jtag_ctx;
//threadinitptr->hwcontext=hwcontext;

print_callback = jtag_ctx->jtagcore_print_callback;

threadinitptr=(threadinit *)malloc(sizeof(threadinit));
if(threadinitptr)
{
threadinitptr->thread=thread;
threadinitptr->jtag_ctx=jtag_ctx;
//threadinitptr->hwcontext=hwcontext;

ret = pthread_create(&threadid, &threadattrib,ThreadProc, threadinitptr);
if(ret)
ret = pthread_create(&threadid, &threadattrib,ThreadProc, threadinitptr);
if(ret)
{
print_callback("genos_createthread : pthread_create failed !");
}
}
else
{
print_callback("genos_createthread : pthread_create failed");
print_callback("genos_createthread : memory allocation failed !");
}

return sit;
Expand Down
6 changes: 4 additions & 2 deletions lib_jtag_core/src/script/env.c
Original file line number Diff line number Diff line change
Expand Up @@ -237,13 +237,15 @@ envvar_entry * duplicate_env_vars(envvar_entry * src)
if(src[j].name)
{
tmp_envvars[j].name = malloc(strlen(src[j].name) + 1);
strcpy(tmp_envvars[j].name,src[j].name);
if(tmp_envvars[j].name)
strcpy(tmp_envvars[j].name,src[j].name);
}

if(src[j].varvalue)
{
tmp_envvars[j].varvalue = malloc(strlen(src[j].varvalue) + 1);
strcpy(tmp_envvars[j].varvalue,src[j].varvalue);
if(tmp_envvars[j].varvalue)
strcpy(tmp_envvars[j].varvalue,src[j].varvalue);
}
}
}
Expand Down

0 comments on commit e9860a6

Please sign in to comment.