diff options
author | Buddy Liong | 2014-08-25 16:33:13 -0500 |
---|---|---|
committer | Buddy Liong | 2014-09-02 15:48:10 -0500 |
commit | 1916cfef94c4ee41c2beedc9cd87b8916ad29895 (patch) | |
tree | 6c5e0d047f865670ee4295a41adf53359fb3b85e | |
parent | 16c81c0153b31325782464f751915476fa4f3028 (diff) | |
download | hardware-ti-libdce-1916cfef94c4ee41c2beedc9cd87b8916ad29895.tar.gz hardware-ti-libdce-1916cfef94c4ee41c2beedc9cd87b8916ad29895.tar.xz hardware-ti-libdce-1916cfef94c4ee41c2beedc9cd87b8916ad29895.zip |
Fixing Klocwork finding
Running Klocwork stand-alone, it reports 19-20 issues.
This task submitted to resolve the found issues.
Change-Id: I98150d4262ee5b1ab85cb1a7c0e697dcadb4a665
Signed-off-by: Buddy Liong <buddy.budiono@ti.com>
-rw-r--r-- | libdce.c | 4 | ||||
-rw-r--r-- | test_qnx/dce_enc_test/dce_enc_test.c | 16 | ||||
-rw-r--r-- | test_qnx/dce_test/dce_test.c | 77 |
3 files changed, 67 insertions, 30 deletions
@@ -404,7 +404,7 @@ EXIT: | |||
404 | static XDAS_Int32 control(void *codec, int id, void *dynParams, void *status, dce_codec_type codec_id) | 404 | static XDAS_Int32 control(void *codec, int id, void *dynParams, void *status, dce_codec_type codec_id) |
405 | { | 405 | { |
406 | MmRpc_FxnCtx fxnCtx; | 406 | MmRpc_FxnCtx fxnCtx; |
407 | int32_t fxnRet; | 407 | int32_t fxnRet = XDM_EFAIL; |
408 | dce_error_status eError = DCE_EOK; | 408 | dce_error_status eError = DCE_EOK; |
409 | int coreIdx = INVALID_CORE; | 409 | int coreIdx = INVALID_CORE; |
410 | 410 | ||
@@ -462,7 +462,7 @@ static XDAS_Int32 get_version(void *codec, void *dynParams, void *status, dce_co | |||
462 | MmRpc_FxnCtx fxnCtx; | 462 | MmRpc_FxnCtx fxnCtx; |
463 | MmRpc_Xlt xltAry; | 463 | MmRpc_Xlt xltAry; |
464 | void * *version_buf = NULL; | 464 | void * *version_buf = NULL; |
465 | int32_t fxnRet; | 465 | int32_t fxnRet = XDM_EFAIL; |
466 | dce_error_status eError = DCE_EOK; | 466 | dce_error_status eError = DCE_EOK; |
467 | int coreIdx = INVALID_CORE; | 467 | int coreIdx = INVALID_CORE; |
468 | 468 | ||
diff --git a/test_qnx/dce_enc_test/dce_enc_test.c b/test_qnx/dce_enc_test/dce_enc_test.c index 046b4c5..e9130fd 100644 --- a/test_qnx/dce_enc_test/dce_enc_test.c +++ b/test_qnx/dce_enc_test/dce_enc_test.c | |||
@@ -228,7 +228,9 @@ static const char *get_path(const char *pattern, int cnt) | |||
228 | path = realloc(path, len); | 228 | path = realloc(path, len); |
229 | } | 229 | } |
230 | 230 | ||
231 | snprintf(path, len - 1, pattern, cnt); | 231 | if( path ) { |
232 | snprintf(path, len - 1, pattern, cnt); | ||
233 | } | ||
232 | 234 | ||
233 | return (path); | 235 | return (path); |
234 | } | 236 | } |
@@ -251,7 +253,11 @@ int read_input(const char *pattern, int cnt, char *input) | |||
251 | int sz = 0, n = 0, num_planes, i, buf_height; | 253 | int sz = 0, n = 0, num_planes, i, buf_height; |
252 | 254 | ||
253 | const char *path = get_path(pattern, cnt); | 255 | const char *path = get_path(pattern, cnt); |
254 | int fd = open(path, O_RDONLY); | 256 | if( path == NULL ) { |
257 | return (sz); | ||
258 | } | ||
259 | |||
260 | int fd = open(path, O_RDONLY); | ||
255 | 261 | ||
256 | //DEBUG("Open file fd %d errno %d", fd, errno); | 262 | //DEBUG("Open file fd %d errno %d", fd, errno); |
257 | if( fd < 0 ) { | 263 | if( fd < 0 ) { |
@@ -301,7 +307,11 @@ int write_output(const char *pattern, int cnt, char *output, int bytesToWrite) | |||
301 | { | 307 | { |
302 | int sz = 0; | 308 | int sz = 0; |
303 | const char *path = get_path(pattern, cnt); | 309 | const char *path = get_path(pattern, cnt); |
304 | int fd = open(path, O_WRONLY | O_CREAT | O_APPEND, 0644); | 310 | if( path == NULL ) { |
311 | return (sz); | ||
312 | } | ||
313 | |||
314 | int fd = open(path, O_WRONLY | O_CREAT | O_APPEND, 0644); | ||
305 | 315 | ||
306 | if( fd < 0 ) { | 316 | if( fd < 0 ) { |
307 | ERROR("could open output file: %s (%d)", path, errno); | 317 | ERROR("could open output file: %s (%d)", path, errno); |
diff --git a/test_qnx/dce_test/dce_test.c b/test_qnx/dce_test/dce_test.c index a1e82c4..c66598c 100644 --- a/test_qnx/dce_test/dce_test.c +++ b/test_qnx/dce_test/dce_test.c | |||
@@ -247,6 +247,22 @@ SysLinkMemUtils_translateAddr (UInt32 physAddr) | |||
247 | 247 | ||
248 | #endif | 248 | #endif |
249 | 249 | ||
250 | void output_free(void) | ||
251 | { | ||
252 | OutputBuffer *buf = head; | ||
253 | |||
254 | while((buf=head)) { | ||
255 | if( buf->tiler ) { | ||
256 | MemMgr_Free(buf->buf); | ||
257 | } else { | ||
258 | //munmap(buf->buf, buf->len); | ||
259 | SHM_release(&buf->shmBuf); | ||
260 | } | ||
261 | head = buf->next; | ||
262 | free(buf); | ||
263 | } | ||
264 | } | ||
265 | |||
250 | int output_allocate(XDM2_BufDesc *outBufs, int cnt, | 266 | int output_allocate(XDM2_BufDesc *outBufs, int cnt, |
251 | int width, int height, int stride) | 267 | int width, int height, int stride) |
252 | { | 268 | { |
@@ -277,6 +293,10 @@ int output_allocate(XDM2_BufDesc *outBufs, int cnt, | |||
277 | 293 | ||
278 | while( cnt ) { | 294 | while( cnt ) { |
279 | OutputBuffer *buf = calloc(sizeof(OutputBuffer), 1); | 295 | OutputBuffer *buf = calloc(sizeof(OutputBuffer), 1); |
296 | if( buf == NULL ) { | ||
297 | output_free(); | ||
298 | return (-ENOMEM); | ||
299 | } | ||
280 | 300 | ||
281 | DEBUG(" ----------------- create TILER buf 0x%x --------------------", (unsigned int)buf); | 301 | DEBUG(" ----------------- create TILER buf 0x%x --------------------", (unsigned int)buf); |
282 | 302 | ||
@@ -305,12 +325,16 @@ int output_allocate_nonTiler(XDM2_BufDesc *outBufs, int cnt, | |||
305 | int width, int height, int stride) | 325 | int width, int height, int stride) |
306 | { | 326 | { |
307 | int tw; | 327 | int tw; |
308 | XDAS_Int16 y_type, uv_type; | 328 | XDAS_Int16 y_type = XDM_MEMTYPE_RAW, uv_type = XDM_MEMTYPE_RAW; |
309 | 329 | ||
310 | outBufs->numBufs = 2; | 330 | outBufs->numBufs = 2; |
311 | 331 | ||
312 | while( cnt ) { | 332 | while( cnt ) { |
313 | OutputBuffer *buf = calloc(sizeof(OutputBuffer), 1); | 333 | OutputBuffer *buf = calloc(sizeof(OutputBuffer), 1); |
334 | if( buf == NULL ) { | ||
335 | output_free(); | ||
336 | return (-ENOMEM); | ||
337 | } | ||
314 | 338 | ||
315 | DEBUG(" ----------------- create nonTILER buf 0x%x --------------------", (unsigned int)buf); | 339 | DEBUG(" ----------------- create nonTILER buf 0x%x --------------------", (unsigned int)buf); |
316 | int size_y = width * height; | 340 | int size_y = width * height; |
@@ -393,22 +417,6 @@ int output_allocate_nonTiler(XDM2_BufDesc *outBufs, int cnt, | |||
393 | return (0); | 417 | return (0); |
394 | } | 418 | } |
395 | 419 | ||
396 | void output_free(void) | ||
397 | { | ||
398 | OutputBuffer *buf = head; | ||
399 | |||
400 | while((buf=head)) { | ||
401 | if( buf->tiler ) { | ||
402 | MemMgr_Free(buf->buf); | ||
403 | } else { | ||
404 | //munmap(buf->buf, buf->len); | ||
405 | SHM_release(&buf->shmBuf); | ||
406 | } | ||
407 | head = buf->next; | ||
408 | free(buf); | ||
409 | } | ||
410 | } | ||
411 | |||
412 | OutputBuffer *output_get(void) | 420 | OutputBuffer *output_get(void) |
413 | { | 421 | { |
414 | OutputBuffer *buf = head; | 422 | OutputBuffer *buf = head; |
@@ -443,7 +451,9 @@ static const char *get_path(const char *pattern, int cnt) | |||
443 | path = realloc(path, len); | 451 | path = realloc(path, len); |
444 | } | 452 | } |
445 | 453 | ||
446 | snprintf(path, len - 1, pattern, cnt); | 454 | if( path ) { |
455 | snprintf(path, len - 1, pattern, cnt); | ||
456 | } | ||
447 | 457 | ||
448 | return (path); | 458 | return (path); |
449 | } | 459 | } |
@@ -453,7 +463,12 @@ int read_input(const char *pattern, int cnt, char *input) | |||
453 | { | 463 | { |
454 | int sz = 0, n = 0; | 464 | int sz = 0, n = 0; |
455 | const char *path = get_path(pattern, cnt); | 465 | const char *path = get_path(pattern, cnt); |
456 | int fd = open(path, O_RDONLY); | 466 | |
467 | if( path == NULL ) { | ||
468 | return (sz); | ||
469 | } | ||
470 | |||
471 | int fd = open(path, O_RDONLY); | ||
457 | 472 | ||
458 | //DEBUG("Open file fd %d errno %d", fd, errno); | 473 | //DEBUG("Open file fd %d errno %d", fd, errno); |
459 | /* if we can't find the file, then at the end of stream */ | 474 | /* if we can't find the file, then at the end of stream */ |
@@ -483,9 +498,14 @@ int read_input(const char *pattern, int cnt, char *input) | |||
483 | /* helper to write one frame of output */ | 498 | /* helper to write one frame of output */ |
484 | int write_output(const char *pattern, int cnt, char *y, char *uv, int stride) | 499 | int write_output(const char *pattern, int cnt, char *y, char *uv, int stride) |
485 | { | 500 | { |
486 | int sz = 0, n, i; | 501 | int sz = 0, n = 0, i; |
487 | const char *path = get_path(pattern, cnt); | 502 | const char *path = get_path(pattern, cnt); |
488 | int fd = open(path, O_WRONLY | O_CREAT | O_APPEND, 0644); | 503 | |
504 | if( path == NULL ) { | ||
505 | return (sz); | ||
506 | } | ||
507 | |||
508 | int fd = open(path, O_WRONLY | O_CREAT | O_APPEND, 0644); | ||
489 | 509 | ||
490 | if( fd < 0 ) { | 510 | if( fd < 0 ) { |
491 | ERROR("could open output file: %s (%d)", path, errno); | 511 | ERROR("could open output file: %s (%d)", path, errno); |
@@ -582,6 +602,7 @@ int main(int argc, char * *argv) | |||
582 | unsigned char frameinput[10] = { "\0" }; | 602 | unsigned char frameinput[10] = { "\0" }; |
583 | int eof = 0; | 603 | int eof = 0; |
584 | int ivahd_decode_type; | 604 | int ivahd_decode_type; |
605 | char *temp_data = NULL; | ||
585 | char vid_codec[10]; | 606 | char vid_codec[10]; |
586 | char tilerbuffer[10]; | 607 | char tilerbuffer[10]; |
587 | unsigned int codec_switch = 0; | 608 | unsigned int codec_switch = 0; |
@@ -630,8 +651,10 @@ int main(int argc, char * *argv) | |||
630 | frameData = argv[4]; | 651 | frameData = argv[4]; |
631 | in_pattern = argv[5]; | 652 | in_pattern = argv[5]; |
632 | out_pattern = argv[6]; | 653 | out_pattern = argv[6]; |
633 | strcpy(vid_codec, argv[7]); | 654 | temp_data = argv[7]; |
634 | strcpy(tilerbuffer, argv[8]); | 655 | strcpy(vid_codec, temp_data); |
656 | temp_data = argv[8]; | ||
657 | strcpy(tilerbuffer, temp_data); | ||
635 | 658 | ||
636 | printf("Selected codec: %s\n", vid_codec); | 659 | printf("Selected codec: %s\n", vid_codec); |
637 | printf("Selected buffer: %s\n", tilerbuffer); | 660 | printf("Selected buffer: %s\n", tilerbuffer); |
@@ -684,6 +707,7 @@ int main(int argc, char * *argv) | |||
684 | DEBUG("frameFile open %p errno %d", frameFile, errno); | 707 | DEBUG("frameFile open %p errno %d", frameFile, errno); |
685 | if( frameFile == NULL ) { | 708 | if( frameFile == NULL ) { |
686 | DEBUG("Opening framesize file FAILED"); | 709 | DEBUG("Opening framesize file FAILED"); |
710 | return (1); | ||
687 | } | 711 | } |
688 | 712 | ||
689 | /* Read the frame Size from the frame size file */ | 713 | /* Read the frame Size from the frame size file */ |
@@ -691,11 +715,12 @@ int main(int argc, char * *argv) | |||
691 | frameSize[frameCount] = atoi((char *)frameinput); | 715 | frameSize[frameCount] = atoi((char *)frameinput); |
692 | //DEBUG("frameSize[%d] = %d \n", frameCount, frameSize[frameCount]); | 716 | //DEBUG("frameSize[%d] = %d \n", frameCount, frameSize[frameCount]); |
693 | 717 | ||
694 | if( frameCount > 64000 ) { | 718 | frameCount++; |
719 | |||
720 | if( frameCount >= 64000 ) { | ||
695 | DEBUG("Num Frames %d exceeded MAX limit %d \n", frameCount, 64000); | 721 | DEBUG("Num Frames %d exceeded MAX limit %d \n", frameCount, 64000); |
696 | goto out; | 722 | goto out; |
697 | } | 723 | } |
698 | frameCount++; | ||
699 | } | 724 | } |
700 | 725 | ||
701 | DEBUG("Num Frames is %d width=%d, height=%d", frameCount, width, height); | 726 | DEBUG("Num Frames is %d width=%d, height=%d", frameCount, width, height); |
@@ -1464,6 +1489,8 @@ out: | |||
1464 | 1489 | ||
1465 | output_free(); | 1490 | output_free(); |
1466 | 1491 | ||
1492 | fclose(frameFile); | ||
1493 | |||
1467 | printf("DCE test completed...\n"); | 1494 | printf("DCE test completed...\n"); |
1468 | 1495 | ||
1469 | return (0); | 1496 | return (0); |