{ NULL }
};
-static int parse_percent_rate(char *rate, const char *str, const char *dev)
+static int parse_percent_rate(char *rate, size_t len,
+ const char *str, const char *dev)
{
long dev_mbit;
int ret;
rate_mbit = perc * dev_mbit;
- ret = snprintf(rate, 20, "%lf", rate_mbit);
- if (ret <= 0 || ret >= 20) {
+ ret = snprintf(rate, len, "%lf", rate_mbit);
+ if (ret <= 0 || ret >= len) {
fprintf(stderr, "Unable to parse calculated rate\n");
return -1;
}
{
char r_str[20];
- if (parse_percent_rate(r_str, str, dev))
+ if (parse_percent_rate(r_str, sizeof(r_str), str, dev))
return -1;
return get_rate(rate, r_str);
{
char r_str[20];
- if (parse_percent_rate(r_str, str, dev))
+ if (parse_percent_rate(r_str, sizeof(r_str), str, dev))
return -1;
return get_rate64(rate, r_str);