Nico Huber submitted this change.

View Change

Approvals: build bot (Jenkins): Verified Nico Huber: Looks good to me, approved
tests: Fix fread wrap to return success by default

Successful return value for fread is the number of items read, and
default behaviour for all wraps is to return success.

This worked previously because all existing tests have custom mocks
for fread, so default behaviour hasn't been used. However next patch
in this chain adds new test which needs default fread wrap.

BUG=b:181803212
TEST=ninja test

Change-Id: I17d82d281a87129843f547b87c18f52aca23314d
Signed-off-by: Anastasia Klimchuk <aklm@chromium.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/58356
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Nico Huber <nico.h@gmx.de>
---
M tests/tests.c
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tests/tests.c b/tests/tests.c
index 3eb3129..d3df356 100644
--- a/tests/tests.c
+++ b/tests/tests.c
@@ -168,12 +168,12 @@
return NULL;
}

-size_t __wrap_fread(void *ptr, size_t size, size_t len, FILE *fp)
+size_t __wrap_fread(void *ptr, size_t size, size_t nmemb, FILE *fp)
{
LOG_ME;
if (get_io() && get_io()->fread)
- return get_io()->fread(get_io()->state, ptr, size, len, fp);
- return 0;
+ return get_io()->fread(get_io()->state, ptr, size, nmemb, fp);
+ return nmemb;
}

size_t __wrap_fwrite(const void *ptr, size_t size, size_t nmemb, FILE *fp)

To view, visit change 58356. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I17d82d281a87129843f547b87c18f52aca23314d
Gerrit-Change-Number: 58356
Gerrit-PatchSet: 3
Gerrit-Owner: Anastasia Klimchuk <aklm@chromium.org>
Gerrit-Reviewer: Angel Pons <th3fanbus@gmail.com>
Gerrit-Reviewer: Edward O'Callaghan <quasisec@chromium.org>
Gerrit-Reviewer: Nico Huber <nico.h@gmx.de>
Gerrit-Reviewer: build bot (Jenkins) <no-reply@coreboot.org>
Gerrit-CC: Paul Menzel <paulepanter@mailbox.org>
Gerrit-MessageType: merged