p4-projects@freebsd.org
[Top] [All Lists]

PERFORCE change 100498 for review

Subject: PERFORCE change 100498 for review
From: Paolo Pisati
Date: Mon, 3 Jul 2006 14:02:08 GMT
http://perforce.freebsd.org/chv.cgi?CH=100498

Change 100498 by piso@piso_newluxor on 2006/07/03 14:01:59

        Style(9):
        -Sanitize comments
        -use #if 0 ... #endif instead of C comments
        -rename 'err' to 'error'
        -use err() when possible

Affected files ...

.. //depot/projects/soc2005/libalias/sys/netinet/libalias/alias.c#3 edit

Differences ...

==== //depot/projects/soc2005/libalias/sys/netinet/libalias/alias.c#3 (text+ko) 
====

@@ -723,7 +723,7 @@
                struct in_addr original_address;
                u_short alias_port;
                int accumulate;
-               int r = 0, err;
+               int r = 0, error;
                struct alias_data ad = {
                        lnk, 
                        &original_address, 
@@ -731,7 +731,7 @@
                        &alias_port,
                        &ud->uh_sport,
                        &ud->uh_dport,
-                       0                  /* maxpacketsize */
+                       0                  /* Maxpacketsize. */
                };
 
                alias_address = GetAliasAddress(lnk);
@@ -739,9 +739,9 @@
                alias_port = ud->uh_dport;
                ud->uh_dport = GetOriginalPort(lnk);
 
-               /* walk out chain */            
-               err = find_handler(IN, UDP, la, pip, &ad);
-               if (err == EHDNOF)
+               /* Walk out chain. */           
+               error = find_handler(IN, UDP, la, pip, &ad);
+               if (error == EHDNOF)
                        ;
 
 /* If UDP checksum is not zero, then adjust since destination port */
