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