public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Jan Stancek <jstancek@redhat.com>
To: Guangwen Feng <fenggw-fnst@cn.fujitsu.com>
Cc: ltp-list@lists.sourceforge.net
Subject: Re: [LTP] [PATCH] lib/safe_macros.c: fix safe_write() and safe_pwrite()
Date: Tue, 14 Jul 2015 03:34:30 -0400 (EDT)	[thread overview]
Message-ID: <893248042.16992409.1436859270663.JavaMail.zimbra@redhat.com> (raw)
In-Reply-To: <1436856423-5444-1-git-send-email-fenggw-fnst@cn.fujitsu.com>





----- Original Message -----
> From: "Guangwen Feng" <fenggw-fnst@cn.fujitsu.com>
> To: ltp-list@lists.sourceforge.net
> Sent: Tuesday, 14 July, 2015 8:47:03 AM
> Subject: [LTP] [PATCH] lib/safe_macros.c: fix safe_write() and safe_pwrite()
> 
> The len_strict is ineffective in byte length verification
> because of the improper if-condition.
> 
> Signed-off-by: Guangwen Feng <fenggw-fnst@cn.fujitsu.com>

Good catch, pushed.

Regards,
Jan

> ---
>  lib/safe_macros.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/safe_macros.c b/lib/safe_macros.c
> index a3d997c..173d72f 100644
> --- a/lib/safe_macros.c
> +++ b/lib/safe_macros.c
> @@ -414,7 +414,7 @@ ssize_t safe_write(const char *file, const int lineno,
> void (cleanup_fn) (void),
>  	ssize_t rval;
>  
>  	rval = write(fildes, buf, nbyte);
> -	if ((len_strict == 0 && rval == -1) || (size_t)rval != nbyte) {
> +	if (rval == -1 || (len_strict && (size_t)rval != nbyte)) {
>  		tst_brkm(TBROK | TERRNO, cleanup_fn,
>  			 "%s:%d: write(%d,%p,%zu) failed",
>  		         file, lineno, fildes, buf, rval);
> @@ -430,7 +430,7 @@ ssize_t safe_pwrite(const char *file, const int lineno,
>  	ssize_t rval;
>  
>  	rval = pwrite(fildes, buf, nbyte, offset);
> -	if ((len_strict == 0 && rval == -1) || (size_t)rval != nbyte) {
> +	if (rval == -1 || (len_strict && (size_t)rval != nbyte)) {
>  		tst_brkm(TBROK | TERRNO, cleanup_fn,
>  			 "%s:%d: pwrite(%d,%p,%zu,%ld) failed",
>  			 file, lineno, fildes, buf, rval, offset);
> --
> 1.8.4.2
> 
> 
> ------------------------------------------------------------------------------
> Don't Limit Your Business. Reach for the Cloud.
> GigeNET's Cloud Solutions provide you with the tools and support that
> you need to offload your IT needs and focus on growing your business.
> Configured For All Businesses. Start Your Cloud Today.
> https://www.gigenetcloud.com/
> _______________________________________________
> Ltp-list mailing list
> Ltp-list@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/ltp-list
> 

------------------------------------------------------------------------------
Don't Limit Your Business. Reach for the Cloud.
GigeNET's Cloud Solutions provide you with the tools and support that
you need to offload your IT needs and focus on growing your business.
Configured For All Businesses. Start Your Cloud Today.
https://www.gigenetcloud.com/
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

  reply	other threads:[~2015-07-14  7:34 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-14  6:47 [LTP] [PATCH] lib/safe_macros.c: fix safe_write() and safe_pwrite() Guangwen Feng
2015-07-14  7:34 ` Jan Stancek [this message]
2015-07-14 14:24 ` Cyril Hrubis
     [not found]   ` <912685955.17420609.1436885866542.JavaMail.zimbra@redhat.com>
2015-07-14 15:06     ` Cyril Hrubis

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=893248042.16992409.1436859270663.JavaMail.zimbra@redhat.com \
    --to=jstancek@redhat.com \
    --cc=fenggw-fnst@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