Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

trace: fix minor issue about printf data type and value range #743

Merged
merged 1 commit into from
Aug 29, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions va/va_trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -1240,13 +1240,13 @@ static void va_TraceSurfaceAttributes(
va_TraceMsg(trace_ctx, "\t\t width=%d\n", tmp->width);
va_TraceMsg(trace_ctx, "\t\t height=%d\n", tmp->height);
va_TraceMsg(trace_ctx, "\t\t num_objects=0x%08x\n", tmp->num_objects);
for (j = 0; j < tmp->num_objects; j++) {
for (j = 0; j < tmp->num_objects && tmp->num_objects <= 4; j++) {
va_TraceMsg(trace_ctx, "\t\t\tobjects[%d].fd=%d\n", j, tmp->objects[j].fd);
va_TraceMsg(trace_ctx, "\t\t\tobjects[%d].size=%d\n", j, tmp->objects[j].size);
va_TraceMsg(trace_ctx, "\t\t\tobjects[%d].drm_format_modifier=%d\n", j, tmp->objects[j].drm_format_modifier);
va_TraceMsg(trace_ctx, "\t\t\tobjects[%d].drm_format_modifier=%llx\n", j, tmp->objects[j].drm_format_modifier);
}
va_TraceMsg(trace_ctx, "\t\t num_layers=%d\n", tmp->num_layers);
for (j = 0; j < tmp->num_layers; j++) {
for (j = 0; j < tmp->num_layers && tmp->num_layers <= 4; j++) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. You should be doing same for num_objects, right?
  2. I think better to derive from real array size and avoid hardcoding 4 here:
tmp->num_layers <= sizeof(tmp->layers)/sizeof(tmp->layers[0])

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. You should be doing same for num_objects, right?

yes, correct, will update

  1. I think better to derive from real array size and avoid hardcoding 4 here:

"4" comes from VADRMPRIMESurfaceDescriptor , it is fix value.

va_TraceMsg(trace_ctx, "\t\t\tlayers[%d].drm_format=0x%08x\n", j, tmp->layers[j].drm_format);
va_TraceMsg(trace_ctx, "\t\t\tlayers[%d].num_planes=0x%d\n", j, tmp->layers[j].num_planes);
for (k = 0; k < 4; k++) {
Expand Down Expand Up @@ -5980,7 +5980,7 @@ void va_TraceSyncSurface2(
TRACE_FUNCNAME(idx);

va_TraceMsg(trace_ctx, "\tsurface = 0x%08x\n", surface);
va_TraceMsg(trace_ctx, "\ttimeout_ns = %d\n", timeout_ns);
va_TraceMsg(trace_ctx, "\ttimeout_ns = %lld\n", timeout_ns);
va_TraceMsg(trace_ctx, NULL);

DPY2TRACE_VIRCTX_EXIT(pva_trace);
Expand Down Expand Up @@ -6061,7 +6061,7 @@ void va_TraceSyncBuffer(
TRACE_FUNCNAME(idx);

va_TraceMsg(trace_ctx, "\tbuf_id = 0x%08x\n", buf_id);
va_TraceMsg(trace_ctx, "\ttimeout_ns = %d\n", timeout_ns);
va_TraceMsg(trace_ctx, "\ttimeout_ns = %lld\n", timeout_ns);
va_TraceMsg(trace_ctx, NULL);

DPY2TRACE_VIRCTX_EXIT(pva_trace);
Expand Down Expand Up @@ -6241,7 +6241,7 @@ void va_TraceEvent(
write_size = VA_TRACE_HEADER_SIZE;
for (i = 0; i < num; i++) {
if (write_size + desc[i].size > VA_TRACE_MAX_SIZE) {
va_errorMessage(pva_trace->dpy, "error: trace event %d carry too big data. max size \n", id, VA_TRACE_MAX_SIZE);
va_errorMessage(pva_trace->dpy, "error: trace event %d carry too big data. max size %d \n", id, VA_TRACE_MAX_SIZE);
break;
}
if (desc[i].buf) {
Expand Down