Skip to content

Commit

Permalink
fix: use correct format specifier for NSInteger (#3164)
Browse files Browse the repository at this point in the history
  • Loading branch information
armcknight authored Jul 29, 2023
1 parent a176fc4 commit 8919322
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Sources/Sentry/SentryFileManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ - (NSNumber *_Nullable)readTimezoneOffset

- (void)storeTimezoneOffset:(NSInteger)offset
{
NSString *timezoneOffsetString = [NSString stringWithFormat:@"%zd", offset];
NSString *timezoneOffsetString = [NSString stringWithFormat:@"%ld", (long)offset];
SENTRY_LOG_DEBUG(@"Persisting timezone offset: %@", timezoneOffsetString);
@synchronized(self.timezoneOffsetFilePath) {
if (![self writeData:[timezoneOffsetString dataUsingEncoding:NSUTF8StringEncoding]
Expand Down
5 changes: 5 additions & 0 deletions Tests/SentryTests/Helper/SentryFileManagerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,11 @@ class SentryFileManagerTests: XCTestCase {
XCTAssertEqual(sut.readTimezoneOffset(), 7_200)
}

func testtestStoreAndReadNegativeTimezoneOffset() {
sut.storeTimezoneOffset(-1_000)
XCTAssertEqual(sut.readTimezoneOffset(), -1_000)
}

func testStoreDeleteTimezoneOffset() {
sut.storeTimezoneOffset(7_200)
sut.deleteTimezoneOffset()
Expand Down

0 comments on commit 8919322

Please sign in to comment.