Vote Up
5
Votes
Vote Down

For a change, some code. Courtesy of Marshal on Feb 22nd, 2009 at 4:45 am:

“svn blame tells us that Eric [Raymond] has not read the manpage for read() (this error goes way back to the 1.x releases of gpsd):

548 esr int gps_poll(struct gps_data_t *gpsdata)
304 esr /* wait for and read data being streamed from the daemon */
251 esr {
1747 esr char buf[BUFSIZ];
2578 esr ssize_t n;
1930 esr double received = 0;
251 esr
1342 esr /* the daemon makes sure that every read is NUL-terminated */
1949 garyemiller n = read(gpsdata->gps_fd, buf, sizeof(buf)-1);
2350 esr if (n <= 0) {
2490 esr /* error or nothing read */
1342 esr return -1;
1949 garyemiller }

Within the rest of the program, errors returned from gps_poll are frequently handled by exiting gpsd. Why on Earth would you want to quit gpsd because of a short read? These are not errors, and can be returned for numerous reasons that do not indicate any kind of problem.

gpsd appears to be a POS style-wise, too. One could write a whole wiki about things Eric doesn’t understand about writing good code.”

#1 Posted by JoeMonco on Aug 28, 2011 8:33 AM

“Why on Earth would you want to quit gpsd because of a short read?”

Interesting… So Raymond basically just lumps read() == 0 together with all other exceptions and assumes that gps_poll() returning -1 in one case is just as unrecoverable an error as another. That’s indeed some good ol’ fashioned Unix-y design right there, isn’t it?

You must be signed in to leave comments.