Skip to content

Commit

Permalink
Enable a few hicpp (pytorch#13189)
Browse files Browse the repository at this point in the history
Summary:
Enabling three checks from ["High Integrity C++"](https://www.perforce.com/blog/qac/high-integrity-cpp-hicpp)

ezyang
Pull Request resolved: pytorch#13189

Differential Revision: D12859779

Pulled By: goldsborough

fbshipit-source-id: 8ec22370dcf88618dae749a8dae0e82678e68b0e
  • Loading branch information
goldsborough authored and facebook-github-bot committed Nov 1, 2018
1 parent d843f63 commit 27002e3
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ Checks: '
,-cppcoreguidelines-special-member-functions
,-cppcoreguidelines-interfaces-global-init
,-cppcoreguidelines-owning-memory
,hicpp-signed-bitwise
,hicpp-exception-baseclass
,hicpp-avoid-goto
'
WarningsAsErrors: '*'
HeaderFilterRegex: 'torch/csrc/.*'
Expand Down
4 changes: 2 additions & 2 deletions torch/csrc/api/src/data/datasets/mnist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ bool check_is_little_endian() {
}

constexpr uint32_t flip_endianness(uint32_t value) {
return ((value & 0xff) << 24) | ((value & 0xff00) << 8) |
((value & 0xff0000) >> 8) | ((value & 0xff000000) >> 24);
return ((value & 0xffu) << 24u) | ((value & 0xff00u) << 8u) |
((value & 0xff0000u) >> 8u) | ((value & 0xff000000u) >> 24u);
}

uint32_t read_int32(std::ifstream& stream) {
Expand Down
1 change: 1 addition & 0 deletions torch/csrc/jit/fuser/cpu/dynamic_library.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ struct DynamicLibrary {
TH_DISALLOW_COPY_AND_ASSIGN(DynamicLibrary);

DynamicLibrary(const char* name) {
// NOLINTNEXTLINE(hicpp-signed-bitwise)
handle = checkDL(dlopen(name, RTLD_LOCAL | RTLD_NOW));
}

Expand Down
2 changes: 2 additions & 0 deletions torch/csrc/jit/script/lexer.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,13 @@ struct SharedParserData {
}
#ifdef _WIN32
double strtod_c(const char * str, char** end) {
/// NOLINTNEXTLINE(hicpp-signed-bitwise)
static _locale_t loc = _create_locale(LC_ALL, "C");
return _strtod_l(str, end, loc);
}
#else
double strtod_c(const char * str, char** end) {
/// NOLINTNEXTLINE(hicpp-signed-bitwise)
static locale_t loc = newlocale(LC_ALL_MASK, "C", nullptr);
return strtod_l(str, end, loc);
}
Expand Down

0 comments on commit 27002e3

Please sign in to comment.