OLD | NEW |
1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium OS 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 CHROMEOS_PLATFORM_UPDATE_ENGINE_UTILS_H__ | 5 #ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_UTILS_H__ |
6 #define CHROMEOS_PLATFORM_UPDATE_ENGINE_UTILS_H__ | 6 #define CHROMEOS_PLATFORM_UPDATE_ENGINE_UTILS_H__ |
7 | 7 |
8 #include <errno.h> | 8 #include <errno.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 // Detects which bootloader this system uses and returns it via the out | 118 // Detects which bootloader this system uses and returns it via the out |
119 // param. Returns true on success. | 119 // param. Returns true on success. |
120 bool GetBootloader(BootLoader* out_bootloader); | 120 bool GetBootloader(BootLoader* out_bootloader); |
121 | 121 |
122 // Returns the error message, if any, from a GError pointer. | 122 // Returns the error message, if any, from a GError pointer. |
123 const char* GetGErrorMessage(const GError* error); | 123 const char* GetGErrorMessage(const GError* error); |
124 | 124 |
125 // Initiates a system reboot. Returns true on success, false otherwise. | 125 // Initiates a system reboot. Returns true on success, false otherwise. |
126 bool Reboot(); | 126 bool Reboot(); |
127 | 127 |
| 128 // Fuzzes an integer |value| randomly in the range: |
| 129 // [value - range / 2, value + range - range / 2] |
| 130 int FuzzInt(int value, unsigned int range); |
| 131 |
128 // Log a string in hex to LOG(INFO). Useful for debugging. | 132 // Log a string in hex to LOG(INFO). Useful for debugging. |
129 void HexDumpArray(const unsigned char* const arr, const size_t length); | 133 void HexDumpArray(const unsigned char* const arr, const size_t length); |
130 inline void HexDumpString(const std::string& str) { | 134 inline void HexDumpString(const std::string& str) { |
131 HexDumpArray(reinterpret_cast<const unsigned char*>(str.data()), str.size()); | 135 HexDumpArray(reinterpret_cast<const unsigned char*>(str.data()), str.size()); |
132 } | 136 } |
133 inline void HexDumpVector(const std::vector<char>& vect) { | 137 inline void HexDumpVector(const std::vector<char>& vect) { |
134 HexDumpArray(reinterpret_cast<const unsigned char*>(&vect[0]), vect.size()); | 138 HexDumpArray(reinterpret_cast<const unsigned char*>(&vect[0]), vect.size()); |
135 } | 139 } |
136 | 140 |
137 extern const char* const kStatefulPartition; | 141 extern const char* const kStatefulPartition; |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 bool _success = (_x); \ | 333 bool _success = (_x); \ |
330 if (!_success) { \ | 334 if (!_success) { \ |
331 LOG(ERROR) << #_x " failed."; \ | 335 LOG(ERROR) << #_x " failed."; \ |
332 return; \ | 336 return; \ |
333 } \ | 337 } \ |
334 } while (0) | 338 } while (0) |
335 | 339 |
336 | 340 |
337 | 341 |
338 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_UTILS_H__ | 342 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_UTILS_H__ |
OLD | NEW |