forked from microsoft/onnxruntime
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix Objective-C static analysis warnings. (microsoft#20417)
Replace most usages of [NSString stringWithUTF8String:] with checked helper function. The issue is that the former can return nil.
- Loading branch information
Showing
7 changed files
with
44 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
#pragma once | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
namespace onnxruntime::coreml::util { | ||
|
||
// Converts a UTF8 const char* to an NSString. Throws on failure. | ||
// Prefer this to directly calling [NSString stringWithUTF8String:] as that may return nil. | ||
NSString* _Nonnull Utf8StringToNSString(const char* _Nonnull utf8_str); | ||
|
||
} // namespace onnxruntime::coreml::util |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
#include "core/providers/coreml/model/objc_str_utils.h" | ||
|
||
#include "core/common/common.h" | ||
|
||
namespace onnxruntime::coreml::util { | ||
|
||
NSString* _Nonnull Utf8StringToNSString(const char* _Nonnull utf8_str) { | ||
NSString* result = [NSString stringWithUTF8String:utf8_str]; | ||
ORT_ENFORCE(result != nil, "NSString conversion failed."); | ||
return result; | ||
} | ||
|
||
} // namespace onnxruntime::coreml::util |