[Git][NTPsec/ntpsec][master] 2 commits: Remove a bad cast tripping up -Wsign-conversion

Gary E. Miller gitlab at mg.gitlab.com
Fri Mar 10 22:49:29 UTC 2017


Gary E. Miller pushed to branch master at NTPsec / ntpsec


Commits:
8d08caf4 by Gary E. Miller at 2017-03-10T14:17:29-08:00
Remove a bad cast tripping up -Wsign-conversion

Prolly needs a test routine.  Also prolly shoul return an int64_t not
just a long.

- - - - -
d5aea26a by Gary E. Miller at 2017-03-10T14:45:44-08:00
get_lsb_long(): don't cast to long and back to ulong.

So now get_lsb_long() is get_lsb_ulong().  Removes 8 bad
cast warnings.

- - - - -


3 changed files:

- include/binio.h
- libparse/binio.c
- libparse/data_mbg.c


Changes:

=====================================
include/binio.h
=====================================
--- a/include/binio.h
+++ b/include/binio.h
@@ -12,7 +12,7 @@
 
 long get_lsb_short (unsigned char **);
 void put_lsb_short (unsigned char **, long);
-long get_lsb_long (unsigned char **);
+unsigned long get_lsb_ulong (unsigned char **);
 void put_lsb_long (unsigned char **, long);
 
 #define get_lsb_int16( _x_ )   ((int16_t) get_lsb_short( _x_ ))


=====================================
libparse/binio.c
=====================================
--- a/libparse/binio.c
+++ b/libparse/binio.c
@@ -42,7 +42,7 @@ get_lsb_long(
   retval  = *((*bufpp)++);
   retval |= *((*bufpp)++) << 8;
   retval |= *((*bufpp)++) << 16;
-  retval |= (unsigned long)*((*bufpp)++) << 24;
+  retval |= *((*bufpp)++) << 24;
 
   return retval;
 }


=====================================
libparse/data_mbg.c
=====================================
--- a/libparse/data_mbg.c
+++ b/libparse/data_mbg.c
@@ -95,8 +95,8 @@ get_mbg_tgps(
 	)
 {
   tgpsp->wn = get_lsb_uint16(bufpp);
-  tgpsp->sec = get_lsb_long(bufpp);
-  tgpsp->tick = get_lsb_long(bufpp);
+  tgpsp->sec = get_lsb_ulong(bufpp);
+  tgpsp->tick = get_lsb_ulong(bufpp);
 }
 
 void
@@ -113,8 +113,8 @@ get_mbg_tm(
   tmp->hour = *(*buffpp)++;
   tmp->min = *(*buffpp)++;
   tmp->sec = *(*buffpp)++;
-  tmp->frac = get_lsb_long(buffpp);
-  tmp->offs_from_utc = get_lsb_long(buffpp);
+  tmp->frac = get_lsb_ulong(buffpp);
+  tmp->offs_from_utc = get_lsb_ulong(buffpp);
   tmp->status = get_lsb_uint16(buffpp);
 }
 
@@ -156,8 +156,8 @@ get_mbg_tzdl(
 	TZDL *tzdlp
 	)
 {
-  tzdlp->offs = get_lsb_long(buffpp);
-  tzdlp->offs_dl = get_lsb_long(buffpp);
+  tzdlp->offs = get_lsb_ulong(buffpp);
+  tzdlp->offs_dl = get_lsb_ulong(buffpp);
   get_mbg_tm(buffpp, &tzdlp->tm_on);
   get_mbg_tm(buffpp, &tzdlp->tm_off);
   get_mbg_tzname(buffpp, (char *)tzdlp->name[0]);
@@ -173,7 +173,7 @@ get_mbg_antinfo(
   antinfop->status = get_lsb_int16(buffpp);
   get_mbg_tm(buffpp, &antinfop->tm_disconn);
   get_mbg_tm(buffpp, &antinfop->tm_reconn);
-  antinfop->delta_t = get_lsb_long(buffpp);
+  antinfop->delta_t = get_lsb_ulong(buffpp);
 }
 
 static void
@@ -352,7 +352,7 @@ get_mbg_comparam(
 {
   size_t i;
 
-  comparamp->baud_rate = get_lsb_long(buffpp);
+  comparamp->baud_rate = get_lsb_ulong(buffpp);
   for (i = 0; i < sizeof(comparamp->framing); i++)
     {
       comparamp->framing[i] = *(*buffpp)++;



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/534dd4790f42a69766bf36f50b080e7e8696318c...d5aea26a685ac94781d4824ddefed43bd9f3bf0f
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20170310/952e80f6/attachment.html>


More information about the vc mailing list