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

clang-format script isn't removing temporary files

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major - P3
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: Backlog
    • Component/s: None
    • Labels:

      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

              • Assignee:
                backlog-server-storage-engines Backlog - Storage Engines Team
                Reporter:
                keith.bostic Keith Bostic
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated: