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

Side by Side Diff: posix/safe_strerror.cc

Issue 1712863003: Fixing clang warnings. (Closed) Base URL: https://chromium.googlesource.com/external/github.com/domokit/base@master
Patch Set: Created 4 years, 10 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 | « no previous file | third_party/dynamic_annotations/dynamic_annotations.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #if defined(__ANDROID__) 5 #if defined(__ANDROID__)
6 // Post-L versions of bionic define the GNU-specific strerror_r if _GNU_SOURCE 6 // Post-L versions of bionic define the GNU-specific strerror_r if _GNU_SOURCE
7 // is defined, but the symbol is renamed to __gnu_strerror_r which only exists 7 // is defined, but the symbol is renamed to __gnu_strerror_r which only exists
8 // on those later versions. To preserve ABI compatibility with older versions, 8 // on those later versions. To preserve ABI compatibility with older versions,
9 // undefine _GNU_SOURCE and use the POSIX version. 9 // undefine _GNU_SOURCE and use the POSIX version.
10 #undef _GNU_SOURCE 10 #undef _GNU_SOURCE
11 #endif 11 #endif
12 12
13 #include "base/posix/safe_strerror.h" 13 #include "base/posix/safe_strerror.h"
14 14
15 #include <errno.h> 15 #include <errno.h>
16 #include <stdio.h> 16 #include <stdio.h>
17 #include <string.h> 17 #include <string.h>
18 18
19 #include "build/build_config.h" 19 #include "build/build_config.h"
20 20
21 namespace base { 21 namespace base {
22 22
23 #define USE_HISTORICAL_STRERRO_R (defined(__GLIBC__) || defined(OS_NACL)) 23 #if defined(__GLIBC__) || defined(OS_NACL)
24 #define USE_HISTORICAL_STRERRO_R 1
25 #else
26 #define USE_HISTORICAL_STRERRO_R 0
27 #endif
24 28
25 #if USE_HISTORICAL_STRERRO_R && defined(__GNUC__) 29 #if USE_HISTORICAL_STRERRO_R && defined(__GNUC__)
26 // GCC will complain about the unused second wrap function unless we tell it 30 // GCC will complain about the unused second wrap function unless we tell it
27 // that we meant for them to be potentially unused, which is exactly what this 31 // that we meant for them to be potentially unused, which is exactly what this
28 // attribute is for. 32 // attribute is for.
29 #define POSSIBLY_UNUSED __attribute__((unused)) 33 #define POSSIBLY_UNUSED __attribute__((unused))
30 #else 34 #else
31 #define POSSIBLY_UNUSED 35 #define POSSIBLY_UNUSED
32 #endif 36 #endif
33 37
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 } 119 }
116 120
117 std::string safe_strerror(int err) { 121 std::string safe_strerror(int err) {
118 const int buffer_size = 256; 122 const int buffer_size = 256;
119 char buf[buffer_size]; 123 char buf[buffer_size];
120 safe_strerror_r(err, buf, sizeof(buf)); 124 safe_strerror_r(err, buf, sizeof(buf));
121 return std::string(buf); 125 return std::string(buf);
122 } 126 }
123 127
124 } // namespace base 128 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | third_party/dynamic_annotations/dynamic_annotations.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698