From: Sami Kerola Date: Sat, 8 Oct 2016 10:11:48 +0000 (+0100) Subject: style: convert c++ comment style to c style X-Git-Tag: v0.88~21^2^2~11 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=028b3d0bec28e2fd434938fbdbd54c7ef61042e7;p=thirdparty%2Fmtr.git style: convert c++ comment style to c style // c++ style comments are not exactly forbid by standard, but /* mixing two styles is worse than sticking to a one */ Reference: http://c0x.coding-guidelines.com/6.4.9.html --- diff --git a/asn.c b/asn.c index 7d721a2..a6e9f76 100644 --- a/asn.c +++ b/asn.c @@ -46,8 +46,8 @@ #include "mtr.h" #include "asn.h" #include "utils.h" -//#define IIDEBUG +/* #define IIDEBUG */ #ifdef IIDEBUG #include #define DEB_syslog syslog @@ -65,12 +65,12 @@ static int iihash = 0; static char fmtinfo[32]; -// items width: ASN, Route, Country, Registry, Allocated -static const int iiwidth[] = { 7, 19, 4, 8, 11 }; // item len + space +/* items width: ASN, Route, Country, Registry, Allocated */ +static const int iiwidth[] = { 7, 19, 4, 8, 11 }; /* item len + space */ typedef char* items_t[ITEMSMAX + 1]; -static items_t items_a; // without hash: items -static char txtrec[NAMELEN + 1]; // without hash: txtrec +static items_t items_a; /* without hash: items */ +static char txtrec[NAMELEN + 1]; /* without hash: txtrec */ static items_t* items = &items_a; @@ -146,7 +146,7 @@ static char *ipinfo_lookup(const char *domain) { return txt; } -// originX.asn.cymru.com txtrec: ASN | Route | Country | Registry | Allocated +/* originX.asn.cymru.com txtrec: ASN | Route | Country | Registry | Allocated */ static char* split_txtrec(struct mtr_ctl *ctl, char *txt_rec) { char* prev; char* next; @@ -190,11 +190,11 @@ static char* split_txtrec(struct mtr_ctl *ctl, char *txt_rec) { } #ifdef ENABLE_IPV6 -// from dns.c:addr2ip6arpa() +/* from dns.c:addr2ip6arpa() */ static void reverse_host6(struct in6_addr *addr, char *buff) { int i; char *b = buff; - for (i=(sizeof(*addr)/2-1); i>=0; i--, b+=4) // 64b portion + for (i=(sizeof(*addr)/2-1); i>=0; i--, b+=4) /* 64b portion */ sprintf(b, "%x.%x.", addr->s6_addr[i] & 0xf, addr->s6_addr[i] >> 4); buff[strlen(buff) - 1] = '\0'; } diff --git a/curses.c b/curses.c index 20fb497..5a0c8bc 100644 --- a/curses.c +++ b/curses.c @@ -350,10 +350,10 @@ static void format_field (char *dst, const char *format, int n) *dst++ = ' '; format_number (n, 5, dst); } else if (strchr( format, 'f' ) ) { - // this is for fields where we measure integer microseconds but - // display floating point miliseconds. Convert to float here. + /* this is for fields where we measure integer microseconds but + display floating point miliseconds. Convert to float here. */ sprintf(dst, format, n / 1000.0 ); - // this was marked as a temporary hack over 10 years ago. -- REW + /* this was marked as a temporary hack over 10 years ago. -- REW */ } else { sprintf(dst, format, n); } @@ -514,7 +514,7 @@ static void mtr_curses_init(void) { static int block_col[NUM_FACTORS+1] = -{ // 1:black 2:red 3:green 4:brown/yellow 5:blue 6:magenta 7:cyan 8:white +{ /* 1:black 2:red 3:green 4:brown/yellow 5:blue 6:magenta 7:cyan 8:white */ COLOR_PAIR(2)|A_BOLD, A_NORMAL, COLOR_PAIR(3), diff --git a/dns.c b/dns.c index 81d7a23..750aeeb 100644 --- a/dns.c +++ b/dns.c @@ -146,13 +146,13 @@ extern void dns_open(struct mtr_ctl *ctl) int i; FILE *infp; - // Automatically reap children. + /* Automatically reap children. */ if (signal(SIGCHLD, SIG_IGN) == SIG_ERR) { error(EXIT_FAILURE, errno, "signal"); } - // Close all unneccessary FDs. - // for debugging and error reporting, keep std-in/out/err. + /* Close all unneccessary FDs. + for debugging and error reporting, keep std-in/out/err. */ for (i=3;iaf); set_sockaddr_ip (ctl, &sa, &host); @@ -193,8 +193,8 @@ extern void dns_open(struct mtr_ctl *ctl) } else { int flags; - // the parent. - close (todns[0]); // close the pipe ends we don't need. + /* the parent. */ + close (todns[0]); /* close the pipe ends we don't need. */ close (fromdns[1]); fromdnsfp = fdopen (fromdns[0],"r"); flags = fcntl(fromdns[0], F_GETFL, 0); @@ -252,7 +252,7 @@ extern char *dns_lookup2(struct mtr_ctl *ctl, ip_t * ip) r = findip (ctl, ip); if (r) { - // we've got a result. + /* we've got a result. */ if (r->name) return r->name; else @@ -282,7 +282,7 @@ extern char *dns_lookup(struct mtr_ctl *ctl, ip_t * ip) return t; } -// XXX check if necessary/exported. +/* XXX check if necessary/exported. */ /* Resolve an IP address to a hostname. */ extern struct hostent *addr2host( const char *addr, int family ) { diff --git a/gtk.c b/gtk.c index 5ddd28a..2542285 100644 --- a/gtk.c +++ b/gtk.c @@ -311,12 +311,11 @@ enum { N_COLS }; -// Trick to cast a pointer to integer..... -// We are mis-using a pointer as a single integer. On 64-bit -// architectures, the pointer is 64 bits and the integer only 32. -// The compiler warns us of loss of precision. However we know we -// casted a normal 32-bit integer into this pointer a few microseconds -// earlier, so it is ok. Nothing to worry about.... +/* Trick to cast a pointer to integer. We are mis-using a pointer as a + single integer. On 64-bit architectures, the pointer is 64 bits and the + integer only 32. The compiler warns us of loss of precision. However we + know we casted a normal 32-bit integer into this pointer a few + microseconds earlier, so it is ok. Nothing to worry about. */ #define POINTER_TO_INT(p) ((int)(long)(p)) static void float_formatter(GtkTreeViewColumn *tree_column ATTRIBUTE_UNUSED, @@ -733,7 +732,7 @@ static gboolean ReportTreeView_clicked(GtkWidget *Tree ATTRIBUTE_UNUSED, gtk_tree_view_set_cursor(GTK_TREE_VIEW(ReportTreeView), path, NULL, FALSE); - // Single right click: prepare and show the popup menu + /* Single right click: prepare and show the popup menu */ popup_menu = gtk_menu_new (); copy_item = gtk_menu_item_new_with_label ("Copy to clipboard"); diff --git a/mtr.c b/mtr.c index d47a61e..2828e34 100644 --- a/mtr.c +++ b/mtr.c @@ -695,7 +695,7 @@ extern int main(int argc, char **argv) error(EXIT_FAILURE, 0, "Couldn't determine raw socket type"); } - if (!names) append_to_names ("localhost"); // default: localhost. + if (!names) append_to_names ("localhost"); /* default: localhost. */ head = names; while (names != NULL) { diff --git a/net.c b/net.c index 47ef342..c63424d 100644 --- a/net.c +++ b/net.c @@ -86,9 +86,9 @@ struct TCPHeader { uint32_t seq; }; -// This ifdef is unnecessary. But it should trigger errors if I forget -// an ifdef HAS_SCTP further down. (Success! I forgot one and the compiler -// told me the line number!) +/* This ifdef is unnecessary. But it should trigger errors if I forget an + ifdef HAS_SCTP further down. (Success! I forgot one and the compiler + told me the line number!) */ #ifdef HAS_SCTP /* Structure of an SCTP header */ struct SCTPHeader { @@ -666,7 +666,7 @@ static void net_send_query(struct mtr_ctl *ctl, int index) gettimeofday(&sequence[udp->dstport].time, NULL); udp->dstport = htons(udp->dstport); } else { - // keep dstport constant, stuff sequence into the checksum + /* keep dstport constant, stuff sequence into the checksum */ udp->dstport = htons(ctl->remoteport); udp->checksum = new_sequence(ctl, index); gettimeofday(&sequence[udp->checksum].time, NULL); diff --git a/raw.c b/raw.c index 4bc723a..89cb2bb 100644 --- a/raw.c +++ b/raw.c @@ -34,14 +34,14 @@ #include "dns.h" -// Log an echo request, or a "ping" +/* Log an echo request, or a "ping" */ extern void raw_rawxmit (int host, int seq) { printf ("x %d %d\n", host, seq); fflush (stdout); } -// Log an echo reply, or a "pong" +/* Log an echo reply, or a "pong" */ extern void raw_rawping (struct mtr_ctl *ctl, int host, int msec, int seq) { static int havename[MaxHost]; diff --git a/report.c b/report.c index 2f6662f..8986131 100644 --- a/report.c +++ b/report.c @@ -84,7 +84,7 @@ extern void report_close(struct mtr_ctl *ctl) if (ctl->reportwide) { - // get the longest hostname + /* get the longest hostname */ len_hosts = strlen(ctl->LocalHostname); max = net_max(ctl); at = net_min(ctl); @@ -101,10 +101,10 @@ extern void report_close(struct mtr_ctl *ctl) if (ctl->ipinfo_no >= 0 && iiwidth_len) { ctl->ipinfo_no %= iiwidth_len; if (ctl->reportwide) { - len_hosts++; // space + len_hosts++; /* space */ len_tmp += get_iiwidth(ctl->ipinfo_no); if (!ctl->ipinfo_no) - len_tmp += 2; // align header: AS + len_tmp += 2; /* align header: AS */ } } snprintf( fmt, sizeof(fmt), "HOST: %%-%ds", len_tmp); @@ -300,7 +300,7 @@ extern void json_close(struct mtr_ctl *ctl) printf(",\n"); } - if (j <= 0) continue; // Field nr 0, " " shouldn't be printed in this method. + if (j <= 0) continue; /* Field nr 0, " " shouldn't be printed in this method. */ /* Format value */ format = data_fields[j].format; @@ -374,7 +374,7 @@ extern void xml_close(struct mtr_ctl *ctl) const char *title; j = ctl->fld_index[ctl->fld_active[i]]; - if (j <= 0) continue; // Field nr 0, " " shouldn't be printed in this method. + if (j <= 0) continue; /* Field nr 0, " " shouldn't be printed in this method. */ snprintf(name, sizeof(name), "%s%s%s", " <%s>", data_fields[j].format, "\n");