nm-online: fix division-by-zero with zero timeout

$ nm-online -t 0
  Floating point exception (core dumped)

Fixes: c5f17a97ea

https://bugzilla.gnome.org/show_bug.cgi?id=777914
This commit is contained in:
Thomas Haller 2017-01-31 00:11:10 +01:00
parent 7399cf3b16
commit 34acecf544

View file

@ -227,7 +227,7 @@ main (int argc, char *argv[])
remaining_ms = t_secs * 1000;
data.end_timestamp_ms = data.start_timestamp_ms + remaining_ms;
data.progress_step_duration = (data.end_timestamp_ms - data.start_timestamp_ms + PROGRESS_STEPS/2) / PROGRESS_STEPS;
data.progress_step_duration = NM_MAX (1, (data.end_timestamp_ms - data.start_timestamp_ms + PROGRESS_STEPS/2) / PROGRESS_STEPS);
g_timeout_add (data.quiet ? remaining_ms : 0, handle_timeout, &data);
nm_client_new_async (NULL, got_client, &data);