Uploaded image for project: 'WiredTiger'
  1. WiredTiger
  2. WT-5106

Remove temporary files in clang-format script

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Major - P3
    • Resolution: Fixed
    • None
    • 4.3.1, WT10.0.0, 4.2.2, 4.0.15
    • None
    • 1
    • Storage Engines 2019-11-04
    • v4.2, v4.0

    Description

      The clang-format script isn't removing its temporary files.

      It's also creating a new temporary file per command execution which isn't useful, and moving temporary files into place (which potentially modifies existing file permissions).

      I'd suggest something like this:

      diff --git a/dist/s_clang-format b/dist/s_clang-format
      index 58e4b59f0..ee7fc9475 100755
      --- a/dist/s_clang-format
      +++ b/dist/s_clang-format
      @@ -2,6 +2,11 @@
       
       set -o pipefail
       
      +t=__wt.$$
      +trap 'rm -rf $t' 0 1 2 3 13 15
      +
      +echo "check for $t"
      +
       download_clang_format() {
              if [ `uname` = "Linux" ]; then
                      curl https://s3.amazonaws.com/boxes.10gen.com/build/clang-format-3.8-rhel55.tar.gz -o dist/clang-format.tar.gz
      @@ -45,16 +50,15 @@ esac
       # Don't format inplace with -i flag.
       # We want to be able to detect modifications.
       for f in $search; do
      -       tempfile=$(mktemp)
              cat "$f" | \
                   clang-format --fallback-style=none | \
                   python dist/s_goto.py | \
      -            python dist/s_comment.py > "$tempfile" || exit 1
      -       cmp --silent "$f" "$tempfile"
      +            python dist/s_comment.py > "$t" || exit 1
      +       cmp --silent "$f" "$t"
              if test $? -ne 0; then
                      if test $# -eq 0 ; then
                              echo "Modifying $f"
                      fi
      -               mv "$tempfile" "$f"
      +               cp "$t" "$f"
              fi
       done
      

      Attachments

        Issue Links

          Activity

            People

              alex.cameron@mongodb.com Alex Cameron (Inactive)
              keith.bostic@mongodb.com Keith Bostic
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: