mirror of
https://github.com/CovidBraceletPrj/CovidBracelet.git
synced 2024-12-04 16:45:43 +01:00
Format ens files and add .clang-format file
This commit is contained in:
parent
522a2aab9d
commit
80cba23823
1
.clang-format
Normal file
1
.clang-format
Normal file
@ -0,0 +1 @@
|
||||
{ BasedOnStyle: Chromium, UseTab: Never, IndentWidth: 4, TabWidth: 4, ColumnLimit: 120 }
|
@ -1,10 +1,10 @@
|
||||
#include <drivers/flash.h>
|
||||
#include <storage/flash_map.h>
|
||||
#include <sys/crc.h>
|
||||
#include <string.h>
|
||||
#include <sys/crc.h>
|
||||
|
||||
#include "ens_fs.h"
|
||||
#include "ens_error.h"
|
||||
#include "ens_fs.h"
|
||||
|
||||
#define SEED 42
|
||||
|
||||
@ -36,7 +36,6 @@ int ens_fs_init(ens_fs_t* fs, uint8_t id, uint64_t entry_size) {
|
||||
}
|
||||
|
||||
int ens_fs_read(ens_fs_t* fs, uint64_t id, void* dist) {
|
||||
|
||||
// read the entry from flash
|
||||
uint64_t offset = id * fs->entry_size;
|
||||
if (flash_area_read(fs->area, offset, dist, fs->entry_size)) {
|
||||
@ -59,7 +58,6 @@ int ens_fs_read(ens_fs_t* fs, uint64_t id, void* dist) {
|
||||
}
|
||||
|
||||
int ens_fs_write(ens_fs_t* fs, uint64_t id, void* data) {
|
||||
|
||||
// set CRC and not-deleted-flag
|
||||
uint8_t* obj = data;
|
||||
obj[fs->entry_size - 1] = crc7_be(SEED, obj, fs->entry_size - 1) | 1;
|
||||
@ -74,7 +72,6 @@ int ens_fs_write(ens_fs_t* fs, uint64_t id, void* data) {
|
||||
}
|
||||
|
||||
int ens_fs_delete(ens_fs_t* fs, uint64_t id) {
|
||||
|
||||
uint8_t data[fs->entry_size];
|
||||
|
||||
uint64_t offset = id * fs->entry_size;
|
||||
@ -94,7 +91,6 @@ int ens_fs_delete(ens_fs_t* fs, uint64_t id) {
|
||||
}
|
||||
|
||||
int ens_fs_page_erase(ens_fs_t* fs, uint64_t offset, uint64_t sector_count) {
|
||||
|
||||
// calculate the next page start before (or at) the given offset
|
||||
uint64_t start = (offset - offset % fs->sector_size) * fs->entry_size;
|
||||
|
||||
|
@ -24,8 +24,6 @@ int ens_records_iterator_init_range(record_iterator_t* iterator,
|
||||
record_sequence_number_t* opt_start,
|
||||
record_sequence_number_t* opt_end);
|
||||
|
||||
// TODO: This function should call with the relevant start and end sequence numbers (retrieved through e.g. binary
|
||||
// search / metadata)
|
||||
// TODO: Do we guarantee that higher sequence numbers have at least our timestamp and lower sequence numbers up to our
|
||||
// timestamp?
|
||||
int ens_records_iterator_init_timerange(record_iterator_t* iterator, uint32_t* ts_start, uint32_t* ts_end);
|
||||
|
@ -72,7 +72,8 @@ int init_contact_storage(void) {
|
||||
struct flash_pages_info info;
|
||||
// define the nvs file system
|
||||
info_fs.offset = FLASH_AREA_OFFSET(storage);
|
||||
rc = flash_get_page_info_by_offs(device_get_binding(DT_CHOSEN_ZEPHYR_FLASH_CONTROLLER_LABEL), info_fs.offset, &info);
|
||||
rc =
|
||||
flash_get_page_info_by_offs(device_get_binding(DT_CHOSEN_ZEPHYR_FLASH_CONTROLLER_LABEL), info_fs.offset, &info);
|
||||
|
||||
if (rc) {
|
||||
// Error during retrieval of page information
|
||||
@ -118,7 +119,6 @@ int load_contact(record_t* dest, record_sequence_number_t sn) {
|
||||
}
|
||||
|
||||
int add_contact(record_t* src) {
|
||||
|
||||
// Check, if next sn would be at start of page
|
||||
record_sequence_number_t potential_next_sn = sn_increment(get_latest_sequence_number());
|
||||
storage_id_t potential_next_id = convert_sn_to_storage_id(potential_next_sn);
|
||||
|
@ -2,8 +2,8 @@
|
||||
#define CONTACT_STORAGE_H
|
||||
|
||||
#include "../contacts.h" // Requires contact_t in contacts.h!
|
||||
#include "sequencenumber.h"
|
||||
#include "../covid_types.h"
|
||||
#include "sequencenumber.h"
|
||||
|
||||
typedef uint16_t storage_id_t;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user