mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-12-22 04:32:37 +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;
|
||||
int status;
|
||||
double interval;
|
||||
const int BUF_LEN = 11;
|
||||
char interval_buf[BUF_LEN];
|
||||
|
||||
corpse = waitpid(WAIT_ANY, &status, 0);
|
||||
|
||||
@ -1394,11 +1392,8 @@ start_next_test:
|
||||
kill_process(test_timer_pid);
|
||||
|
||||
timersub(&time_after, &time_before, &time_elapsed);
|
||||
sprintf(interval_buf, "%ld.%0ld",
|
||||
(long int) time_elapsed.tv_sec,
|
||||
(long int) time_elapsed.tv_usec);
|
||||
interval_buf[BUF_LEN - 1] = '\0';
|
||||
interval = atof(interval_buf);
|
||||
interval = time_elapsed.tv_sec +
|
||||
1e-6 * time_elapsed.tv_usec;
|
||||
|
||||
if (WIFEXITED(status) &&
|
||||
WEXITSTATUS(status) == EXIT_SUCCESS) {
|
||||
|
Loading…
Reference in New Issue
Block a user