Commit Graph

8 Commits

Author SHA1 Message Date
David Rogers
c4dc8644e6 pw_status: Minor update for PW_TRY macros
- Remove TRY* short name macros and switch existing use to PW_TRY*
- Make PW_TRY macros use constexpr rather than inline internally.

Change-Id: Ia86071183c76568241425ae8b5eafec8313fc133
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/18165
Reviewed-by: Keir Mierle <keir@google.com>
Commit-Queue: David Rogers <davidrogers@google.com>
2020-09-15 02:08:43 +00:00
David Rogers
b6b14b8e36 pw_status: Add TRY macros
- Add TRY macros to status module (they are moving from pw_kvs).
- Switch pw_kvs to use pw_status/try.
- Remove TRY macros from pw_kvs.

Change-Id: I72c844f4a452c80d8053cb0cf64b0dd88e891367
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/18040
Commit-Queue: David Rogers <davidrogers@google.com>
Reviewed-by: Wyatt Hepler <hepler@google.com>
Reviewed-by: Keir Mierle <keir@google.com>
2020-09-14 17:26:28 +00:00
Wyatt Hepler
e2cbadfa0c pw_span: Switch from pw::span to std::span
Replace pw::span with std::span and "pw_span/span.h" with <span>
throughout the codebase.

Change-Id: Ib1fa873168b6093794e861611d750fcad6285d6c
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/12801
Commit-Queue: Wyatt Hepler <hepler@google.com>
Reviewed-by: Rob Mohr <mohrr@google.com>
Reviewed-by: Keir Mierle <keir@google.com>
2020-07-01 01:37:27 +00:00
Wyatt Hepler
289046011c pw_kvs: AlignedWriter read-and-write function
Define AlignedWriter::Write overload that reads into the internal buffer
from an Input and writes it aligned to the output.

Change-Id: I72c1dead8cdcb912bf44fd1e36940cdb741f92df
2020-03-10 20:34:40 +00:00
Wyatt Hepler
0f2ad9fce9 pw_kvs: Fix AlignedWrite issues; expand tests
- Update AlignedWriter to prevent writing after an error occurs.
- Ensure that the number of written bytes is always returned for
  AlignedWriter errors.
- Remove FlashError::Mode, since the number of bytes affected should
  always be set.
- Add tests to alignment_test.cc and key_value_store.cc to cover
  failures during AlignedWrite.
- Update some comments.

Change-Id: Id62f1564b3641be0aeb7f799f0fa0538a1b5b09e
2020-02-26 09:17:06 -08:00
David Rogers
6592d291e4 pw_kvs: Add free space accounting for write errors
Add accounting of byte written to flash when write operation has an error.

Change-Id: I4268cf36de16648fa10117fb6a828327685d4417
2020-02-21 03:03:28 +00:00
Wyatt Hepler
50f70779c8 Remove StatusWithSize implicit conversions
- Disallow implicit conversions between Status and StatusWithSize, which
  can be problematic.
- Add TRY_WITH_SIZE to pw_kvs to handle returning StatusWithSize from
  functions.
- Make zero the default size argument for StatusWithSize.
- Expand tests for StatusWithSize.

Change-Id: Ia1c36e5a39402a50138d93e89afbaa5e772adb8a
2020-02-14 17:59:00 +00:00
Wyatt Hepler
1927c2868b pw_kvs: Split out aligned write functionality
- Define the Output interface.
- Create AlignedWriter class, which handles writing aligned and padded
  data to a buffer.
- Define AlignedWriterBuffer, which provides a buffer to an
  AlignedWriter.

Change-Id: I791c5fc2d47617b0866fa779a506cb977905f245
2020-02-12 17:00:09 -08:00