* If _POSIX_SEMAPHORES is not defined, It's no need to allocate buffer. so, allocate buffer after checking it.
* free the memory at the end of main(). Signed-off-by: Wei,Jiangang <weijg.f...@cn.fujitsu.com> --- testcases/open_posix_testsuite/functional/semaphores/sem_conpro.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/testcases/open_posix_testsuite/functional/semaphores/sem_conpro.c b/testcases/open_posix_testsuite/functional/semaphores/sem_conpro.c index f5f1abf..58657f9 100644 --- a/testcases/open_posix_testsuite/functional/semaphores/sem_conpro.c +++ b/testcases/open_posix_testsuite/functional/semaphores/sem_conpro.c @@ -102,12 +102,12 @@ int main(int argc, char *argv[]) int lock_value = 1; buf_t *buf; pthread_t con, pro; - buf = malloc(sizeof(buf_t)); #ifndef _POSIX_SEMAPHORES printf("_POSIX_SEMAPHORES is not defined \n"); return PTS_UNRESOLVED; #endif + buf = malloc(sizeof(buf_t)); if (-1 == sem_init(&(buf->occupied), shared, occupied_value)) { perror("sem_init didn't return success \n"); printf("hello \n"); @@ -129,5 +129,6 @@ int main(int argc, char *argv[]) pthread_join(pro, NULL); sem_destroy(&buf->occupied); sem_destroy(&buf->empty); + free(buf); return PTS_PASS; } -- 1.9.3 ------------------------------------------------------------------------------ Monitor 25 network devices or servers for free with OpManager! OpManager is web-based network management software that monitors network devices and physical & virtual servers, alerts via email & sms for fault. Monitor 25 devices for free with no restriction. Download now http://ad.doubleclick.net/ddm/clk/292181274;119417398;o _______________________________________________ Ltp-list mailing list Ltp-list@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/ltp-list