From 959507faec3641809901ef410c6fd047173d7a13 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Fri, 6 Mar 2015 16:52:20 -0500 Subject: Simplify context initialization so we don't have to know structure shapes. --- libgpsd_core.c | 31 ++++--------------------------- 1 file changed, 4 insertions(+), 27 deletions(-) (limited to 'libgpsd_core.c') diff --git a/libgpsd_core.c b/libgpsd_core.c index a8cd72e3..7fae7006 100644 --- a/libgpsd_core.c +++ b/libgpsd_core.c @@ -280,35 +280,12 @@ int gpsd_switch_driver(struct gps_device_t *session, char *type_name) void gps_context_init(struct gps_context_t *context, /*@observer@*/const char *label) { - /* *INDENT-OFF* */ - /*@ -initallelements -nullassign -nullderef -fullinitblock @*/ - struct gps_context_t nullcontext = { - .valid = 0, - .readonly = false, - .fixcnt = 0, - .start_time = 0, - .leap_seconds = 0, - .gps_week = 0, - .gps_tow = 0, - .century = 0, - .rollovers = 0, + (void)memset(context, '\0', sizeof(struct gps_context_t)); + //context.readonly = false; #ifdef TIMEHINT_ENABLE - .leap_notify = LEAP_NOWARNING, + context->leap_notify = LEAP_NOWARNING; #endif /* TIMEHINT_ENABLE */ -#ifdef NTPSHM_ENABLE - .shmTime = {0}, -#endif /* NTPSHM_ENABLE */ -#ifdef PPS_ENABLE - .pps_hook = NULL, -#endif /* PPS_ENABLE */ -#ifdef SHM_EXPORT_ENABLE - .shmexport = NULL, -#endif /* SHM_EXPORT_ENABLE */ - .serial_write = gpsd_serial_write, - }; - /*@ +initallelements +nullassign +nullderef +fullinitblock @*/ - /* *INDENT-ON* */ - (void)memcpy(context, &nullcontext, sizeof(struct gps_context_t)); + context->serial_write = gpsd_serial_write; errout_reset(&context->errout); context->errout.label = (char *)label; -- cgit v1.2.1