• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2017 The Chromium OS 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 SRC_SET_ERRORS_H_
6 #define SRC_SET_ERRORS_H_
7 
8 #ifdef USE_BRILLO
9 #include "base/logging.h"
10 #else
11 #include "glog/logging.h"
12 #endif
13 
14 namespace puffin {
15 
16 #define TEST_AND_RETURN_FALSE(_x)   \
17   do {                              \
18     if (!(_x)) {                    \
19       LOG(ERROR) << #_x " failed."; \
20       return false;                 \
21     }                               \
22   } while (0)
23 
24 #define TEST_AND_RETURN_VALUE(_x, _v) \
25   do {                                \
26     if (!(_x)) {                      \
27       LOG(ERROR) << #_x " failed.";   \
28       return (_v);                    \
29     }                                 \
30   } while (0)
31 
32 #define TEST_AND_RETURN_FALSE_SET_ERROR(_x, _error) \
33   do {                                              \
34     if (!(_x)) {                                    \
35       (*error) = (_error);                          \
36       LOG(ERROR) << #_x " failed.";                 \
37       return false;                                 \
38     }                                               \
39   } while (0)
40 
41 }  // namespace puffin
42 
43 #endif  // SRC_SET_ERRORS_H_
44