Skip to content

Commit

Permalink
Const modifiers
Browse files Browse the repository at this point in the history
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
  • Loading branch information
miklelappo committed Mar 23, 2017
1 parent 20791bd commit b49767c
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion otafault/ota_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ static int __ota_fclose(FILE* fh) {
return fclose(fh);
}

void OtaFcloser::operator()(FILE* f) {
void OtaFcloser::operator()(FILE* f) const {
__ota_fclose(f);
};

Expand Down
2 changes: 1 addition & 1 deletion otafault/ota_io.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ using unique_fd = android::base::unique_fd_impl<OtaCloser>;
int ota_close(unique_fd& fd);

struct OtaFcloser {
void operator()(FILE*);
void operator()(FILE*) const;
};

using unique_file = std::unique_ptr<FILE, OtaFcloser>;
Expand Down
6 changes: 3 additions & 3 deletions screen_ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ GRSurface* ScreenRecoveryUI::GetCurrentText() {
}
}

int ScreenRecoveryUI::PixelsFromDp(int dp) {
int ScreenRecoveryUI::PixelsFromDp(int dp) const {
return dp * density_;
}

Expand Down Expand Up @@ -256,12 +256,12 @@ void ScreenRecoveryUI::DrawHorizontalRule(int* y) {
*y += 4;
}

void ScreenRecoveryUI::DrawTextLine(int x, int* y, const char* line, bool bold) {
void ScreenRecoveryUI::DrawTextLine(int x, int* y, const char* line, bool bold) const {
gr_text(gr_sys_font(), x, *y, line, bold);
*y += char_height_ + 4;
}

void ScreenRecoveryUI::DrawTextLines(int x, int* y, const char* const* lines) {
void ScreenRecoveryUI::DrawTextLines(int x, int* y, const char* const* lines) const {
for (size_t i = 0; lines != nullptr && lines[i] != nullptr; ++i) {
DrawTextLine(x, y, lines[i], false);
}
Expand Down
6 changes: 3 additions & 3 deletions screen_ui.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,14 +160,14 @@ class ScreenRecoveryUI : public RecoveryUI {
void LoadBitmap(const char* filename, GRSurface** surface);
void LoadLocalizedBitmap(const char* filename, GRSurface** surface);

int PixelsFromDp(int dp);
int PixelsFromDp(int dp) const;
virtual int GetAnimationBaseline();
virtual int GetProgressBaseline();
virtual int GetTextBaseline();

void DrawHorizontalRule(int* y);
void DrawTextLine(int x, int* y, const char* line, bool bold);
void DrawTextLines(int x, int* y, const char* const* lines);
void DrawTextLine(int x, int* y, const char* line, bool bold) const;
void DrawTextLines(int x, int* y, const char* const* lines) const;
};

#endif // RECOVERY_UI_H
2 changes: 1 addition & 1 deletion verifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ std::unique_ptr<RSA, RSADeleter> parse_rsa_key(FILE* file, uint32_t exponent) {
}

struct BNDeleter {
void operator()(BIGNUM* bn) {
void operator()(BIGNUM* bn) const {
BN_free(bn);
}
};
Expand Down
4 changes: 2 additions & 2 deletions verifier.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@
#include <openssl/sha.h>

struct RSADeleter {
void operator()(RSA* rsa) {
void operator()(RSA* rsa) const {
RSA_free(rsa);
}
};

struct ECKEYDeleter {
void operator()(EC_KEY* ec_key) {
void operator()(EC_KEY* ec_key) const {
EC_KEY_free(ec_key);
}
};
Expand Down

0 comments on commit b49767c

Please sign in to comment.