public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Cyril Hrubis <chrubis@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH v3] runltp: add -R option for randomize test order
Date: Mon, 26 Sep 2016 10:25:01 +0200	[thread overview]
Message-ID: <20160926082501.GA32494@rei> (raw)
In-Reply-To: <20160925134701.GD12847@dhcp12-143.nay.redhat.com>

Hi!
> Hm, it works, even works for large file (>pagesize). I thought it maybe make
> mistake if read and rewrite same file at same time when I sent this patch.
> Now I just read the code of sort.c, it'll read the file into buffer and temp
> file at first, then close the fopen(r) file and go to fopen(w) the file:
> 
>           if (buf.eof && !nfiles && !ntemps && !buf.left)
>             {
>               xfclose (fp, file);
>               tfp = xfopen (output_file, "w");
> 	      ...
> 	      ...
> 
> So it looks safe to read and write the same file together ... But I don't know
> if it worth changing this patch (the old way looks safer:). Can maintainers
> choose a favorite way?

The POSIX specification for sort explicitly states:

-o  output
    Specify the name of an output file to be used instead of the
    standard output. This file can be the same as one of the input
    files.

So I would say that using the same filename for input and output is
pretty much safe.

-- 
Cyril Hrubis
chrubis@suse.cz

      reply	other threads:[~2016-09-26  8:25 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-24 12:35 [LTP] [PATCH v3] runltp: add -R option for randomize test order Zorro Lang
2016-09-25  9:38 ` Li Wang
2016-09-25 13:47   ` Zorro Lang
2016-09-26  8:25     ` Cyril Hrubis [this message]

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=20160926082501.GA32494@rei \
    --to=chrubis@suse.cz \
    --cc=ltp@lists.linux.it \
    /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