gpsd-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [gpsd-dev] [PATCH v1 1/1] gps2udp: atoi doesn't set errno. use strto


From: Gary E. Miller
Subject: Re: [gpsd-dev] [PATCH v1 1/1] gps2udp: atoi doesn't set errno. use strtoul to detect errors.
Date: Fri, 3 Jan 2014 14:40:03 -0800

Yo Mike!

Ths patch fixes an already fixed bug.  So no point picking at it.

On Fri, 3 Jan 2014 17:05:27 -0500
Mike Frysinger <address@hidden> wrote:

> On Friday 03 January 2014 15:10:07 Ferry Huberts wrote:
> > +bool readUL(const char * str, unsigned long * dst) {
> > +   char * endPtr = NULL;
> 
> pretty sure style says to:
>  - not cuddle the brace
>  - not put a space after the *
>  - not use camelCase
> 
> also, pretty sure there is no need to assign NULL to endPtr
> 
> > -       portnum = atoi(portname);
> > -       if (errno != 0) {
> > +       bool validPort = readUL(portname, &portnum);
> > +       validPort = validPort && portnum > 0 && portnum < 65536;
> > +       if (!validPort) {
> 
> could do:
>       bool validPort = readUL(portname, &portnum);
>       if (!validPort || portnum == 0 || portnum >= 65536) {
>               ...
> -mike




RGDS
GARY
---------------------------------------------------------------------------
Gary E. Miller Rellim 109 NW Wilmington Ave., Suite E, Bend, OR 97701
        address@hidden  Tel:+1(541)382-8588

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]