Skip to content

Instantly share code, notes, and snippets.

@kevinAlbs
Created July 19, 2019 01:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kevinAlbs/3a00b5f554dee99568ca4a7739950ba9 to your computer and use it in GitHub Desktop.
Save kevinAlbs/3a00b5f554dee99568ca4a7739950ba9 to your computer and use it in GitHub Desktop.
A list of the original clang-tidy warnings for reference.
To run clang-tidy, you need a compilation "database" (which is a JSON file listing how to compile each individual file).
Generate this by setting -DCMAKE_EXPORT_COMPILE_COMMANDS=ON in the cmake command used to configure libmongocrypt. E.g.
cd cmake-build
cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON ../
Then the cmake-build directory should contain the compilation database: compile_commands.json
Then, run clang-tidy by passing a list of file names and the path to the directory containing the compilation database:
find ./src/ -name "*.c" | xargs ~/bin/clang+llvm-8.0.0-x86_64-apple-darwin/bin/clang-tidy -p ./cmake-build
Users/kevinalbertson/code/libmongocrypt/src//crypto/cng.c:20:10: error: 'bcrypt.h' file not found [clang-diagnostic-error]
#include <bcrypt.h>
^
/Users/kevinalbertson/code/libmongocrypt/src//crypto/openssl.c:28:10: error: 'openssl/crypto.h' file not found [clang-diagnostic-error]
#include <openssl/crypto.h>
^
/Users/kevinalbertson/code/libmongocrypt/src//os_win/os_mutex.c:22:4: warning: implicit declaration of function 'InitializeCriticalSection' is invalid in C99 [clang-diagnostic-implicit-function-declaration]
InitializeCriticalSection (mutex);
^
/Users/kevinalbertson/code/libmongocrypt/src//os_win/os_mutex.c:28:4: warning: implicit declaration of function 'DeleteCriticalSection' is invalid in C99 [clang-diagnostic-implicit-function-declaration]
DeleteCriticalSection (mutex);
^
/Users/kevinalbertson/code/libmongocrypt/src//os_win/os_mutex.c:34:4: warning: implicit declaration of function 'EnterCriticalSection' is invalid in C99 [clang-diagnostic-implicit-function-declaration]
EnterCriticalSection (mutex);
^
/Users/kevinalbertson/code/libmongocrypt/src//os_win/os_mutex.c:40:4: warning: implicit declaration of function 'LeaveCriticalSection' is invalid in C99 [clang-diagnostic-implicit-function-declaration]
LeaveCriticalSection (mutex);
^
/Users/kevinalbertson/code/libmongocrypt/src//os_win/os_once.c:21:8: error: unknown type name 'INIT_ONCE' [clang-diagnostic-error]
static INIT_ONCE once_control = INIT_ONCE_STATIC_INIT;
^
/Users/kevinalbertson/code/libmongocrypt/src//os_win/os_once.c:21:33: error: use of undeclared identifier 'INIT_ONCE_STATIC_INIT' [clang-diagnostic-error]
static INIT_ONCE once_control = INIT_ONCE_STATIC_INIT;
^
/Users/kevinalbertson/code/libmongocrypt/src//os_win/os_once.c:23:8: error: unknown type name 'BOOL' [clang-diagnostic-error]
static BOOL WINAPI
^
/Users/kevinalbertson/code/libmongocrypt/src//os_win/os_once.c:23:19: error: expected ';' after top level declarator [clang-diagnostic-error]
static BOOL WINAPI
^
;
/Users/kevinalbertson/code/libmongocrypt/src/mongocrypt-ciphertext.c:144:4: warning: Value stored to 'offset' is never read [clang-analyzer-deadcode.DeadStores]
offset += ciphertext->data.len;
^
/Users/kevinalbertson/code/libmongocrypt/src/mongocrypt-ciphertext.c:144:4: note: Value stored to 'offset' is never read
/Users/kevinalbertson/code/libmongocrypt/src/mongocrypt-ctx.c:41:27: warning: Access to field 'status' results in a dereference of a null pointer (loaded from variable 'ctx') [clang-analyzer-core.NullDereference]
_mongocrypt_set_error (ctx->status,
^
/Users/kevinalbertson/code/libmongocrypt/src/mongocrypt-ctx.c:481:8: note: Assuming 'ctx' is null
if (!ctx || !ctx->initialized) {
^
/Users/kevinalbertson/code/libmongocrypt/src/mongocrypt-ctx.c:481:13: note: Left side of '||' is true
if (!ctx || !ctx->initialized) {
^
/Users/kevinalbertson/code/libmongocrypt/src/mongocrypt-ctx.c:482:42: note: Passing null pointer value via 1st parameter 'ctx'
return _mongocrypt_ctx_fail_w_msg (ctx, "ctx NULL or uninitialized");
^
/Users/kevinalbertson/code/libmongocrypt/src/mongocrypt-ctx.c:482:14: note: Calling '_mongocrypt_ctx_fail_w_msg'
return _mongocrypt_ctx_fail_w_msg (ctx, "ctx NULL or uninitialized");
^
/Users/kevinalbertson/code/libmongocrypt/src/mongocrypt-ctx.c:41:27: note: Access to field 'status' results in a dereference of a null pointer (loaded from variable 'ctx')
_mongocrypt_set_error (ctx->status,
^
/Users/kevinalbertson/code/libmongocrypt/src/mongocrypt-key-broker.c:706:25: warning: Value stored to 'status' during its initialization is never read [clang-analyzer-deadcode.DeadStores]
mongocrypt_status_t *status = kb->status;
^
/Users/kevinalbertson/code/libmongocrypt/src/mongocrypt-key-broker.c:706:25: note: Value stored to 'status' during its initialization is never read
/Users/kevinalbertson/code/libmongocrypt/src/mongocrypt-key.c:470:17: warning: va_arg() is called on an uninitialized va_list [clang-analyzer-valist.Uninitialized]
arg_ptr = va_arg (args, const char *);
^
/Users/kevinalbertson/bin/clang+llvm-8.0.0-x86_64-apple-darwin/bin/../lib/clang/8.0.0/include/stdarg.h:35:29: note: expanded from macro 'va_arg'
#define va_arg(ap, type) __builtin_va_arg(ap, type)
^
/Users/kevinalbertson/code/libmongocrypt/src/mongocrypt-key.c:457:4: note: Loop condition is true. Entering loop body
while (arg_ptr) {
^
/Users/kevinalbertson/code/libmongocrypt/src/mongocrypt-key.c:464:7: note: Taking true branch
if (!prev) {
^
/Users/kevinalbertson/code/libmongocrypt/src/mongocrypt-key.c:470:17: note: va_arg() is called on an uninitialized va_list
arg_ptr = va_arg (args, const char *);
^
/Users/kevinalbertson/bin/clang+llvm-8.0.0-x86_64-apple-darwin/bin/../lib/clang/8.0.0/include/stdarg.h:35:29: note: expanded from macro 'va_arg'
#define va_arg(ap, type) __builtin_va_arg(ap, type)
^
Suppressed 50 warnings (50 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
Found compiler error(s).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment