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

Side by Side Diff: base/safe_strerror_posix.h

Issue 6902177: linux components: expose more BASE_API used by Chrome itself (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: copyrights Created 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #ifndef BASE_SAFE_STRERROR_POSIX_H_ 5 #ifndef BASE_SAFE_STRERROR_POSIX_H_
6 #define BASE_SAFE_STRERROR_POSIX_H_ 6 #define BASE_SAFE_STRERROR_POSIX_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
11 #include "base/base_api.h"
12
11 // BEFORE using anything from this file, first look at PLOG and friends in 13 // BEFORE using anything from this file, first look at PLOG and friends in
12 // logging.h and use them instead if applicable. 14 // logging.h and use them instead if applicable.
13 // 15 //
14 // This file declares safe, portable alternatives to the POSIX strerror() 16 // This file declares safe, portable alternatives to the POSIX strerror()
15 // function. strerror() is inherently unsafe in multi-threaded apps and should 17 // function. strerror() is inherently unsafe in multi-threaded apps and should
16 // never be used. Doing so can cause crashes. Additionally, the thread-safe 18 // never be used. Doing so can cause crashes. Additionally, the thread-safe
17 // alternative strerror_r varies in semantics across platforms. Use these 19 // alternative strerror_r varies in semantics across platforms. Use these
18 // functions instead. 20 // functions instead.
19 21
20 // Thread-safe strerror function with dependable semantics that never fails. 22 // Thread-safe strerror function with dependable semantics that never fails.
21 // It will write the string form of error "err" to buffer buf of length len. 23 // It will write the string form of error "err" to buffer buf of length len.
22 // If there is an error calling the OS's strerror_r() function then a message to 24 // If there is an error calling the OS's strerror_r() function then a message to
23 // that effect will be printed into buf, truncating if necessary. The final 25 // that effect will be printed into buf, truncating if necessary. The final
24 // result is always null-terminated. The value of errno is never changed. 26 // result is always null-terminated. The value of errno is never changed.
25 // 27 //
26 // Use this instead of strerror_r(). 28 // Use this instead of strerror_r().
27 void safe_strerror_r(int err, char *buf, size_t len); 29 BASE_API void safe_strerror_r(int err, char *buf, size_t len);
28 30
29 // Calls safe_strerror_r with a buffer of suitable size and returns the result 31 // Calls safe_strerror_r with a buffer of suitable size and returns the result
30 // in a C++ string. 32 // in a C++ string.
31 // 33 //
32 // Use this instead of strerror(). Note though that safe_strerror_r will be 34 // Use this instead of strerror(). Note though that safe_strerror_r will be
33 // more robust in the case of heap corruption errors, since it doesn't need to 35 // more robust in the case of heap corruption errors, since it doesn't need to
34 // allocate a string. 36 // allocate a string.
35 std::string safe_strerror(int err); 37 BASE_API std::string safe_strerror(int err);
36 38
37 #endif // BASE_SAFE_STRERROR_POSIX_H_ 39 #endif // BASE_SAFE_STRERROR_POSIX_H_
OLDNEW
« base/linux_util.h ('K') | « base/process_util.h ('k') | sandbox/linux/suid/process_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698