Skip to content

Commit

Permalink
fix bitrate factor should be 1 when unit is not specified
Browse files Browse the repository at this point in the history
  • Loading branch information
upa committed Apr 10, 2024
1 parent 67b51f7 commit a281dfd
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,8 @@ int main(int argc, char **argv)
int direction = 0;
char *remote = NULL, *checkpoint_save = NULL, *checkpoint_load = NULL;
bool dryrun = false, resume = false;
char *u;
size_t mag = 0;
size_t factor = 1;
char *unit;

memset(&s, 0, sizeof(s));
memset(&o, 0, sizeof(o));
Expand Down Expand Up @@ -314,23 +314,24 @@ int main(int argc, char **argv)
o.buf_sz = atoi(optarg);
break;
case 'L':
u = optarg + (strlen(optarg) - 1);
if (*u == 'k' || *u == 'K') {
mag = 1000;
*u = '\0';
} else if (*u == 'm' || *u == 'M') {
mag = 1000000;
*u = '\0';
} else if (*u == 'g' || *u == 'G') {
mag = 1000000000;
*u = '\0';
factor = 1;
unit = optarg + (strlen(optarg) - 1);
if (*unit == 'k' || *unit == 'K') {
factor = 1000;
*unit = '\0';
} else if (*unit == 'm' || *unit == 'M') {
factor = 1000000;
*unit = '\0';
} else if (*unit == 'g' || *unit == 'G') {
factor = 1000000000;
*unit = '\0';
}
o.bitrate = atol(optarg);
if (o.bitrate == 0) {
pr_err("invalid bitrate: %s", optarg);
return 1;
}
o.bitrate *= mag;
o.bitrate *= factor;
break;
case '4':
s.ai_family = AF_INET;
Expand Down

0 comments on commit a281dfd

Please sign in to comment.