From: Caspar Zhang <caspar@casparzhang.com>
To: gaowanlong@cn.fujitsu.com
Cc: LTP List <ltp-list@lists.sourceforge.net>
Subject: Re: [LTP] [PATCH] safe_macros: add SAFE_STRTOL
Date: Thu, 09 Feb 2012 17:45:20 +0800 [thread overview]
Message-ID: <4F3395B0.9060109@casparzhang.com> (raw)
In-Reply-To: <4F339228.7000708@cn.fujitsu.com>
On 02/09/2012 05:30 PM, Wanlong Gao wrote:
> On 02/09/2012 04:13 PM, Caspar Zhang wrote:
>
>> +
>> +long safe_strtol(const char *file, const int lineno,
>> + void (cleanup_fn)(void), char *str, long min, long max)
>> +{
>> + int rval;
>> + char *endptr;
>> +
>> + rval = strtol(str, &endptr, 10);
>> + if (rval == LONG_MAX || rval == LONG_MIN)
>
>
> Shouldn't we check the errno here?
Ah yes. I'll make a v2 soon.
>
> Thanks
> -Wanlong Gao
>
>> + tst_brkm(TBROK|TERRNO, cleanup_fn, "strtol failed at %s:%d",
>> + file, lineno);
>> + if (rval >= max || rval <= min)
>> + tst_brkm(TBROK, cleanup_fn,
>> + "converted value out of range: %ld - %ld",
>> + min, max);
>> + if (endptr == str || (*endptr != '\0' && *endptr != '\n'))
>> + tst_brkm(TBROK, cleanup_fn, "Invalid value: %s", str);
>> +
>> + return rval;
>> +}
>
>
------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
next prev parent reply other threads:[~2012-02-09 9:45 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-09 8:13 [LTP] [PATCH] safe_macros: add SAFE_STRTOL Caspar Zhang
2012-02-09 9:30 ` Wanlong Gao
2012-02-09 9:45 ` Caspar Zhang [this message]
2012-02-09 9:46 ` [LTP] [PATCH v2] " Caspar Zhang
2012-02-09 10:00 ` Wanlong Gao
2012-02-09 10:28 ` Cyril Hrubis
2012-02-09 10:53 ` [LTP] [PATCH v3] " Caspar Zhang
2012-02-09 12:53 ` Cyril Hrubis
2012-02-09 13:12 ` [LTP] [PATCH v4] " Caspar Zhang
2012-02-09 13:59 ` Cyril Hrubis
2012-03-16 9:58 ` Gopal Kalita
2012-03-20 8:49 ` Caspar Zhang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4F3395B0.9060109@casparzhang.com \
--to=caspar@casparzhang.com \
--cc=gaowanlong@cn.fujitsu.com \
--cc=ltp-list@lists.sourceforge.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox