[Git][NTPsec/ntpsec][master] 3 commits: Remove unneeded noconst.
Eric S. Raymond
gitlab at mg.gitlab.com
Sun Dec 11 23:24:45 UTC 2016
Eric S. Raymond pushed to branch master at NTPsec / ntpsec
Commits:
7bcb59b8 by Eric S. Raymond at 2016-12-11T16:32:53-05:00
Remove unneeded noconst.
- - - - -
e838f045 by Eric S. Raymond at 2016-12-11T18:12:20-05:00
Remove unused macros. A step towards union elimination.
- - - - -
dfab6e5b by Eric S. Raymond at 2016-12-11T18:23:25-05:00
Simplify the vint4 structure; another step towards union elimination.
- - - - -
3 changed files:
- include/ntp_types.h
- ntpd/ntp_leapsec.c
- tests/libntp/vi64ops.c
Changes:
=====================================
include/ntp_types.h
=====================================
--- a/include/ntp_types.h
+++ b/include/ntp_types.h
@@ -51,16 +51,10 @@
typedef union {
# ifdef WORDS_BIGENDIAN
struct {
- int32_t hi; uint32_t lo;
- } d_s;
- struct {
uint32_t hi; uint32_t lo;
} D_s;
# else
struct {
- uint32_t lo; int32_t hi;
- } d_s;
- struct {
uint32_t lo; uint32_t hi;
} D_s;
# endif
@@ -70,10 +64,8 @@ typedef union {
} vint64; /* variant int 64 */
/* hide the structure of a vint64 */
-#define vint64lo(n) (n).d_s.lo
-#define setvint64lo(n,v) (n).d_s.lo = (v)
-#define vint64his(n) (n).d_s.hi
-#define setvint64his(n,v) (n).d_s.hi = (v)
+#define vint64lo(n) (n).D_s.lo
+#define setvint64lo(n,v) (n).D_s.lo = (v)
#define vint64hiu(n) (n).D_s.hi
#define setvint64hiu(n,v) (n).D_s.hi = (v)
#define vint64s(n) (n).q_s
=====================================
ntpd/ntp_leapsec.c
=====================================
--- a/ntpd/ntp_leapsec.c
+++ b/ntpd/ntp_leapsec.c
@@ -34,25 +34,6 @@
static const char * const logPrefix = "leapsecond file";
/* ---------------------------------------------------------------------
- * GCC is rather sticky with its 'const' attribute. We have to do it more
- * explicit than with a cast if we want to get rid of a CONST qualifier.
- * Greetings from the PASCAL world, where casting was only possible via
- * untagged unions...
- */
-static inline void*
-noconst(
- const void* ptr
- )
-{
- union {
- const void * cp;
- void * vp;
- } tmp;
- tmp.cp = ptr;
- return tmp.vp;
-}
-
-/* ---------------------------------------------------------------------
* Our internal data structure
*/
#define MAX_HIST 10 /* history of leap seconds */
@@ -93,7 +74,7 @@ static bool _electric;
/* Forward decls of local helpers */
static bool add_range(leap_table_t*, const leap_info_t*);
static char * get_line(leapsec_reader, void*, char*, size_t);
-static char * skipws(const char*);
+static char * skipws(char*);
static bool parsefail(const char * cp, const char * ep);
static void reload_limits(leap_table_t*, const vint64*);
static bool betweenu32(uint32_t, uint32_t, uint32_t);
@@ -707,11 +688,11 @@ get_line(
/* [internal] skips whitespace characters from a character buffer. */
static char *
skipws(
- const char *ptr)
+ char *ptr)
{
while (isspace((uint8_t)*ptr))
ptr++;
- return (char*)noconst(ptr);
+ return ptr;
}
/* [internal] check if a strtoXYZ ended at EOL or whistespace and
=====================================
tests/libntp/vi64ops.c
=====================================
--- a/tests/libntp/vi64ops.c
+++ b/tests/libntp/vi64ops.c
@@ -29,22 +29,6 @@ TEST(vi64ops, HiLoVUI64ul) {
TEST_ASSERT_EQUAL(vint64lo(exp), 0x89ABCDEF);
}
-TEST(vi64ops, HiLoVUI64sh) {
- vint64 exp;
-
- setvint64his(exp, 0x01234567);
- setvint64lo(exp, 0x89ABCDEF);
- TEST_ASSERT_EQUAL(vint64his(exp), 0x01234567);
-}
-
-TEST(vi64ops, HiLoVUI64sl) {
- vint64 exp;
-
- setvint64his(exp, 0x01234567);
- setvint64lo(exp, 0x89ABCDEF);
- TEST_ASSERT_EQUAL(vint64lo(exp), 0x89ABCDEF);
-}
-
TEST(vi64ops, SetVUI64s_pos) {
vint64 exp;
@@ -76,8 +60,6 @@ TEST(vi64ops, NegVUI64) {
TEST_GROUP_RUNNER(vi64ops) {
RUN_TEST_CASE(vi64ops, HiLoVUI64uh);
RUN_TEST_CASE(vi64ops, HiLoVUI64ul);
- RUN_TEST_CASE(vi64ops, HiLoVUI64sh);
- RUN_TEST_CASE(vi64ops, HiLoVUI64sl);
RUN_TEST_CASE(vi64ops, SetVUI64s_pos);
RUN_TEST_CASE(vi64ops, SetVUI64s_neg);
RUN_TEST_CASE(vi64ops, SetVUI64u);
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/6f07d603b05d2ee5d480118e6c3461e6476034b6...dfab6e5b37ad5cdfca334995bb8b350b4dc93590
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ntpsec.org/pipermail/vc/attachments/20161211/7f259b9e/attachment.html>
More information about the vc
mailing list