Skip to content

Commit

Permalink
RDKBDEV-2827: check scanf() return values to avoid compiler warnings (#…
Browse files Browse the repository at this point in the history
…213)

Reason for change:
avoid compiler warnings
Test Procedure: Sanity.
Risks: None.

Signed-off-by: Andre McCurdy <[email protected]>
Co-authored-by: Andre McCurdy <[email protected]>
Co-authored-by: Karunakaran A <[email protected]>
  • Loading branch information
3 people authored Oct 2, 2024
1 parent f8d965e commit ba706eb
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions sampleapps/consumer/rbusOpenTelemetry.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,20 @@ int main(int argc, char *argv[])
void GetTraceContextFromUser(char *traceparent, char *tracestate)
{
char buff[256];
snprintf(traceparent, RBUS_OPEN_TELEMETRY_DATA_MAX, "traceparent:%s", buff);

memset(buff, '\0', 256);
memset(traceparent, '\0', RBUS_OPEN_TELEMETRY_DATA_MAX);
memset(tracestate, '\0', RBUS_OPEN_TELEMETRY_DATA_MAX);
printf("Enter traceparent:");
scanf("%s", buff);
snprintf(traceparent, RBUS_OPEN_TELEMETRY_DATA_MAX, "traceparent:%s", buff);
if (scanf("%s", buff) == 1)
snprintf(traceparent, RBUS_OPEN_TELEMETRY_DATA_MAX, "traceparent:%s", buff);
else
memset(traceparent, '\0', RBUS_OPEN_TELEMETRY_DATA_MAX);

memset(buff, '\0', 256);
printf("Enter tracestate:");
scanf("%s", buff);
snprintf(tracestate, RBUS_OPEN_TELEMETRY_DATA_MAX, "tracestate:%s", buff);
if (scanf("%s", buff) == 1)
snprintf(tracestate, RBUS_OPEN_TELEMETRY_DATA_MAX, "tracestate:%s", buff);
else
memset(tracestate, '\0', RBUS_OPEN_TELEMETRY_DATA_MAX);
}

void run_client()
Expand Down

0 comments on commit ba706eb

Please sign in to comment.