~ubuntu-branches/debian/squeeze/ntp/squeeze

« back to all changes in this revision

Viewing changes to ntpd/refclock_tpro.c

  • Committer: Bazaar Package Importer
  • Author(s): Kurt Roeckx
  • Date: 2010-05-24 11:09:51 UTC
  • mfrom: (1.2.9 upstream)
  • Revision ID: james.westby@ubuntu.com-20100524110951-1o7gh469ygochf4n
Tags: 1:4.2.6.p1+dfsg-1
* New upstream version
  - They no longer ship arlib, adjust dfsg.patch.
  - Drop kfreebsd.patch, applied upstream
  - Update patches for upstream changes.
* Remove the obsolete config files:

  for ntp:
  - /etc/logcheck/ignore.d.server/ntp, removed in 1:4.2.6+dfsg-1
  - /etc/dhcp3/dhclient-enter-hooks.d/ntp, replaced by exit hooks in
    1:4.2.4p4+dfsg-3
  - /etc/network/if-up.d/ntp, removed in 1:4.2.4p0+dfsg-1

  for ntpdate:
  - /etc/dhcp3/dhclient-enter-hooks.d/ntpdate, replaced by exit hooks in
    1:4.2.4p4+dfsg-3

  Use dpkg 1.15.7.2's dpkg-maintscript-helper.  This needs
  a Pre-Depends to work, else it's never going to be removed.
  (Closes: #569530)
* Add "Depends: ${misc:Depends}" to ntp-doc.

Show diffs side-by-side

added added

removed removed

Lines of Context:
77
77
        /*
78
78
         * Open TPRO device
79
79
         */
80
 
        (void)sprintf(device, DEVICE, unit);
 
80
        snprintf(device, sizeof(device), DEVICE, unit);
81
81
        fd = open(device, O_RDONLY | O_NDELAY, 0777);
82
82
        if (fd == -1) {
83
83
                msyslog(LOG_ERR, "tpro_start: open of %s: %m", device);
87
87
        /*
88
88
         * Allocate and initialize unit structure
89
89
         */
90
 
        if (!(up = (struct tprounit *) emalloc(sizeof(struct tprounit)))) {
91
 
                (void) close(fd);
92
 
                return (0);
93
 
        }
94
 
        memset((char *)up, 0, sizeof(struct tprounit));
 
90
        up = emalloc(sizeof(*up));
 
91
        memset(up, 0, sizeof(*up));
95
92
        pp = peer->procptr;
96
93
        pp->io.clock_recv = noentry;
97
94
        pp->io.srcclock = (caddr_t)peer;
125
122
        pp = peer->procptr;
126
123
        up = (struct tprounit *)pp->unitptr;
127
124
        io_closeclock(&pp->io);
128
 
        free(up);
 
125
        if (NULL != up)
 
126
                free(up);
129
127
}
130
128
 
131
129
 
170
168
         * we could pad the written string appropriately and read the
171
169
         * resulting value in already scaled.
172
170
         */
173
 
        sprintf(pp->a_lastcode,
174
 
            "%1x%1x%1x %1x%1x:%1x%1x:%1x%1x.%1x%1x%1x%1x%1x%1x %1x",
175
 
            tp->day100, tp->day10, tp->day1, tp->hour10, tp->hour1,
176
 
            tp->min10, tp->min1, tp->sec10, tp->sec1, tp->ms100,
177
 
            tp->ms10, tp->ms1, tp->usec100, tp->usec10, tp->usec1,
178
 
            tp->status);
179
 
            pp->lencode = strlen(pp->a_lastcode);
 
171
        snprintf(pp->a_lastcode, sizeof(pp->a_lastcode),
 
172
                 "%1x%1x%1x %1x%1x:%1x%1x:%1x%1x.%1x%1x%1x%1x%1x%1x %1x",
 
173
                 tp->day100, tp->day10, tp->day1, tp->hour10, tp->hour1,
 
174
                 tp->min10, tp->min1, tp->sec10, tp->sec1, tp->ms100,
 
175
                 tp->ms10, tp->ms1, tp->usec100, tp->usec10, tp->usec1,
 
176
                 tp->status);
 
177
        pp->lencode = strlen(pp->a_lastcode);
180
178
#ifdef DEBUG
181
179
        if (debug)
182
180
                printf("tpro: time %s timecode %d %s\n",