Hi!
> I think we need some error check mechanism here.
> 
> (@Cyril: Looks like we need a strtol wrapper in LTP lib? we have several
> examples before, like:
> 
>     val = strtol(str, &endptr, 10);
>     if (((val == LONG_MAX || val == LONG_MIN) && errno == ERANGE) ||
>             (errno != 0 && val == 0))
>         tst_brkm(TBROK|TERRNO, cleanup, "strtol");
>     if (endptr == str || *endptr != '\0')
>         tst_brkm(TBROK, cleanup, "Invalid number parameter: %s", str);
> 

Hmm, that sounds reasonable, the code to handle strtol is too
compilcated to be written again and again.

I would do something similar to the safe macros, perhaps:

SAFE_STRTOL(cleanup_fn, str, min, max)

Which would assert that string was converted correctly and is between
min and max value.

see include/safe_macros.h

-- 
Cyril Hrubis
[email protected]

------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to