diff --git a/lib_jtag_core/src/os_interface/fs.c b/lib_jtag_core/src/os_interface/fs.c index 3c02263..480d5d9 100644 --- a/lib_jtag_core/src/os_interface/fs.c +++ b/lib_jtag_core/src/os_interface/fs.c @@ -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; @@ -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 { diff --git a/lib_jtag_core/src/os_interface/os_interface.c b/lib_jtag_core/src/os_interface/os_interface.c index 4226e6e..2240d24 100644 --- a/lib_jtag_core/src/os_interface/os_interface.c +++ b/lib_jtag_core/src/os_interface/os_interface.c @@ -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; @@ -314,17 +316,24 @@ int genos_createthread(jtag_core* jtag_ctx,void* hwcontext,THREADFUNCTION thread /* set the new scheduling param */ pthread_attr_setschedparam (&threadattrib, ¶m); - 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; diff --git a/lib_jtag_core/src/script/env.c b/lib_jtag_core/src/script/env.c index 3f0df61..8f016d0 100644 --- a/lib_jtag_core/src/script/env.c +++ b/lib_jtag_core/src/script/env.c @@ -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); } } }