Browse Source

Const modifiers

This functions do not change class variables
Would be good to mark them as const, so
class variables are not changed by coincidence

Change-Id: Iea34f6d26dbd1bde813035160e07ff2a681989e6
Mikhail Lappo 4 years ago
parent
commit
b49767c0ba
6 changed files with 11 additions and 11 deletions
  1. 1
    1
      otafault/ota_io.cpp
  2. 1
    1
      otafault/ota_io.h
  3. 3
    3
      screen_ui.cpp
  4. 3
    3
      screen_ui.h
  5. 1
    1
      verifier.cpp
  6. 2
    2
      verifier.h

+ 1
- 1
otafault/ota_io.cpp View File

@@ -89,7 +89,7 @@ static int __ota_fclose(FILE* fh) {
89 89
     return fclose(fh);
90 90
 }
91 91
 
92
-void OtaFcloser::operator()(FILE* f) {
92
+void OtaFcloser::operator()(FILE* f) const {
93 93
     __ota_fclose(f);
94 94
 };
95 95
 

+ 1
- 1
otafault/ota_io.h View File

@@ -59,7 +59,7 @@ using unique_fd = android::base::unique_fd_impl<OtaCloser>;
59 59
 int ota_close(unique_fd& fd);
60 60
 
61 61
 struct OtaFcloser {
62
-  void operator()(FILE*);
62
+  void operator()(FILE*) const;
63 63
 };
64 64
 
65 65
 using unique_file = std::unique_ptr<FILE, OtaFcloser>;

+ 3
- 3
screen_ui.cpp View File

@@ -98,7 +98,7 @@ GRSurface* ScreenRecoveryUI::GetCurrentText() {
98 98
     }
99 99
 }
100 100
 
101
-int ScreenRecoveryUI::PixelsFromDp(int dp) {
101
+int ScreenRecoveryUI::PixelsFromDp(int dp) const {
102 102
     return dp * density_;
103 103
 }
104 104
 
@@ -256,12 +256,12 @@ void ScreenRecoveryUI::DrawHorizontalRule(int* y) {
256 256
     *y += 4;
257 257
 }
258 258
 
259
-void ScreenRecoveryUI::DrawTextLine(int x, int* y, const char* line, bool bold) {
259
+void ScreenRecoveryUI::DrawTextLine(int x, int* y, const char* line, bool bold) const {
260 260
     gr_text(gr_sys_font(), x, *y, line, bold);
261 261
     *y += char_height_ + 4;
262 262
 }
263 263
 
264
-void ScreenRecoveryUI::DrawTextLines(int x, int* y, const char* const* lines) {
264
+void ScreenRecoveryUI::DrawTextLines(int x, int* y, const char* const* lines) const {
265 265
     for (size_t i = 0; lines != nullptr && lines[i] != nullptr; ++i) {
266 266
         DrawTextLine(x, y, lines[i], false);
267 267
     }

+ 3
- 3
screen_ui.h View File

@@ -160,14 +160,14 @@ class ScreenRecoveryUI : public RecoveryUI {
160 160
     void LoadBitmap(const char* filename, GRSurface** surface);
161 161
     void LoadLocalizedBitmap(const char* filename, GRSurface** surface);
162 162
 
163
-    int PixelsFromDp(int dp);
163
+    int PixelsFromDp(int dp) const;
164 164
     virtual int GetAnimationBaseline();
165 165
     virtual int GetProgressBaseline();
166 166
     virtual int GetTextBaseline();
167 167
 
168 168
     void DrawHorizontalRule(int* y);
169
-    void DrawTextLine(int x, int* y, const char* line, bool bold);
170
-    void DrawTextLines(int x, int* y, const char* const* lines);
169
+    void DrawTextLine(int x, int* y, const char* line, bool bold) const;
170
+    void DrawTextLines(int x, int* y, const char* const* lines) const;
171 171
 };
172 172
 
173 173
 #endif  // RECOVERY_UI_H

+ 1
- 1
verifier.cpp View File

@@ -370,7 +370,7 @@ std::unique_ptr<RSA, RSADeleter> parse_rsa_key(FILE* file, uint32_t exponent) {
370 370
 }
371 371
 
372 372
 struct BNDeleter {
373
-  void operator()(BIGNUM* bn) {
373
+  void operator()(BIGNUM* bn) const {
374 374
     BN_free(bn);
375 375
   }
376 376
 };

+ 2
- 2
verifier.h View File

@@ -26,13 +26,13 @@
26 26
 #include <openssl/sha.h>
27 27
 
28 28
 struct RSADeleter {
29
-  void operator()(RSA* rsa) {
29
+  void operator()(RSA* rsa) const {
30 30
     RSA_free(rsa);
31 31
   }
32 32
 };
33 33
 
34 34
 struct ECKEYDeleter {
35
-  void operator()(EC_KEY* ec_key) {
35
+  void operator()(EC_KEY* ec_key) const {
36 36
     EC_KEY_free(ec_key);
37 37
   }
38 38
 };