diff --git a/Crashlytics/CHANGELOG.md b/Crashlytics/CHANGELOG.md index e437c95b7d7..bf9e5532d29 100644 --- a/Crashlytics/CHANGELOG.md +++ b/Crashlytics/CHANGELOG.md @@ -1,3 +1,6 @@ +# Unreleased +- [fixed] Resolved compiler warnings related to constant definitions. (#15059) + # 11.13.0 - [fixed] Improved startup time by putting some initialization steps on a background. (#13675, #13232) diff --git a/Crashlytics/Crashlytics/Helpers/FIRCLSFile.m b/Crashlytics/Crashlytics/Helpers/FIRCLSFile.m index 6a2b7fa3a19..48dc787ebd1 100644 --- a/Crashlytics/Crashlytics/Helpers/FIRCLSFile.m +++ b/Crashlytics/Crashlytics/Helpers/FIRCLSFile.m @@ -28,11 +28,21 @@ #include -// uint64_t should only have max 19 chars in base 10, and less in base 16 -static const size_t FIRCLSUInt64StringBufferLength = 21; -static const size_t FIRCLSStringBufferLength = 16; const size_t FIRCLSWriteBufferLength = 1000; +/// Use an enum to define true compile-time integer constants. This prevents +/// compiler warnings when these constants are used to declare array sizes. +enum { + /// The buffer size needed to hold a 64-bit unsigned integer as a string. + /// The largest uint64_t value (18,446,744,073,709,551,615) has 20 digits. + /// An additional byte is required for the null terminator. + FIRCLSUInt64StringBufferLength = 21, + + /// The size in bytes of a raw 128-bit UUID. This is used for buffers + /// holding the binary data, not a C-style string. + FIRCLSStringBufferLength = 16 +}; + static bool FIRCLSFileInit( FIRCLSFile* file, const char* path, int fdm, bool appendMode, bool bufferWrites); diff --git a/Crashlytics/Shared/FIRCLSUUID.m b/Crashlytics/Shared/FIRCLSUUID.m index 47ce7718aac..b3bc4f1d236 100644 --- a/Crashlytics/Shared/FIRCLSUUID.m +++ b/Crashlytics/Shared/FIRCLSUUID.m @@ -16,7 +16,14 @@ #import "Crashlytics/Shared/FIRCLSByteUtility.h" -static NSInteger const FIRCLSUUIDStringLength = 33; +/// Use an enum to define a true compile-time integer constant. This prevents +/// warning below where the constant is used to declare the size of an array. +enum { + /// The buffer size needed to hold the hexadecimal string representation of a + /// 16-byte UUID. This accounts for 32 characters (2 for each byte) plus one + /// byte for the null terminator. + FIRCLSUUIDStringLength = (16 * 2) + 1 +}; #pragma mark Public methods