diff options
Diffstat (limited to 'migration.c')
-rw-r--r-- | migration.c | 18 |
1 files changed, 3 insertions, 15 deletions
diff --git a/migration.c b/migration.c index 598f8df5c4..6abdc65149 100644 --- a/migration.c +++ b/migration.c @@ -109,23 +109,11 @@ void do_migrate_cancel(Monitor *mon, const QDict *qdict, QObject **ret_data) void do_migrate_set_speed(Monitor *mon, const QDict *qdict) { double d; - char *ptr; FdMigrationState *s; - const char *value = qdict_get_str(qdict, "value"); - - d = strtod(value, &ptr); - switch (*ptr) { - case 'G': case 'g': - d *= 1024; - case 'M': case 'm': - d *= 1024; - case 'K': case 'k': - d *= 1024; - default: - break; - } - max_throttle = (uint32_t)d; + d = qdict_get_double(qdict, "value"); + d = MAX(0, MIN(UINT32_MAX, d)); + max_throttle = d; s = migrate_to_fms(current_migration); if (s && s->file) { |