public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Wanlong Gao <gaowanlong@cn.fujitsu.com>
To: Caspar Zhang <caspar@casparzhang.com>
Cc: LTP List <ltp-list@lists.sourceforge.net>
Subject: Re: [LTP] [PATCH v2] safe_macros: add SAFE_STRTOL
Date: Thu, 09 Feb 2012 18:00:05 +0800	[thread overview]
Message-ID: <4F339925.3090801@cn.fujitsu.com> (raw)
In-Reply-To: <1328780807-14132-1-git-send-email-caspar@casparzhang.com>

On 02/09/2012 05:46 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;


Ah, long rval?

> +	char *endptr;
> +
> +	rval = strtol(str, &endptr, 10);
> +	if ((errno == ERANGE && (rval == LONG_MAX || rval == LONG_MIN))
> +		    || (errno != 0 && rval == 0))
> +		tst_brkm(TBROK|TERRNO, cleanup_fn, "strtol failed at %s:%d",
> +			 file, lineno);
> +	if (rval >= max || rval <= min)


I'm not sure with this check. ;)

Thanks
-Wanlong Gao

> +		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

  reply	other threads:[~2012-02-09 10:01 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
2012-02-09  9:46 ` [LTP] [PATCH v2] " Caspar Zhang
2012-02-09 10:00   ` Wanlong Gao [this message]
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=4F339925.3090801@cn.fujitsu.com \
    --to=gaowanlong@cn.fujitsu.com \
    --cc=caspar@casparzhang.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