Skip to content

Commit 4998d1e

Browse files
committed
fix(sha256_file): Improve the retval
- set ret = 0 during normal completion (eof) - do not use access(2) Signed-off-by: Krisztian Szilvasi <34309983+kr-t@users.noreply.github.com>
1 parent aee470a commit 4998d1e

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

src/shell/image/sha256_file.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ int sha256_file(const char *path, char *hash)
2626

2727
int fd = open(path, O_RDONLY);
2828
if (fd < 0) {
29-
return -1;
29+
return -2;
3030
}
3131

3232
struct stat finfo;
@@ -57,7 +57,6 @@ int sha256_file(const char *path, char *hash)
5757
}
5858

5959
if (!bytes_read) {
60-
ret = 0;
6160
break;
6261
}
6362

@@ -66,6 +65,8 @@ int sha256_file(const char *path, char *hash)
6665
total_bytes_read += bytes_read;
6766
}
6867

68+
ret = 0;
69+
6970
sha256_finalize(&buff);
7071
sha256_read_hex(&buff, hash);
7172

0 commit comments

Comments
 (0)