Skip to content

Commit 797f8c7

Browse files
authored
[Infra] Resolve Crashlytics C warnings (#15059)
1 parent 053e6fc commit 797f8c7

File tree

3 files changed

+24
-4
lines changed

3 files changed

+24
-4
lines changed

Crashlytics/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Unreleased
2+
- [fixed] Resolved compiler warnings related to constant definitions. (#15059)
3+
14
# 11.13.0
25
- [fixed] Improved startup time by putting some initialization steps on a background. (#13675, #13232)
36

Crashlytics/Crashlytics/Helpers/FIRCLSFile.m

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,21 @@
2828

2929
#include <unistd.h>
3030

31-
// uint64_t should only have max 19 chars in base 10, and less in base 16
32-
static const size_t FIRCLSUInt64StringBufferLength = 21;
33-
static const size_t FIRCLSStringBufferLength = 16;
3431
const size_t FIRCLSWriteBufferLength = 1000;
3532

33+
/// Use an enum to define true compile-time integer constants. This prevents
34+
/// compiler warnings when these constants are used to declare array sizes.
35+
enum {
36+
/// The buffer size needed to hold a 64-bit unsigned integer as a string.
37+
/// The largest uint64_t value (18,446,744,073,709,551,615) has 20 digits.
38+
/// An additional byte is required for the null terminator.
39+
FIRCLSUInt64StringBufferLength = 21,
40+
41+
/// The size in bytes of a raw 128-bit UUID. This is used for buffers
42+
/// holding the binary data, not a C-style string.
43+
FIRCLSStringBufferLength = 16
44+
};
45+
3646
static bool FIRCLSFileInit(
3747
FIRCLSFile* file, const char* path, int fdm, bool appendMode, bool bufferWrites);
3848

Crashlytics/Shared/FIRCLSUUID.m

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,14 @@
1616

1717
#import "Crashlytics/Shared/FIRCLSByteUtility.h"
1818

19-
static NSInteger const FIRCLSUUIDStringLength = 33;
19+
/// Use an enum to define a true compile-time integer constant. This prevents
20+
/// warning below where the constant is used to declare the size of an array.
21+
enum {
22+
/// The buffer size needed to hold the hexadecimal string representation of a
23+
/// 16-byte UUID. This accounts for 32 characters (2 for each byte) plus one
24+
/// byte for the null terminator.
25+
FIRCLSUUIDStringLength = (16 * 2) + 1
26+
};
2027

2128
#pragma mark Public methods
2229

0 commit comments

Comments
 (0)