On 12 Oct 2015, at 14:00, Neels Hofmeyr
<nhofmeyr(a)sysmocom.de> wrote:
Hi!
Fix spelling dublicate -> duplicate in comments and
in (apparently only
statically used) gtp_dublicate().
Add two TODO comments.
Fix other spelling/punctuation and one numbering in comments.
Remove an opening brace from a comment to not mix up cindent in vim.
Break a long line.
I am sorry to be picky in this regard. If the subject of the change is to fix the
typo in comments, code and function names, then please limit yourself to
such a fix.
Is sed -i s,dublicate,duplicate,g enough for the first round?
---
gtp/gtp.c | 38 ++++++++++++++++++++------------------
gtp/gtp.h | 4 ++--
-int gtp_dublicate(struct gsn_t *gsn, int version,
+int gtp_duplicate(struct gsn_t *gsn, int version,
struct sockaddr_in *peer, uint16_t seq)
{
- if (!gtp_dublicate(gsn, version, peer, seq))
+ /* TODO describe what this is all about: */
+ if (!gtp_duplicate(gsn, version, peer, seq))
return 0;
pdp = &pdp_buf;
memset(pdp, 0, sizeof(struct pdp_t));
if (version == 0) {
+ /* TODO code dup: get_tid() */
uint64_t tid = be64toh(((union gtp_packet *)pack)->gtp0.h.tid);
diff --git a/gtp/gtp.h b/gtp/gtp.h
index 76c967b..7f8ec91 100644
--- a/gtp/gtp.h
+++ b/gtp/gtp.h
@@ -147,7 +147,7 @@ struct ul16_t;
struct gtp0_header { /* Descriptions from 3GPP 09.60 */
uint8_t flags; /* 01 bitfield, with typical values */
- /* 000..... Version: 1 (0) */
+ /* 000..... Version: 0 */
diff --git a/sgsnemu/sgsnemu.c b/sgsnemu/sgsnemu.c
index 5b56751..13692e0 100644
--- a/sgsnemu/sgsnemu.c
+++ b/sgsnemu/sgsnemu.c
@@ -1569,7 +1569,7 @@ int main(int argc, char **argv)
512 = Flat rate, 256 = Hot billing */
/* Create context */
- /* We send this of once. Retransmissions are handled by gtplib */
+ /* We send this off once. Retransmissions are handled by gtplib */
- /******************************************************************/
+ /******************************************************************/
/* Main select loop */
- /******************************************************************/
+ /******************************************************************/
while ((0 != state) && (5 != state)) {
@@ -1613,7 +1613,7 @@ int main(int argc, char **argv)
state = 3;
}
- /* Send off disconnect */
+ /* Send disconnect */
if (3 == state) {
state = 4;
stoptime = time(NULL) + 5; /* Extra seconds to allow disconnect */
@@ -1628,17 +1628,23 @@ int main(int argc, char **argv)
}
}
- /* Send of ping packets */
+ /* Send ping packets */
diff = 0;
while ((diff <= 0) &&
/* Send off an ICMP ping packet */
- /*if ( */ (options.pinghost.s_addr) && (2 == state) &&
+ /*if */ (options.pinghost.s_addr) && (2 == state) &&
((pingseq < options.pingcount)
|| (options.pingcount == 0))) {
+
if (!pingseq)
gettimeofday(&firstping, &tz); /* Set time of first ping */
gettimeofday(&tv, &tz);
- diff = 1000000 / options.pingrate * pingseq - 1000000 * (tv.tv_sec -
firstping.tv_sec) - (tv.tv_usec - firstping.tv_usec); /* Microseconds safe up to 500 sec
*/
+
+ /* Microseconds safe up to 500 sec */
+ diff = 1e6 / options.pingrate * pingseq
+ - 1e6 * (tv.tv_sec - firstping.tv_sec)
+ - (tv.tv_usec - firstping.tv_usec);
+
if (diff <= 0) {
if (options.debug)
printf("Create_ping %d\n", diff);
--
2.1.4