]> git-server-git.apps.pok.os.sepia.ceph.com Git - rocksdb.git/commitdiff
Use only ASCII in source files (#10164)
authorPeter Dillinger <peterd@fb.com>
Wed, 15 Jun 2022 21:44:43 +0000 (14:44 -0700)
committerFacebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
Wed, 15 Jun 2022 21:44:43 +0000 (14:44 -0700)
Summary:
Fix existing usage of non-ASCII and add a check to prevent
future use. Added `-n` option to greps to provide line numbers.

Alternative to https://github.com/facebook/rocksdb/issues/10147

Pull Request resolved: https://github.com/facebook/rocksdb/pull/10164

Test Plan:
used new checker to find & fix cases, manually check
db_bench output is preserved

Reviewed By: akankshamahajan15

Differential Revision: D37148792

Pulled By: pdillinger

fbshipit-source-id: 68c8b57e7ab829369540d532590bf756938855c7

build_tools/check-sources.sh
tools/db_bench_tool.cc
util/ribbon_alg.h
util/xxhash.h

index 588817588c7b73ca7ce6259403f658afaa2a530e..fdd40a182279c2223416c6a863458dbe7b0cbb15 100755 (executable)
@@ -5,25 +5,25 @@
 
 BAD=""
 
-git grep 'namespace rocksdb' -- '*.[ch]*'
+git grep -n 'namespace rocksdb' -- '*.[ch]*'
 if [ "$?" != "1" ]; then
   echo "^^^^^ Do not hardcode namespace rocksdb. Use ROCKSDB_NAMESPACE"
   BAD=1
 fi
 
-git grep -i 'nocommit' -- ':!build_tools/check-sources.sh'
+git grep -n -i 'nocommit' -- ':!build_tools/check-sources.sh'
 if [ "$?" != "1" ]; then
   echo "^^^^^ Code was not intended to be committed"
   BAD=1
 fi
 
-git grep '<rocksdb/' -- ':!build_tools/check-sources.sh'
+git grep -n '<rocksdb/' -- ':!build_tools/check-sources.sh'
 if [ "$?" != "1" ]; then
   echo '^^^^^ Use double-quotes as in #include "rocksdb/something.h"'
   BAD=1
 fi
 
-git grep 'using namespace' -- ':!build_tools' ':!docs' \
+git grep -n 'using namespace' -- ':!build_tools' ':!docs' \
     ':!third-party/folly/folly/lang/Align.h' \
     ':!third-party/gtest-1.8.1/fused-src/gtest/gtest.h'
 if [ "$?" != "1" ]; then
@@ -31,6 +31,12 @@ if [ "$?" != "1" ]; then
   BAD=1
 fi
 
+git grep -n -P "[\x80-\xFF]" -- ':!docs' ':!*.md'
+if [ "$?" != "1" ]; then
+  echo '^^^^ Use only ASCII characters in source files'
+  BAD=1
+fi
+
 if [ "$BAD" ]; then
   exit 1
 fi
index 46d8a9af17607291b388b1b294cf18b9f52efc86..bd9e43b43bb96cc6ac8fd7c28095b15a9739bf44 100644 (file)
@@ -2388,13 +2388,14 @@ class CombinedStats {
 
     if (throughput_mbs_.size() == throughput_ops_.size()) {
       fprintf(stdout,
-              "%s [AVG %d runs] : %d (± %d) ops/sec; %6.1f (± %.1f) MB/sec\n",
+              "%s [AVG %d runs] : %d (\xC2\xB1 %d) ops/sec; %6.1f (\xC2\xB1 "
+              "%.1f) MB/sec\n",
               name, num_runs, static_cast<int>(CalcAvg(throughput_ops_)),
               static_cast<int>(CalcConfidence95(throughput_ops_)),
               CalcAvg(throughput_mbs_), CalcConfidence95(throughput_mbs_));
     } else {
-      fprintf(stdout, "%s [AVG %d runs] : %d (± %d) ops/sec\n", name, num_runs,
-              static_cast<int>(CalcAvg(throughput_ops_)),
+      fprintf(stdout, "%s [AVG %d runs] : %d (\xC2\xB1 %d) ops/sec\n", name,
+              num_runs, static_cast<int>(CalcAvg(throughput_ops_)),
               static_cast<int>(CalcConfidence95(throughput_ops_)));
     }
   }
@@ -2435,8 +2436,10 @@ class CombinedStats {
     int num_runs = static_cast<int>(throughput_ops_.size());
 
     if (throughput_mbs_.size() == throughput_ops_.size()) {
+      // \xC2\xB1 is +/- character in UTF-8
       fprintf(stdout,
-              "%s [AVG    %d runs] : %d (± %d) ops/sec; %6.1f (± %.1f) MB/sec\n"
+              "%s [AVG    %d runs] : %d (\xC2\xB1 %d) ops/sec; %6.1f (\xC2\xB1 "
+              "%.1f) MB/sec\n"
               "%s [MEDIAN %d runs] : %d ops/sec; %6.1f MB/sec\n",
               name, num_runs, static_cast<int>(CalcAvg(throughput_ops_)),
               static_cast<int>(CalcConfidence95(throughput_ops_)),
@@ -2445,7 +2448,7 @@ class CombinedStats {
               CalcMedian(throughput_mbs_));
     } else {
       fprintf(stdout,
-              "%s [AVG    %d runs] : %d (± %d) ops/sec\n"
+              "%s [AVG    %d runs] : %d (\xC2\xB1 %d) ops/sec\n"
               "%s [MEDIAN %d runs] : %d ops/sec\n",
               name, num_runs, static_cast<int>(CalcAvg(throughput_ops_)),
               static_cast<int>(CalcConfidence95(throughput_ops_)), name,
index a79952f55b6bf080f931d2365b0f4554642d936c..f9afefc2377b1f85d737bf5214f72aec98c421e1 100644 (file)
@@ -150,7 +150,7 @@ namespace ribbon {
 // (m/n) than is required with Gaussian elimination.
 //
 // Recommended reading:
-// "Peeling Close to the Orientability Threshold  Spatial Coupling in
+// "Peeling Close to the Orientability Threshold - Spatial Coupling in
 // Hashing-Based Data Structures" by Stefan Walzer
 //
 // ######################################################################
index 9846861b726b5b46f546f3eca0a766bc29004ac3..706b97bd9adceab58b8119558001c5eeb28a4620 100644 (file)
@@ -13,6 +13,7 @@
 #include "port/lang.h" // for FALLTHROUGH_INTENDED, inserted as appropriate
 /* END RocksDB customizations */
 
+// clang-format off
 /*
  * xxHash - Extremely Fast Hash algorithm
  * Header File
@@ -3673,7 +3674,7 @@ XXH3_initCustomSecret_avx512(void* XXH_RESTRICT customSecret, xxh_u64 seed64)
         int i;
         for (i=0; i < nbRounds; ++i) {
             /* GCC has a bug, _mm512_stream_load_si512 accepts 'void*', not 'void const*',
-             * this will warn "discards ‘const’ qualifier". */
+             * this will warn "discards 'const' qualifier". */
             union {
                 XXH_ALIGN(64) const __m512i* cp;
                 XXH_ALIGN(64) void* p;