Skip to content

Commit e49eae0

Browse files
authored
Remove comments as requested during review.
1 parent fe42564 commit e49eae0

File tree

1 file changed

+10
-15
lines changed

1 file changed

+10
-15
lines changed

libraries/Preferences/src/Preferences.cpp

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
1+
// Copyright 2015-2021 Espressif Systems (Shanghai) PTE LTD
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
55
// You may obtain a copy of the License at
6+
67
// http://www.apache.org/licenses/LICENSE-2.0
78
//
89
// Unless required by applicable law or agreed to in writing, software
@@ -43,7 +44,7 @@ bool Preferences::begin(const char * name, bool readOnly, const char* partition_
4344
}
4445
err = nvs_open_from_partition(partition_label, name, readOnly ? NVS_READONLY : NVS_READWRITE, &_handle);
4546
} else {
46-
err = nvs_open(name, readOnly?NVS_READONLY:NVS_READWRITE, &_handle);
47+
err = nvs_open(name, readOnly ? NVS_READONLY : NVS_READWRITE, &_handle);
4748
}
4849
if(err){
4950
log_e("nvs_open failed: %s", nvs_error(err));
@@ -53,14 +54,10 @@ bool Preferences::begin(const char * name, bool readOnly, const char* partition_
5354
return true;
5455
}
5556

56-
void Preferences::end(){ // modified to add an nvs_commit()
57+
void Preferences::end(){
5758
if(!_started){
5859
return;
5960
}
60-
esp_err_t err = nvs_commit(_handle); // to undo changes: delete the lines from here...
61-
if(err){
62-
log_e("nvs_commit fail: %s %s", key, nvs_error(err));
63-
} // ... to here.
6461
nvs_close(_handle);
6562
_started = false;
6663
}
@@ -69,7 +66,7 @@ void Preferences::end(){ // modified to
6966
* Clear all keys in opened preferences
7067
* */
7168

72-
bool Preferences::clear(){ // modified to add an nvs_commit()
69+
bool Preferences::clear(){
7370
if(!_started || _readOnly){
7471
return false;
7572
}
@@ -78,20 +75,19 @@ bool Preferences::clear(){ // modified to add a
7875
log_e("nvs_erase_all fail: %s", nvs_error(err));
7976
return false;
8077
}
81-
// return true; // to undo changes: uncomment this line and...
82-
err = nvs_commit(_handle); // ... delete the lines from from here...
78+
err = nvs_commit(_handle);
8379
if(err){
8480
log_e("nvs_commit fail: %s", nvs_error(err));
8581
return false;
8682
}
87-
return true; // ... to here.
83+
return true;
8884
}
8985

9086
/*
9187
* Remove a key
9288
* */
9389

94-
bool Preferences::remove(const char * key){ // modified to add an nvs_commit()
90+
bool Preferences::remove(const char * key){
9591
if(!_started || !key || _readOnly){
9692
return false;
9793
}
@@ -100,13 +96,12 @@ bool Preferences::remove(const char * key){ // modified to add a
10096
log_e("nvs_erase_key fail: %s %s", key, nvs_error(err));
10197
return false;
10298
}
103-
// return true; // to undo changes: uncomment this line and...
104-
err = nvs_commit(_handle); // ... delete the lines from from here...
99+
err = nvs_commit(_handle);
105100
if(err){
106101
log_e("nvs_commit fail: %s %s", key, nvs_error(err));
107102
return false;
108103
}
109-
return true; // ... to here.
104+
return true;
110105
}
111106

112107
/*

0 commit comments

Comments
 (0)