@@ -774,7 +774,7 @@
 {
        struct udphdr *ud;
        struct alias_link *lnk;
-       int err;
+       int error;
 
 /* Return if proxy-only mode is enabled */
        if (la->packetAliasMode & PKT_ALIAS_PROXY_ONLY)
@@ -790,20 +790,20 @@
                struct in_addr alias_address;
                struct alias_data ad = {
                        lnk, 
-                       NULL,              /* original address */
+                       NULL,              /* Original address. */
                        &alias_address,
                        &alias_port,
                        &ud->uh_sport,
                        &ud->uh_dport,
-                       0                  /* maxpacketsize */
+                       0                  /* Maxpacketsize. */
                };
 
                alias_address = GetAliasAddress(lnk);
                alias_port = GetAliasPort(lnk);
 
-               /* walk out chain */            
-               err = find_handler(OUT, UDP, la, pip, &ad);
-               if (err == EHDNOF)
+               /* Walk out chain. */           
+               error = find_handler(OUT, UDP, la, pip, &ad);
+               if (error == EHDNOF)
                        ;
 
 /* If UDP checksum is not zero, adjust since source port is */
@@ -850,28 +850,27 @@
                struct in_addr proxy_address;
                u_short alias_port;
                u_short proxy_port;
-               int accumulate, err;
+               int accumulate, error;
 
                /* 
-                * XXX - the init of MANY vars is a bit below, but 
-                * aliashandlepptpin seems to need the destination port
-                * that came within the packet and not the original one
-                * looks below [*]
+                * The init of MANY vars is a bit below, but aliashandlepptpin 
+                * seems to need the destination port that came within the
+                * packet and not the original one looks below [*].
                 */
 
                struct alias_data ad = {
                        lnk, 
-                       NULL,              /* original address */
-                       NULL,              /* alias address */
-                       NULL,              /* alias port */
+                       NULL,              /* Original address. */
+                       NULL,              /* Alias address. */
+                       NULL,              /* Alias port. */
                        &tc->th_sport,
                        &tc->th_dport,
-                       0                  /* maxpacketsize */
+                       0                  /* Maxpacketsize. */
                };
 
-               /* walk out chain */            
-               err = find_handler(IN, TCP, la, pip, &ad);
-               if (err == EHDNOF)
+               /* Walk out chain. */           
+               error = find_handler(IN, TCP, la, pip, &ad);
+               if (error == EHDNOF)
                        ;
 
                alias_address = GetAliasAddress(lnk);
@@ -882,26 +881,26 @@
                proxy_port = GetProxyPort(lnk);
 
                /* 
-                * XXX - [*] looks above, if anyone is going to add
-                * find_handler AFTER this aliashandlepptpin/point, please redo
-                * alias_data too.
+                * Look above, if anyone is going to add find_handler AFTER 
+                * this aliashandlepptpin/point, please redo alias_data too.
                 * Uncommenting the piece here below should be enough.
                 */
-
-               /*               struct alias_data ad = { */
-               /*                      lnk,  */
-               /*                      &original_address,  */
-               /*                      &alias_address, */
-               /*                      &alias_port, */
-               /*                      &ud->uh_sport, */
-               /*                      &ud->uh_dport, */
-               /*                      0                  /\* maxpacketsize 
*\/ */
-               /*              }; */
+#if 0
+                                struct alias_data ad = {
+                                       lnk,
+                                       &original_address,
+                                       &alias_address,
+                                       &alias_port,
+                                       &ud->uh_sport,
+                                       &ud->uh_dport,
+                                       0                  /* Maxpacketsize. */
+                               };
                
-               /*              /\* walk out chain *\/           */
-               /*              err = find_handler(la, pip, &ad); */
-               /*              if (err == EHDNOF) */
-               /*                      printf("Protocol handler not found\n"); 
*/
+                               /* Walk out chain. */
+                               error = find_handler(la, pip, &ad);
+                               if (error == EHDNOF)
+                                       printf("Protocol handler not found\n");
+#endif
 
 /* Adjust TCP checksum since destination port is being unaliased */
 /* and destination port is being altered.                        */
@@ -957,7 +956,7 @@
 static int
 TcpAliasOut(struct libalias *la, struct ip *pip, int maxpacketsize, int create)
 {
-       int proxy_type, err;
+       int proxy_type, error;
        u_short dest_port;
        u_short proxy_server_port;
        struct in_addr dest_address;
@@ -1006,7 +1005,7 @@
                int accumulate;
                struct alias_data ad = {
                        lnk, 
-                       NULL, /* original address */
+                       NULL, /* Original address. */
                        &alias_address,
                        &alias_port,
                        &tc->th_sport,
@@ -1030,9 +1029,9 @@
 /* Monitor TCP connection state */
                TcpMonitorOut(pip, lnk);
                
-               /* walk out chain */            
-               err = find_handler(OUT, TCP, la, pip, &ad);
-               if (err == EHDNOF)
+               /* Walk out chain. */           
+               error = find_handler(OUT, TCP, la, pip, &ad);
+               if (error == EHDNOF)
                        ;
 
 /* Adjust TCP checksum since source port is being aliased */
@@ -1235,7 +1234,7 @@
                        iresult = TcpAliasIn(la, pip);
                        break;
                case IPPROTO_GRE: {
-                       int err;
+                       int error;
                        struct alias_data ad = {
                                NULL, 
                                NULL, 
@@ -1246,11 +1245,11 @@
                                0                  
                        };
                        
-                       /* walk out chain */            
-                       err = find_handler(IN, IP, la, pip, &ad);
-                       if (err == EHDNOF)
+                       /* Walk out chain. */           
+                       error = find_handler(IN, IP, la, pip, &ad);
+                       if (error == EHDNOF)
                                ;
-                       if (err ==  OK)
+                       if (error ==  OK)
                                iresult = PKT_ALIAS_OK;
                        else
                                iresult = ProtoAliasIn(la, pip);
@@ -1363,7 +1362,7 @@
                        iresult = TcpAliasOut(la, pip, maxpacketsize, create);
                        break;
                case IPPROTO_GRE: {
-                       int err;
+                       int error;
                        struct alias_data ad = {
                                NULL, 
                                NULL, 
@@ -1373,11 +1372,11 @@
                                NULL,
                                0                  
                        };
-                       /* walk out chain */            
-                       err = find_handler(OUT, IP, la, pip, &ad);
-                       if (err == EHDNOF)
+                       /* Walk out chain. */           
+                       error = find_handler(OUT, IP, la, pip, &ad);
+                       if (error == EHDNOF)
                                ;
-                       if (err == OK)
+                       if (error == OK)
                                iresult = PKT_ALIAS_OK;
                        else
                                iresult = ProtoAliasOut(la, pip, create);
@@ -1511,12 +1510,8 @@
        int len;
 
        fd = fopen(conf, "r");
-       if (fd == NULL) {
-               strcpy(buf, "cannot open config file ");
-               strcat(buf, conf);
-               perror(buf);
-               exit(-1);
-       }
+       if (fd == NULL)
+               err(1, "fopen(%s)", conf);
 
        LibAliasUnLoadAllModule();
 
@@ -1541,6 +1536,8 @@
         const char *error;
        moduledata_t *p;
 
+       // XXX - mixing my own error code and errno.h is really
+       // a bad idea, convert everything to use errno.h
         handle = dlopen (path, RTLD_LAZY);
         if (!handle) {
             fputs (dlerror(), stderr);
@@ -1579,7 +1576,7 @@
        struct dll *t;
        struct proto_handler *p;
 
-       /* unload all modules then reload everything */
+       /* Unload all modules then reload everything. */
        while ((p = first_handler()) != NULL) { 
                detach_handler(p);
        }
_______________________________________________
p4-projects@xxxxxxxxxxx mailing list
http://lists.freebsd.org/mailman/listinfo/p4-projects
To unsubscribe, send any mail to "p4-projects-unsubscribe@xxxxxxxxxxx"

<Prev in Thread] Current Thread [Next in Thread>
  • PERFORCE change 100498 for review, Paolo Pisati <=