Skip to content

Commit

Permalink
fix: convert type before divide operation
Browse files Browse the repository at this point in the history
  • Loading branch information
jean-roland committed Dec 20, 2023
1 parent a49c9f6 commit 66af3b2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions examples/unix/c11/z_sub_thr.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ void on_sample(const z_sample_t *sample, void *context) {
stats->finished_rounds++;
unsigned long elapsed_ms = z_clock_elapsed_ms(&stats->start);
printf("Received %d msg in %lu ms (%.1f msg/s)\n", PACKET_NB, elapsed_ms,

Check notice

Code scanning / Cppcheck (reported by Codacy)

MISRA 17.7 rule Note

MISRA 17.7 rule
(double)(PACKET_NB * 1000 / elapsed_ms));
(double)(PACKET_NB * 1000) / (double)elapsed_ms);

Check notice

Code scanning / Cppcheck (reported by Codacy)

MISRA 10.8 rule Note

MISRA 10.8 rule
stats->count = 0;
}

Check notice

Code scanning / Cppcheck (reported by Codacy)

MISRA 15.7 rule Note

MISRA 15.7 rule
}
Expand All @@ -63,7 +63,7 @@ void drop_stats(void *context) {
unsigned long elapsed_ms = z_clock_elapsed_ms(&stats->first_start);
const unsigned long sent_messages = PACKET_NB * stats->finished_rounds + stats->count;

Check notice

Code scanning / Cppcheck (reported by Codacy)

MISRA 12.1 rule Note

MISRA 12.1 rule

Check notice

Code scanning / Cppcheck (reported by Codacy)

MISRA 10.4 rule Note

MISRA 10.4 rule
printf("Stats after unsubscribing: received %ld messages over %lu miliseconds (%.1f msg/s)\n", sent_messages,

Check notice

Code scanning / Cppcheck (reported by Codacy)

%ld in format string (no. 1) requires 'long' but the argument type is 'unsigned long'. Note

%ld in format string (no. 1) requires 'long' but the argument type is 'unsigned long'.

Check notice

Code scanning / Cppcheck (reported by Codacy)

MISRA 17.7 rule Note

MISRA 17.7 rule
elapsed_ms, (double)(sent_messages * 1000 / elapsed_ms));
elapsed_ms, (double)(sent_messages * 1000) / (double)elapsed_ms);

Check notice

Code scanning / Cppcheck (reported by Codacy)

MISRA 10.4 rule Note

MISRA 10.4 rule
free(context);

Check notice

Code scanning / Cppcheck (reported by Codacy)

MISRA 21.3 rule Note

MISRA 21.3 rule
}

Expand Down

0 comments on commit 66af3b2

Please sign in to comment.