Browse Source

storage: Use const pointers for namespace key

Helmut Pozimski 1 year ago
parent
commit
c7f8e108ed
2 changed files with 6 additions and 6 deletions
  1. 3 3
      main/storage.c
  2. 3 3
      main/storage.h

+ 3 - 3
main/storage.c

@@ -1,5 +1,5 @@
 /*
- * SPDX-FileCopyrightText: 2022 Helmut Pozimski <helmut@pozimski.eu>
+ * SPDX-FileCopyrightText: 2022-2023 Helmut Pozimski <helmut@pozimski.eu>
  *
  * SPDX-License-Identifier: GPL-2.0-only
  */
@@ -21,7 +21,7 @@ static void format_date(struct tm* datetime, char* output) {
     snprintf(output, 9, "%.4s%.2s%.2s", year, month, day);
 }
 
-esp_err_t storage_init(char* name) {
+esp_err_t storage_init(const char* name) {
    return nvs_open(name, NVS_READWRITE, &handle);
 }
 
@@ -51,7 +51,7 @@ esp_err_t delete_wakeup_time_str(const char* key) {
 	return ret | nvs_commit(handle);
 }
 
-void delete_outdated_entries(struct tm* datetime, char* namespace) {
+void delete_outdated_entries(struct tm* datetime, const char* namespace) {
 	char reference_date_str[9];
 	format_date(datetime, reference_date_str);
 	int reference_date = atoi(reference_date_str);

+ 3 - 3
main/storage.h

@@ -1,5 +1,5 @@
 /*
- * SPDX-FileCopyrightText: 2022 Helmut Pozimski <helmut@pozimski.eu>
+ * SPDX-FileCopyrightText: 2022-2023 Helmut Pozimski <helmut@pozimski.eu>
  *
  * SPDX-License-Identifier: GPL-2.0-only
  */
@@ -13,10 +13,10 @@
 
 static const char WEEK_DAYS[NUM_WEEK_DAYS][4] = {"MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN"};
 
-esp_err_t storage_init(char* name);
+esp_err_t storage_init(const char* name);
 esp_err_t write_wakeup_time_tm(struct tm* datetime, int16_t value);
 esp_err_t write_wakeup_time_str(const char* key, int16_t value);
 esp_err_t read_wakeup_time_tm(struct tm* datetime, int16_t* value);
 esp_err_t read_wakeup_time_str(const char* key, int16_t* value);
 esp_err_t delete_wakeup_time_str(const char* key);
-void delete_outdated_entries(struct tm* datetime, char* namespace);
+void delete_outdated_entries(struct tm* datetime, const char* namespace);