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

Side by Side Diff: base/scoped_clear_errno.h

Issue 14749003: Stop overwriting errno in base::StringPrintf, StringAppendV, and StringToDouble (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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
« no previous file with comments | « base/process_util_mac.mm ('k') | base/scoped_clear_errno_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef BASE_SCOPED_CLEAR_ERRNO_H_
6 #define BASE_SCOPED_CLEAR_ERRNO_H_
7
8 #include <errno.h>
9
10 #include "base/basictypes.h"
11
12 // Simple scoper that saves the current value of errno, resets it to 0, and on
brettw 2013/05/02 18:30:18 Please put this file in the base namespace.
Yusuke Sato 2013/05/02 18:50:31 Done.
13 // destruction puts the old value back.
14 class ScopedClearErrno {
15 public:
16 ScopedClearErrno() : old_errno_(errno) {
17 errno = 0;
18 }
19 ~ScopedClearErrno() {
20 if (errno == 0)
21 errno = old_errno_;
22 }
23
24 private:
25 const int old_errno_;
26
27 DISALLOW_COPY_AND_ASSIGN(ScopedClearErrno);
28 };
29
30 #endif // BASE_SCOPED_CLEAR_ERRNO_H_
OLDNEW
« no previous file with comments | « base/process_util_mac.mm ('k') | base/scoped_clear_errno_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698