]> git.ipfire.org Git - thirdparty/mtr.git/commitdiff
style: convert c++ comment style to c style
authorSami Kerola <kerolasa@iki.fi>
Sat, 8 Oct 2016 10:11:48 +0000 (11:11 +0100)
committerSami Kerola <kerolasa@iki.fi>
Tue, 11 Oct 2016 18:29:19 +0000 (19:29 +0100)
// 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

asn.c
curses.c
dns.c
gtk.c
mtr.c
net.c
raw.c
report.c

diff --git a/asn.c b/asn.c
index 7d721a2c414498843e471231da5941006b75964c..a6e9f766fb630a9f0b3e1608abb133aad5b267c9 100644 (file)
--- 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 <syslog.h>
 #define DEB_syslog syslog
 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';
 }
index 20fb497e8a15ec6d51d19f10168a07c7127a8f30..5a0c8bc5633d78af0148325aea112a18e99944a8 100644 (file)
--- 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 81d7a2330f5c95ec0abb23a8ec23790235fcf240..750aeebbca6f30670a6f2ccb9fd03e05d0ac4a16 100644 (file)
--- 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;i<fromdns[1];i++) {
        if (i == todns[0]) continue;
        if (i == fromdns[1]) continue;
@@ -170,7 +170,7 @@ extern void dns_open(struct mtr_ctl *ctl)
       if (!fork ()) {
         int rv;
 
-        buf[strlen(buf)-1] = 0; // chomp newline.
+        buf[strlen(buf)-1] = 0; /* chomp newline. */
 
         longipstr (buf, &host, ctl->af);
         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 5ddd28a92fdb0fe657676557c2413e6be33e4ce8..2542285486b54f9c101ddf333db7f75787e71e3a 100644 (file)
--- 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 d47a61e97247782285e59f244e3e0aac5367eb32..2828e34efde358c5277644bf654beb7354f5c3c6 100644 (file)
--- 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 47ef342c351f559e3f44c191dee12acc458bc520..c63424d6a593e94ea6e527d8ebd56c1c9a1e3742 100644 (file)
--- 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 4bc723a515d948be0d170d130431780fb097f882..89cb2bb3c1c467668ba43afa2eb78dc9721bbc3b 100644 (file)
--- a/raw.c
+++ b/raw.c
 #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];
index 2f6662f2a7682b9a08a8374f86068707a741d81d..8986131da7a63fe282b2a49cee20d734ebfae936 100644 (file)
--- 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, "</%s>\n");