[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [gpsd-dev] [PATCH v3 1/1] gps2udp: reset errno after successful geta
From: |
Mike Frysinger |
Subject: |
Re: [gpsd-dev] [PATCH v3 1/1] gps2udp: reset errno after successful getaddrinfo call |
Date: |
Fri, 3 Jan 2014 14:43:08 -0500 |
User-agent: |
KMail/1.13.7 (Linux/3.12.1; KDE/4.6.5; x86_64; ; ) |
On Friday 03 January 2014 13:43:14 Ferry Huberts wrote:
> The connect2gpsd function calls down into the netlib_connectsock
> function in netlib.c. This function succeeds but leaves behind errno ==
> 2.
this is not a bug
> The the open_udp function goes off and does stuff, like axtract a
> port number by doing atoi. according to the atoi manpage, it is the same
> as strtol(nptr, NULL, 10). strtol has in its manpage
> The implementation may also set errno to EINVAL in case no conversion
> was performed (no digits seen, and 0 returned).
> After atoi, open_udp checks errno and finds it at 2, left behind by the
> netlib_connectsock function.
if this code where to stick to using atoi directly, then the correct answer
should be to first set errno=0 before calling it. then you could safely check
the value of errno immediately after.
but the better answer would be to call strtol yourself and pass in a pointer
to the "endptr" and then use that according to the documentation to check for
an error.
> >>>> The function call may set errno even though it succeeds.
> >>>
> >>> that is not a bug
> >>
> >> exactly, which is why we must reset errno, because otherwise other
> >> functions are affected.
> >
> > no, no they are not
>
> Well, they are. Otherwise I wouldn't have had to fix stuff.
sorry, but no. the patch you posted is completely wrong. you might happen to
make some specific unrelated code start working, but it doesn't make your
change correct.
-mike
signature.asc
Description: This is a digitally signed message part.
- [gpsd-dev] [PATCH v3 1/1] gps2udp: reset errno after successful getaddrinfo call, Ferry Huberts, 2014/01/03
- Re: [gpsd-dev] [PATCH v3 1/1] gps2udp: reset errno after successful getaddrinfo call, Mike Frysinger, 2014/01/03
- Re: [gpsd-dev] [PATCH v3 1/1] gps2udp: reset errno after successful getaddrinfo call, Ferry Huberts, 2014/01/03
- Re: [gpsd-dev] [PATCH v3 1/1] gps2udp: reset errno after successful getaddrinfo call, Mike Frysinger, 2014/01/03
- Re: [gpsd-dev] [PATCH v3 1/1] gps2udp: reset errno after successful getaddrinfo call, Ferry Huberts, 2014/01/03
- Re: [gpsd-dev] [PATCH v3 1/1] gps2udp: reset errno after successful getaddrinfo call, Mike Frysinger, 2014/01/03
- Re: [gpsd-dev] [PATCH v3 1/1] gps2udp: reset errno after successful getaddrinfo call, Ferry Huberts, 2014/01/03
- Re: [gpsd-dev] [PATCH v3 1/1] gps2udp: reset errno after successful getaddrinfo call, Greg Troxel, 2014/01/03
- Re: [gpsd-dev] [PATCH v3 1/1] gps2udp: reset errno after successful getaddrinfo call, Gary E. Miller, 2014/01/03
- Re: [gpsd-dev] [PATCH v3 1/1] gps2udp: reset errno after successful getaddrinfo call, Ferry Huberts, 2014/01/03
- Re: [gpsd-dev] [PATCH v3 1/1] gps2udp: reset errno after successful getaddrinfo call,
Mike Frysinger <=
- Re: [gpsd-dev] [PATCH v3 1/1] gps2udp: reset errno after successful getaddrinfo call, Gary E. Miller, 2014/01/03
Re: [gpsd-dev] [PATCH v3 1/1] gps2udp: reset errno after successful getaddrinfo call, Gary E. Miller, 2014/01/03