Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(254)

Side by Side Diff: util/stdlib/strnlen.cc

Issue 1109273002: mac: Suppress partial availability warnings. (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad.git@master
Patch Set: Comments from mark, round two. Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « util/mach/exception_types.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Crashpad Authors. All rights reserved. 1 // Copyright 2014 The Crashpad Authors. All rights reserved.
2 // 2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); 3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License. 4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at 5 // You may obtain a copy of the License at
6 // 6 //
7 // http://www.apache.org/licenses/LICENSE-2.0 7 // http://www.apache.org/licenses/LICENSE-2.0
8 // 8 //
9 // Unless required by applicable law or agreed to in writing, software 9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, 10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and 12 // See the License for the specific language governing permissions and
13 // limitations under the License. 13 // limitations under the License.
14 14
15 #include "util/stdlib/strnlen.h" 15 #include "util/stdlib/strnlen.h"
16 16
17 #if defined(OS_MACOSX) && MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_7
18
19 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
20 // Redeclare a method only available on OSX 10.7+ to suppress a
21 // -Wpartial-availability warning.
22 extern "C" {
23 size_t strnlen(const char* string, size_t max_length);
24 } // extern "C"
25 #endif
26
17 namespace crashpad { 27 namespace crashpad {
18 28
19 #if defined(OS_MACOSX) && MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_7
20 size_t strnlen(const char* string, size_t max_length) { 29 size_t strnlen(const char* string, size_t max_length) {
21 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7 30 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
22 if (::strnlen) { 31 if (::strnlen) {
23 return ::strnlen(string, max_length); 32 return ::strnlen(string, max_length);
24 } 33 }
25 #endif 34 #endif
26 35
27 for (size_t index = 0; index < max_length; ++index) { 36 for (size_t index = 0; index < max_length; ++index) {
28 if (string[index] == '\0') { 37 if (string[index] == '\0') {
29 return index; 38 return index;
30 } 39 }
31 } 40 }
32 41
33 return max_length; 42 return max_length;
34 } 43 }
35 #endif
36 44
37 } // namespace crashpad 45 } // namespace crashpad
46
47 #endif
OLDNEW
« no previous file with comments | « util/mach/exception_types.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698