cland static code analyzer fixes

This commit is contained in:
kavsrf 2017-02-28 10:57:41 +03:00 committed by Mounir IDRASSI
parent cf5729d4e1
commit 79aa488106
No known key found for this signature in database
GPG Key ID: DD0C382D5FCFB8FC
2 changed files with 22 additions and 18 deletions

View File

@ -82,6 +82,10 @@ typedef struct
#define DCS_DISK_ENTRY_LIST_HEADER_SIGN SIGNATURE_64 ('D','C','S','D','E','L','S','T') #define DCS_DISK_ENTRY_LIST_HEADER_SIGN SIGNATURE_64 ('D','C','S','D','E','L','S','T')
#ifndef CSTATIC_ASSERT
#define CSTATIC_ASSERT(b, name) typedef int StaticAssertFailed##name[b ? 1 : -1];
#endif
#define DE_IDX_CRYPTOHEADER 0 #define DE_IDX_CRYPTOHEADER 0
#define DE_IDX_LIST 1 #define DE_IDX_LIST 1
#define DE_IDX_DISKID 2 #define DE_IDX_DISKID 2
@ -93,7 +97,7 @@ typedef struct
#define DE_IDX_PWDCACHE 8 #define DE_IDX_PWDCACHE 8
#define DE_IDX_RND 9 #define DE_IDX_RND 9
#define DE_IDX_TOTAL 10 #define DE_IDX_TOTAL 10
static_assert(DE_IDX_TOTAL <= 15, "DE_IDX_TOTAL too big"); CSTATIC_ASSERT(DE_IDX_TOTAL <= 15, DE_IDX_TOTAL_too_big);
enum DcsDiskEntryTypes { enum DcsDiskEntryTypes {
DE_Unused = 0, DE_Unused = 0,
@ -127,7 +131,7 @@ typedef struct _DCS_DISK_ENTRY_SECTORS {
uint64 Start; // Start on disk (byte) uint64 Start; // Start on disk (byte)
uint64 Length; // length on disk (byte) uint64 Length; // length on disk (byte)
} DCS_DISK_ENTRY_SECTORS; } DCS_DISK_ENTRY_SECTORS;
static_assert(sizeof(DCS_DISK_ENTRY_SECTORS) == 32, "Wrong size DCS_DISK_ENTRY_SECTORS"); CSTATIC_ASSERT(sizeof(DCS_DISK_ENTRY_SECTORS) == 32, Wrong_size_DCS_DISK_ENTRY_SECTORS);
typedef struct _DCS_DISK_ENTRY_PARAMS { typedef struct _DCS_DISK_ENTRY_PARAMS {
uint32 Type; uint32 Type;
@ -135,7 +139,7 @@ typedef struct _DCS_DISK_ENTRY_PARAMS {
uint64 Reserved[2]; uint64 Reserved[2];
uint64 Length; // size of data uint64 Length; // size of data
} DCS_DISK_ENTRY_PARAMS; } DCS_DISK_ENTRY_PARAMS;
static_assert(sizeof(DCS_DISK_ENTRY_PARAMS) == 32, "Wrong size DCS_DISK_ENTRY_PARAMS"); CSTATIC_ASSERT(sizeof(DCS_DISK_ENTRY_PARAMS) == 32, Wrong_size_DCS_DISK_ENTRY_PARAMS);
typedef struct _DCS_DISK_ENTRY_DISKID { typedef struct _DCS_DISK_ENTRY_DISKID {
uint32 Type; uint32 Type;
@ -143,7 +147,7 @@ typedef struct _DCS_DISK_ENTRY_DISKID {
uint64 ReservedDiskId; uint64 ReservedDiskId;
DCS_GUID GptID; DCS_GUID GptID;
} DCS_DISK_ENTRY_DISKID; } DCS_DISK_ENTRY_DISKID;
static_assert(sizeof(DCS_DISK_ENTRY_DISKID) == 32, "Wrong size DCS_DISK_ENTRY_DISKID"); CSTATIC_ASSERT(sizeof(DCS_DISK_ENTRY_DISKID) == 32, Wrong_size_DCS_DISK_ENTRY_DISKID);
#pragma warning(disable:4201) #pragma warning(disable:4201)
typedef struct _DCS_DISK_ENTRY { typedef struct _DCS_DISK_ENTRY {
@ -160,19 +164,19 @@ typedef struct _DCS_DISK_ENTRY {
}; };
} DCS_DISK_ENTRY; } DCS_DISK_ENTRY;
#pragma warning(default:4201) #pragma warning(default:4201)
static_assert(sizeof(DCS_DISK_ENTRY) == 32, "Wrong size DCS_DISK_ENTRY"); CSTATIC_ASSERT(sizeof(DCS_DISK_ENTRY) == 32, Wrong_size_DCS_DISK_ENTRY);
// Static compile time checks field offsets // Static compile time checks field offsets
#ifndef FIELD_OFFSET #ifndef FIELD_OFFSET
#define FIELD_OFFSET(t, f) ((UINTN)(&((t*)0)->f)) #define FIELD_OFFSET(t, f) ((UINTN)(&((t*)0)->f))
#endif #endif
static_assert(FIELD_OFFSET(DCS_DISK_ENTRY, Type) == FIELD_OFFSET(DCS_DISK_ENTRY_SECTORS, Type), "Wrong Type offset"); CSTATIC_ASSERT(FIELD_OFFSET(DCS_DISK_ENTRY, Type) == FIELD_OFFSET(DCS_DISK_ENTRY_SECTORS, Type), Wrong_Type_offset);
static_assert(FIELD_OFFSET(DCS_DISK_ENTRY, Type) == FIELD_OFFSET(DCS_DISK_ENTRY_DISKID, Type), "Wrong Type offset"); CSTATIC_ASSERT(FIELD_OFFSET(DCS_DISK_ENTRY, Type) == FIELD_OFFSET(DCS_DISK_ENTRY_DISKID, Type), Wrong_Type_offset);
static_assert(FIELD_OFFSET(DCS_DISK_ENTRY, Type) == FIELD_OFFSET(DCS_DISK_ENTRY_PARAMS, Type), "Wrong Type offset"); CSTATIC_ASSERT(FIELD_OFFSET(DCS_DISK_ENTRY, Type) == FIELD_OFFSET(DCS_DISK_ENTRY_PARAMS, Type), Wrong_Type_offset);
static_assert(FIELD_OFFSET(DCS_DISK_ENTRY, Length) == FIELD_OFFSET(DCS_DISK_ENTRY_SECTORS, Length), "Wrong Length offset"); CSTATIC_ASSERT(FIELD_OFFSET(DCS_DISK_ENTRY, Length) == FIELD_OFFSET(DCS_DISK_ENTRY_SECTORS, Length), Wrong_Length_offset);
static_assert(FIELD_OFFSET(DCS_DISK_ENTRY, Length) == FIELD_OFFSET(DCS_DISK_ENTRY_PARAMS, Length), "Wrong Length offset"); CSTATIC_ASSERT(FIELD_OFFSET(DCS_DISK_ENTRY, Length) == FIELD_OFFSET(DCS_DISK_ENTRY_PARAMS, Length), Wrong_Length_offset);
static_assert(FIELD_OFFSET(DCS_DISK_ENTRY, Offset) == FIELD_OFFSET(DCS_DISK_ENTRY_SECTORS, Offset), "Wrong Offset offset"); CSTATIC_ASSERT(FIELD_OFFSET(DCS_DISK_ENTRY, Offset) == FIELD_OFFSET(DCS_DISK_ENTRY_SECTORS, Offset), Wrong_Offset_offset);
static_assert(FIELD_OFFSET(DCS_DISK_ENTRY, Offset) == FIELD_OFFSET(DCS_DISK_ENTRY_PARAMS, Offset), "Wrong Offset offset"); CSTATIC_ASSERT(FIELD_OFFSET(DCS_DISK_ENTRY, Offset) == FIELD_OFFSET(DCS_DISK_ENTRY_PARAMS, Offset), Wrong_Offset_offset);
// DE type specific data // DE type specific data
// DE List // DE List
@ -189,13 +193,13 @@ typedef struct _DCS_DISK_ENTRY_LIST {
// //
DCS_DISK_ENTRY DE[15]; DCS_DISK_ENTRY DE[15];
} DCS_DISK_ENTRY_LIST; } DCS_DISK_ENTRY_LIST;
static_assert(sizeof(DCS_DISK_ENTRY_LIST) == 512, "Wrong size DCS_DISK_ENTRY_LIST"); CSTATIC_ASSERT(sizeof(DCS_DISK_ENTRY_LIST) == 512, Wrong_size_DCS_DISK_ENTRY_LIST);
typedef struct _DCS_DEP_EXEC { typedef struct _DCS_DEP_EXEC {
DCS_GUID ExecPartGuid; DCS_GUID ExecPartGuid;
uint16 ExecCmd[248]; uint16 ExecCmd[248];
} DCS_DEP_EXEC; } DCS_DEP_EXEC;
static_assert(sizeof(DCS_DEP_EXEC) == 512, "Wrong size DCS_DEP_EXEC"); CSTATIC_ASSERT(sizeof(DCS_DEP_EXEC) == 512, Wrong_size_DCS_DEP_EXEC);
#define DCS_DEP_PWD_CACHE_SIGN SIGNATURE_64 ('P','W','D','C','A','C','H','E') #define DCS_DEP_PWD_CACHE_SIGN SIGNATURE_64 ('P','W','D','C','A','C','H','E')
typedef struct _DCS_DEP_PWD_CACHE { typedef struct _DCS_DEP_PWD_CACHE {
@ -206,7 +210,7 @@ typedef struct _DCS_DEP_PWD_CACHE {
int32 Pim[4]; int32 Pim[4];
byte pad[512 - 8 - 4 - 4 - (sizeof(Password) + 4) * 4]; byte pad[512 - 8 - 4 - 4 - (sizeof(Password) + 4) * 4];
} DCS_DEP_PWD_CACHE; } DCS_DEP_PWD_CACHE;
static_assert(sizeof(DCS_DEP_PWD_CACHE) == 512, "Wrong size DCS_DEP_PWD_CACHE"); CSTATIC_ASSERT(sizeof(DCS_DEP_PWD_CACHE) == 512, Wrong_size_DCS_DEP_PWD_CACHE);
#pragma pack() #pragma pack()
#endif // #if !defined(TC_WINDOWS_BOOT) #endif // #if !defined(TC_WINDOWS_BOOT)

View File

@ -11,7 +11,7 @@
// Clang pretends to be VC++, too. // Clang pretends to be VC++, too.
// See http://github.com/weidai11/cryptopp/issues/147 // See http://github.com/weidai11/cryptopp/issues/147
#if defined(_MSC_VER) && defined(__clang__) #if defined(_MSC_VER) && defined(__clang__) && !defined(_DCSPKG_ANALYZE)
# error: "Unsupported configuration" # error: "Unsupported configuration"
#endif #endif
@ -21,10 +21,10 @@
// Apple and LLVM's Clang. Apple Clang version 7.0 roughly equals LLVM Clang version 3.7 // Apple and LLVM's Clang. Apple Clang version 7.0 roughly equals LLVM Clang version 3.7
#if defined(__clang__ ) && !defined(__apple_build_version__) #if defined(__clang__ ) && !defined(__apple_build_version__) && !defined(_DCSPKG_ANALYZE)
#define CRYPTOPP_LLVM_CLANG_VERSION (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__) #define CRYPTOPP_LLVM_CLANG_VERSION (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__)
#define CRYPTOPP_CLANG_INTEGRATED_ASSEMBLER 1 #define CRYPTOPP_CLANG_INTEGRATED_ASSEMBLER 1
#elif defined(__clang__ ) && defined(__apple_build_version__) #elif defined(__clang__ ) && defined(__apple_build_version__) && !defined(_DCSPKG_ANALYZE)
#define CRYPTOPP_APPLE_CLANG_VERSION (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__) #define CRYPTOPP_APPLE_CLANG_VERSION (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__)
#define CRYPTOPP_CLANG_INTEGRATED_ASSEMBLER 1 #define CRYPTOPP_CLANG_INTEGRATED_ASSEMBLER 1
#endif #endif