mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-11-22 14:49:24 +01:00
test-runner: Avoid intermediate string in number conversion
Derive a floating-point interval value from integers using math rather than integer->string->float conversion. The string technique triggered a -Wformat-overflow warning.
This commit is contained in:
parent
8071b51168
commit
21fae3d1d9
@ -1380,8 +1380,6 @@ start_next_test:
|
|||||||
pid_t corpse;
|
pid_t corpse;
|
||||||
int status;
|
int status;
|
||||||
double interval;
|
double interval;
|
||||||
const int BUF_LEN = 11;
|
|
||||||
char interval_buf[BUF_LEN];
|
|
||||||
|
|
||||||
corpse = waitpid(WAIT_ANY, &status, 0);
|
corpse = waitpid(WAIT_ANY, &status, 0);
|
||||||
|
|
||||||
@ -1394,11 +1392,8 @@ start_next_test:
|
|||||||
kill_process(test_timer_pid);
|
kill_process(test_timer_pid);
|
||||||
|
|
||||||
timersub(&time_after, &time_before, &time_elapsed);
|
timersub(&time_after, &time_before, &time_elapsed);
|
||||||
sprintf(interval_buf, "%ld.%0ld",
|
interval = time_elapsed.tv_sec +
|
||||||
(long int) time_elapsed.tv_sec,
|
1e-6 * time_elapsed.tv_usec;
|
||||||
(long int) time_elapsed.tv_usec);
|
|
||||||
interval_buf[BUF_LEN - 1] = '\0';
|
|
||||||
interval = atof(interval_buf);
|
|
||||||
|
|
||||||
if (WIFEXITED(status) &&
|
if (WIFEXITED(status) &&
|
||||||
WEXITSTATUS(status) == EXIT_SUCCESS) {
|
WEXITSTATUS(status) == EXIT_SUCCESS) {
|
||||||
|
Loading…
Reference in New Issue
Block a user