diff --git a/asn.c b/asn.c index 4202f66..13ae0f8 100644 --- a/asn.c +++ b/asn.c @@ -256,18 +256,18 @@ extern ATTRIBUTE_CONST size_t get_iiwidth_len(void) { return (sizeof(iiwidth) / sizeof((iiwidth)[0])); } -extern int get_iiwidth(struct mtr_ctl *ctl) { +extern ATTRIBUTE_CONST int get_iiwidth(int ipinfo_no) { static const int len = (sizeof(iiwidth) / sizeof((iiwidth)[0])); - if (ctl->ipinfo_no < len) - return iiwidth[ctl->ipinfo_no]; - return iiwidth[ctl->ipinfo_no % len]; + if (ipinfo_no < len) + return iiwidth[ipinfo_no]; + return iiwidth[ipinfo_no % len]; } extern char *fmt_ipinfo(struct mtr_ctl *ctl, ip_t *addr){ char *ipinfo = get_ipinfo(ctl, addr); char fmt[8]; - snprintf(fmt, sizeof(fmt), "%s%%-%ds", ctl->ipinfo_no?"":"AS", get_iiwidth(ctl)); + snprintf(fmt, sizeof(fmt), "%s%%-%ds", ctl->ipinfo_no?"":"AS", get_iiwidth(ctl->ipinfo_no)); snprintf(fmtinfo, sizeof(fmtinfo), fmt, ipinfo?ipinfo:UNKN); return fmtinfo; } diff --git a/asn.h b/asn.h index adea489..9d02e5f 100644 --- a/asn.h +++ b/asn.h @@ -22,5 +22,5 @@ extern void asn_open(struct mtr_ctl *ctl); extern void asn_close(struct mtr_ctl *ctl); extern char *fmt_ipinfo(struct mtr_ctl *ctl, ip_t *addr); extern ATTRIBUTE_CONST size_t get_iiwidth_len(void); -extern int get_iiwidth(struct mtr_ctl *ctl); +extern ATTRIBUTE_CONST int get_iiwidth(int ipinfo_no); extern int is_printii(struct mtr_ctl *ctl); diff --git a/curses.c b/curses.c index a071f40..cec844d 100644 --- a/curses.c +++ b/curses.c @@ -687,7 +687,7 @@ extern void mtr_curses_redraw(struct mtr_ctl *ctl) int padding = 30; #ifdef HAVE_IPINFO if (is_printii(ctl)) - padding += get_iiwidth(ctl); + padding += get_iiwidth(ctl->ipinfo_no); #endif int max_cols = maxx<=SAVED_PINGS+padding ? maxx-padding : SAVED_PINGS; startstat = padding - 2; diff --git a/report.c b/report.c index 93568fb..79bd946 100644 --- a/report.c +++ b/report.c @@ -100,7 +100,7 @@ extern void report_close(struct mtr_ctl *ctl) ctl->ipinfo_no %= iiwidth_len; if (ctl->reportwide) { len_hosts++; // space - len_tmp += get_iiwidth(ctl); + len_tmp += get_iiwidth(ctl->ipinfo_no); if (!ctl->ipinfo_no) len_tmp += 2; // align header: AS }