Skip to content

Commit

Permalink
fix Coverity warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
i-rinat committed Jan 21, 2014
1 parent d215695 commit 0c9c24a
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 26 deletions.
12 changes: 10 additions & 2 deletions glsl/shader-bundle-tool.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
Expand All @@ -6,6 +7,7 @@
#include <unistd.h>
#include <libgen.h>


int
main(int argc, char *argv[])
{
Expand Down Expand Up @@ -73,13 +75,19 @@ main(int argc, char *argv[])
}

struct stat sb;
fstat(fileno(fp_tmp), &sb);
if (fstat(fileno(fp_tmp), &sb) != 0) {
printf("can't fstat, errno = %d\n", errno);
return 4;
}
char *buf = malloc(sb.st_size);
if (!buf) {
printf("not enough memory\n");
return 3;
}
fread(buf, sb.st_size, 1, fp_tmp);
if (fread(buf, sb.st_size, 1, fp_tmp) != 1) {
printf("can't read data from file\n");
return 5;
}
fclose(fp_tmp);

fprintf(fp_c, " {\n");
Expand Down
3 changes: 0 additions & 3 deletions src/api-device.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,6 @@ compile_shaders(VdpDeviceData *deviceData)
case glsl_red_to_alpha_swizzle:
deviceData->shaders[k].uniform.tex_0 = glGetUniformLocation(program, "tex_0");
break;
default:
/* nothing */
break;
}
}

Expand Down
5 changes: 4 additions & 1 deletion src/api-presentation-queue.c
Original file line number Diff line number Diff line change
Expand Up @@ -474,14 +474,17 @@ vdpPresentationQueueDisplay(VdpPresentationQueue presentation_queue, VdpOutputSu
return VDP_STATUS_INVALID_HANDLE;

// push work to queue
while (pqData->queue.used >= PRESENTATION_QUEUE_LENGTH) {
while (pqData && pqData->queue.used >= PRESENTATION_QUEUE_LENGTH) {
// wait while queue is full
// TODO: check for deadlock here
handle_release(presentation_queue);
usleep(10*1000);
pqData = handle_acquire(presentation_queue, HANDLETYPE_PRESENTATION_QUEUE);
}

if (NULL == pqData)
return VDP_STATUS_INVALID_HANDLE;

VdpOutputSurfaceData *surfData = handle_acquire(surface, HANDLETYPE_OUTPUT_SURFACE);
if (NULL == surfData) {
handle_release(presentation_queue);
Expand Down
22 changes: 5 additions & 17 deletions src/api-video-surface.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,9 @@ vdpVideoSurfaceGetBitsYCbCr(VdpVideoSurface surface, VdpYCbCrFormat destination_
if (destination_pitches[0] == q.pitches[0] &&
destination_pitches[1] == q.pitches[1])
{
memcpy(destination_data[0], img_data + q.offsets[0], q.width * q.height);
memcpy(destination_data[1], img_data + q.offsets[1], q.width * q.height / 2);
const uint32_t sz = (uint32_t)q.width * (uint32_t)q.height;
memcpy(destination_data[0], img_data + q.offsets[0], sz);
memcpy(destination_data[1], img_data + q.offsets[1], sz / 2);
} else {
uint8_t *src = img_data + q.offsets[0];
uint8_t *dst = destination_data[0];
Expand All @@ -221,7 +222,8 @@ vdpVideoSurfaceGetBitsYCbCr(VdpVideoSurface surface, VdpYCbCrFormat destination_

// Y plane
if (destination_pitches[0] == q.pitches[0]) {
memcpy(destination_data[0], img_data + q.offsets[0], q.width * q.height);
const uint32_t sz = (uint32_t)q.width * (uint32_t)q.height;
memcpy(destination_data[0], img_data + q.offsets[0], sz);
} else {
uint8_t *src = img_data + q.offsets[0];
uint8_t *dst = destination_data[0];
Expand Down Expand Up @@ -505,13 +507,6 @@ vdpVideoSurfacePutBitsYCbCr_glsl(VdpVideoSurface surface, VdpYCbCrFormat source_
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, dstSurfData->width, dstSurfData->height, 0, GL_RED,
GL_UNSIGNED_BYTE, source_data[0]);
break;
case VDP_YCBCR_FORMAT_UYVY:
case VDP_YCBCR_FORMAT_YUYV:
case VDP_YCBCR_FORMAT_Y8U8V8A8:
case VDP_YCBCR_FORMAT_V8U8Y8A8:
default:
/* never reached */
break;
}
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);

Expand All @@ -537,13 +532,6 @@ vdpVideoSurfacePutBitsYCbCr_glsl(VdpVideoSurface surface, VdpYCbCrFormat source_
glUniform1i(deviceData->shaders[glsl_YV12_RGBA].uniform.tex_0, 0);
glUniform1i(deviceData->shaders[glsl_YV12_RGBA].uniform.tex_1, 1);
break;
case VDP_YCBCR_FORMAT_UYVY:
case VDP_YCBCR_FORMAT_YUYV:
case VDP_YCBCR_FORMAT_Y8U8V8A8:
case VDP_YCBCR_FORMAT_V8U8Y8A8:
default:
/* do nothing */
break;
}

glBegin(GL_QUADS);
Expand Down
2 changes: 1 addition & 1 deletion src/h264-parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ parse_slice_header(rbsp_state_t *st, const VAPictureParameterBufferH264 *vapp,
const int ChromaArrayType, unsigned int p_num_ref_idx_l0_active_minus1,
unsigned int p_num_ref_idx_l1_active_minus1, VASliceParameterBufferH264 *vasp)
{
struct slice_parameters sp;
struct slice_parameters sp = { 0 };

for (int k = 0; k < 32; k ++) {
reset_va_picture_h264(&sp.RefPicList0[k]);
Expand Down
5 changes: 3 additions & 2 deletions src/reverse-constant.c
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,8 @@ reverse_output_surface_render_rotate(int flags)
case VDP_OUTPUT_SURFACE_RENDER_ROTATE_0: return "VDP_OUTPUT_SURFACE_RENDER_ROTATE_0";
case VDP_OUTPUT_SURFACE_RENDER_ROTATE_90: return "VDP_OUTPUT_SURFACE_RENDER_ROTATE_90";
case VDP_OUTPUT_SURFACE_RENDER_ROTATE_180: return "VDP_OUTPUT_SURFACE_RENDER_ROTATE_180";
case VDP_OUTPUT_SURFACE_RENDER_ROTATE_270: return "VDP_OUTPUT_SURFACE_RENDER_ROTATE_270";
default: return "Unknown render rotate";
default:
// The only possible case execution get here is VDP_OUTPUT_SURFACE_RENDER_ROTATE_270 case.
return "VDP_OUTPUT_SURFACE_RENDER_ROTATE_270";
}
}

0 comments on commit 0c9c24a

Please sign in to comment.