NetBSD-Bugs archive

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

Re: lib/49429: Import strtonum(3)



The following reply was made to PR lib/49429; it has been noted by GNATS.

From: John Nemeth <jnemeth%cue.bc.ca@localhost>
To: christos%zoulas.com@localhost (Christos Zoulas), "Kamil Rytarowski" <n54%gmx.com@localhost>,
        gnats-bugs%netbsd.org@localhost
Cc: netbsd-bugs%netbsd.org@localhost, "Joerg Sonnenberger" <joerg%britannica.bec.de@localhost>,
        "Steffen Nurpmeso" <sdaoden%yandex.com@localhost>, martin%duskware.de@localhost
Subject: Re: lib/49429: Import strtonum(3)
Date: Fri, 26 Dec 2014 19:15:13 -0800

 On Dec 26,  1:56pm, Christos Zoulas wrote:
 } On Dec 25,  5:52pm, n54%gmx.com@localhost ("Kamil Rytarowski") wrote:
 } 
 } | 1. Imported strtonum(3)
 } | 2. Adapted for NetBSD (libnbcompat...), man-page..
 } | 3. Dropped all occurrences of strtonum.c in our code-base
 } | 4. "Improved" strtonum(3) by changing its prototype to:
 } | intmax_t strtonum(char*,intmax_t,intmax_t,char**);
 } | 
 } | With this improvement we will remain almost fully source code compatible with OpenBSD, next inclusions of OpenBSD or FreeBSD code will be straight-forward.
 } | 
 } | 5. Exported strtonum(3) to user-space programs and making room for pkgsrc \o/
 } | 
 } | Please review and accept. Some things could be done probably cleaner like tmux.. but it's chicken-egg problem (import through pkgsrc to base...).
 } | 
 } | My changes were tested to build and produce valid sets, they are against NetBSD-current.
 } 
 } I propose instead to adopt a better interface:
 } 
 }     http://www.netbsd.org/~christos/strtoi.c
 } 
 } that does not suffer from the problems of strtonum(); for those who really
 } want strtonum(), we can supply it as a macro (or an inline to avoid gcc'isms)
 } that is hidden by default.
 
 ...
 	char *ep;
 	int rep;
 
 	if (*eptr == NULL)
 		eptr = &ep;
 
 	if (rerror == NULL)
 		rerror = &rep;
 ...
 
      With this code, you have the possibility of returning pointers
 to the stack.  You should declare ep and rep as static.  Otherwise,
 strtoi() looks good.
 
 }-- End of excerpt from Christos Zoulas
 


Home | Main Index | Thread Index | Old Index