[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [gpsd-dev] C99 Aftermath
From: |
Gary E. Miller |
Subject: |
Re: [gpsd-dev] C99 Aftermath |
Date: |
Mon, 5 Sep 2016 17:07:29 -0700 |
Yo Fred!
On Mon, 5 Sep 2016 16:47:45 -0700 (PDT)
Fred Wright <address@hidden> wrote:
> The aborted attempt to make the code fully C99-compliant left it
> completely broken for both FreeBSD and OpenBSD.
Yes, top of my list to fix this week. I have a plan, but happy
to see others step up first. Not going to look at it until late
Tuesday.
> Thus, I took the approach of keeping #1 and getting rid of #2 and
> #3. In the process, I redid a couple of the fixes differently:
>
> A) I created a single gps_usleep() function which is a drop-in
> replacement for usleep(). This results in code which is smaller and
> more maintainable. It's also less error-prone, since one only has to
> get the arithmetic right once. :-)
Sounds good.
> B) I got rid of the single use of the generally discouraged alloca()
> by noting that the maximum buffer size needed was both modest and
> determinable at compile time, so a fixed-length array can be used
> (though a bit of tweaking was needed).
I like alloca(), but being non-POSIX, might as well go.
> To do this I started with a revert of all the "C99 group" commits
> except the ones being retained verbatim, and thoroughly tested the
> result (built and passed regression on 14 targets). I then applied
> partial versions of the two commits that mixed categories 1 and 3,
> and then made the A and B fixes described above.
What I would like is the C99 stuff be guarded by #ifdef __linux__.
Then at least the Linux code can be clean.
> After all this, I tested three states of the code against 14 targets:
> the pre-c99 state (ed7780b), the current (as of yesterday) master
> state (5808aa4), and my "c99-rollback" state. This showed that the
> current master state eliminates one warning on OSX 10.11 while
> creating new ones on both CentOS 7 and NetBSD 6, and also completely
> breaks FreeBSD 10.1 and OpenBSD 5.6. Meanwhile, the "c99-rollback"
> state gets rid of the same one warning without creating any new ones
> or breaking any builds, while retaining some useful deprecation
> cleanups.
As noted above, I'd like the C99 enforced for Linux. That will
keep a lot of junk from creeping back in. Can you do the #ifdef wrap
and resubmit?
> The changes may be a bit large for email, particularly on-list:
> Let me know if I should post this to the list or send it privately.
On list is best, the more eyes the better.
RGDS
GARY
---------------------------------------------------------------------------
Gary E. Miller Rellim 109 NW Wilmington Ave., Suite E, Bend, OR 97703
address@hidden Tel:+1 541 382 8588
pgp8XT4bYsqxv.pgp
Description: OpenPGP digital signature