import: use parse_percent() where appropriate

This commit is contained in:
Lennart Poettering 2018-10-10 21:00:03 +02:00
parent b11591af27
commit 5a8582fbff
1 changed files with 4 additions and 5 deletions

View File

@ -510,7 +510,6 @@ static int manager_on_notify(sd_event_source *s, int fd, uint32_t revents, void
struct ucred *ucred = NULL;
Manager *m = userdata;
struct cmsghdr *cmsg;
unsigned percent;
char *p, *e;
Transfer *t;
Iterator i;
@ -566,15 +565,15 @@ static int manager_on_notify(sd_event_source *s, int fd, uint32_t revents, void
e = strchrnul(p, '\n');
*e = 0;
r = safe_atou(p, &percent);
if (r < 0 || percent > 100) {
r = parse_percent(p);
if (r < 0) {
log_warning("Got invalid percent value, ignoring.");
return 0;
}
t->progress_percent = percent;
t->progress_percent = (unsigned) r;
log_debug("Got percentage from client: %u%%", percent);
log_debug("Got percentage from client: %u%%", t->progress_percent);
return 0;
}